Class PvattestWrapper
java.lang.Object
com.suse.coco.module.pvattest.execution.PvattestWrapper
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.suse.common.io.process.ShellCommandExecutorprivate static final Pathstatic final Stringstatic final Stringprivate static final org.apache.logging.log4j.Loggerprotected static final Pathprivate static final Stringprivate final Pathprivate final FileAttribute<Set<PosixFilePermission>> private final FileAttribute<Set<PosixFilePermission>> -
Constructor Summary
ConstructorsConstructorDescriptiondefault constructorPvattestWrapper(com.suse.common.io.process.ShellCommandExecutor commandExecutorIn) ConstructorPvattestWrapper(com.suse.common.io.process.ShellCommandExecutor commandExecutorIn, Path sourceDigiCertCaCertificateFileIn) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckCommandNotFailed(com.suse.common.io.process.ProcessOutput output) private AttestationRequestcreateAttestationRequest(Path attestationRequestFile, Path attestationProtectionKeyFile) private AttestationResponsecreateAttestationResult(Path attestationResultFile) private AttestationRequestcreateCore(X509Certificate hostKeyDocument, boolean doVerify, X509Certificate digiCertCACertificate, X509Certificate ibmZHostKeySigningCertificateX) createNoVerify(String hostKeyDocumentContent) Creates an attestation request, with no certificate verificationprivate PathcreateTempBinaryFile(Path tempDir, String prefix, String suffix, byte[] content) private Pathprivate PathcreateTempFile(Path tempDir, String prefix, String suffix) private PathcreateTempFile(Path tempDir, String prefix, String suffix, String content) createVerify(String hostKeyDocumentContent, String digiCertCACertificateContent, String ibmZHostKeySigningCertificateContent) Creates an attestation request, with certificate verification, given the certificate contentscreateVerifyDownloadCertificates(String hostKeyDocumentContent) Creates an attestation request, with certificate verification, downloading the certificates from IBM websiteDownloads the IBM host key signing certificateDownloads the IBM host key signing certificate revocation listsFinds the package versionGets the root CA certificate from the local resourcesprivate StringgetFirstLine(String str) (package private) Stringprivate voidprivate voidprivate voidverifyAttestationResponse(byte[] attestationResponseContent, byte[] secureExecutionHeaderContent, byte[] attestationProtectionKeyContent) Verifies the validity of an attestation responseverifyAttestationResponse(String attestationResponseContentBase64, String secureExecutionHeaderContentBase64, String attestationProtectionKeyContentBase64) Verifies the validity of an attestation responseversion()Returns the pvattest tool version
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER -
PVATTEST_PACKAGE
- See Also:
-
PVATTEST
-
DEFAULT_DIGI_CERT_CA_FILE
-
IBM_Z_HOST_KEY_SIGNING_CERTIFICATE
- See Also:
-
IBM_Z_HOST_KEY_CERTIFICATE_REVOCATION_LISTS
- See Also:
-
tempDirAttributes
-
tempFileAttributes
-
tempDirs
-
tempFiles
-
commandExecutor
private final com.suse.common.io.process.ShellCommandExecutor commandExecutor -
sourceDigiCertCaCertificateFile
-
-
Constructor Details
-
PvattestWrapper
public PvattestWrapper()default constructor -
PvattestWrapper
public PvattestWrapper(com.suse.common.io.process.ShellCommandExecutor commandExecutorIn) Constructor- Parameters:
commandExecutorIn- the command executor object
-
PvattestWrapper
public PvattestWrapper(com.suse.common.io.process.ShellCommandExecutor commandExecutorIn, Path sourceDigiCertCaCertificateFileIn) - Parameters:
commandExecutorIn- dummysourceDigiCertCaCertificateFileIn- dummy
-
-
Method Details
-
getLastExecutedCommand
String getLastExecutedCommand() -
findPackageVersion
Finds the package version- Returns:
- the package version as string
- Throws:
ExecutionException- if something goes wrong
-
version
Returns the pvattest tool version- Returns:
- the version as string
- Throws:
ExecutionException- if something goes wrong
-
createNoVerify
public AttestationRequest createNoVerify(String hostKeyDocumentContent) throws ExecutionException, CertificateException Creates an attestation request, with no certificate verification- Parameters:
hostKeyDocumentContent- the IBM host key document- Returns:
- the attestation request
- Throws:
ExecutionException- if something goes wrongCertificateException- if some certificate could not be parsed or is invalid
-
createVerifyDownloadCertificates
public AttestationRequest createVerifyDownloadCertificates(String hostKeyDocumentContent) throws ExecutionException, CertificateException, IOException Creates an attestation request, with certificate verification, downloading the certificates from IBM website- Parameters:
hostKeyDocumentContent- the IBM host key document- Returns:
- the attestation request
- Throws:
ExecutionException- if something goes wrongCertificateException- if some certificate could not be parsed or is invalidIOException- if something goes wrong
-
createVerify
public AttestationRequest createVerify(String hostKeyDocumentContent, String digiCertCACertificateContent, String ibmZHostKeySigningCertificateContent) throws ExecutionException, CertificateException Creates an attestation request, with certificate verification, given the certificate contents- Parameters:
hostKeyDocumentContent- the IBM host key documentdigiCertCACertificateContent- the root CA certificateibmZHostKeySigningCertificateContent- the IBM host key signing certificate- Returns:
- the attestation request
- Throws:
ExecutionException- if something goes wrongCertificateException- if some certificate could not be parsed or is invalid
-
createCore
private AttestationRequest createCore(X509Certificate hostKeyDocument, boolean doVerify, X509Certificate digiCertCACertificate, X509Certificate ibmZHostKeySigningCertificateX) throws ExecutionException - Throws:
ExecutionException
-
getDigiCertCACertificate
Gets the root CA certificate from the local resources- Returns:
- the root CA certificate
- Throws:
IOException- if something goes wrong
-
downloadIbmZHostKeySigningCertificate
Downloads the IBM host key signing certificate- Returns:
- the IBM host key signing certificate
- Throws:
IOException- if something goes wrong
-
downloadIbmZHostKeySigningRevocationLists
Downloads the IBM host key signing certificate revocation lists- Returns:
- the IBM host key signing certificate revocation lists
- Throws:
IOException- if something goes wrong
-
createAttestationRequest
private AttestationRequest createAttestationRequest(Path attestationRequestFile, Path attestationProtectionKeyFile) throws IOException - Throws:
IOException
-
createAttestationResult
- Throws:
IOException
-
checkCommandNotFailed
private void checkCommandNotFailed(com.suse.common.io.process.ProcessOutput output) -
logErrorRunningCommand
-
resetTempDirsFiles
private void resetTempDirsFiles() -
removeAllTempDirsFiles
private void removeAllTempDirsFiles() -
createTempDir
- Throws:
IOException
-
createTempFile
- Throws:
IOException
-
createTempFile
private Path createTempFile(Path tempDir, String prefix, String suffix, String content) throws IOException - Throws:
IOException
-
createTempBinaryFile
private Path createTempBinaryFile(Path tempDir, String prefix, String suffix, byte[] content) throws IOException - Throws:
IOException
-
getFirstLine
-
verifyAttestationResponse
public AttestationResponse verifyAttestationResponse(String attestationResponseContentBase64, String secureExecutionHeaderContentBase64, String attestationProtectionKeyContentBase64) throws ExecutionException Verifies the validity of an attestation response- Parameters:
attestationResponseContentBase64- the attestation response in base64secureExecutionHeaderContentBase64- the secure execution header in base64attestationProtectionKeyContentBase64- the attestation protection key in base64- Returns:
- the attestation response
- Throws:
ExecutionException- if something goes wrong
-
verifyAttestationResponse
public AttestationResponse verifyAttestationResponse(byte[] attestationResponseContent, byte[] secureExecutionHeaderContent, byte[] attestationProtectionKeyContent) throws ExecutionException Verifies the validity of an attestation response- Parameters:
attestationResponseContent- the attestation response as byte arraysecureExecutionHeaderContent- the secure execution header as byte arrayattestationProtectionKeyContent- the attestation protection key as byte array- Returns:
- the attestation response
- Throws:
ExecutionException- if something goes wrong
-