The library has been developed to automate the process for provisioning Hyper Protect Virtual Servers for VPC and Hyper Protect Container Runtime.
OPENSSL_BIN (optional)You can configure the path to the openssl binary using the OPENSSL_BIN environment variable.
This is useful especially on systems where openssl is not available in the system PATH (e.g., on Windows).
Set the OPENSSL_BIN environment variable to the full path of your openssl executable.
export OPENSSL_BIN=/usr/bin/openssl
On Windows (PowerShell):
$env:OPENSSL_BIN="C:\Program Files\OpenSSL-Win64\bin\openssl.exe"
This function decrypts encrypted attestation records.
import "github.com/ibm-hyper-protect/contract-go/attestation"
func main() {
    decryptedAttestationRecords, err := HpcrGetAttestationRecords(encryptedChecksum, privateKey)
}
This function downloads HPCR encryption certificates from IBM Cloud.
import "github.com/ibm-hyper-protect/contract-go/certificate"
func main() {
    certs, err := HpcrDownloadEncryptionCertificates(sampleEncryptionCertVersionsList, jsonFormat, certDownloadUrlTemplate)
}
https://hpvsvpcubuntu.s3.us.cloud-object-storage.appdomain.cloud/s390x-/ibm-hyper-protect-container-runtime---s390x--encrypt.crt)This function returns encryption certificate and version from HpcrDownloadEncryptionCertificates() output.
import "github.com/ibm-hyper-protect/contract-go/certificate"
func main() {
    version, cert, err := HpcrGetEncryptionCertificateFromJson(sampleJsonData, desiredVersion)
}
This function selects the latest HPCR image details from image list out from IBM Cloud images API.
import "github.com/ibm-hyper-protect/contract-go/image"
func main() {
    imageId, imageName, imageChecksum, ImageVersion, err := HpcrSelectImage(imageJsonList, version)
}
ibmcloud is images: The input should be output of data.ibm_is_images.hyper_protect_images.images. curl -X GET "https://<region>.cloud.ibm.com/v1/images?version=2022-09-13&generation=2"  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" | jq .images
ibmcloud is images --json.This function generates Base64 for given string.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    base64, inputSha256, outputSha256, err := HpcrText(sampleStringData)
}
This function encrypts text and formats text as per hyper-protect-basic.<encoded-encrypted-password>.<encoded-encrypted-data>.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    encryptedText, inputSha256, outputSha256, err := HpcrTextEncrypted(sampleStringData, HyperProtectOsType, encryptionCertificate)
}
This function generates Base64 of JSON input
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    base64, inputSha256, outputSha256, err := HpcrJson(sampleStringJson)
}
This function generates encrypts JSON and formats text as per hyper-protect-basic.<encoded-encrypted-password>.<encoded-encrypted-data>.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    encryptedJson, inputSha256, outputSha256, err := HpcrJsonEncrypted(sampleStringJson, HyperProtectOsType, encryptionCertificate)
}
This function generates base64 of TGZ that contains files under the given folder
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    encodedTgz, inputSha256, outputSha256, err := HpcrTgz(composePath)
}
This function verifies if the parsed encrypted contract is schematically valid. The validation is successful, if error is nil.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    err := HpcrVerifyContract(contract, HyperProtectOsType)
}
This function first generates base64 of TGZ that contains files under the given folder and then encrypts the data as per hyper-protect-basic.<encoded-encrypted-password>.<encoded-encrypted-data>.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    encodedTgz, inputSha256, outputSha256, err := HpcrTgzEncrypted(composePath, HyperProtectOsType, encryptionCertificate)
}
This function generates a signed and encrypted contract with format hyper-protect-basic.<encoded-encrypted-password>.<encoded-encrypted-data>.
import "github.com/ibm-hyper-protect/contract-go/contract"
func main() {
    signedEncryptedContract, inputSha256, outputSha256, err := HpcrContractSignedEncrypted(contract, HyperProtectOsType, encryptionCertificate, privateKey)
}
This function generates a signed and encrypted contract with contract expiry enabled. The output will be of the format hyper-protect-basic.<encoded-encrypted-password>.<encoded-encrypted-data>.
import "github.com/ibm-hyper-protect/contract-go/contract"
func usingCsrParams() {
    sampleCeCSRPems = map[string]interface{}{
		"country":  "IN",
		"state":    "Karnataka",
		"location": "Bangalore",
		"org":      "IBM",
		"unit":     "ISDL",
		"domain":   "HPVS",
		"mail":     "sashwat.k@ibm.com",
	}
    signedEncryptedCEContract, inputSha256, outputSha256, err := HpcrContractSignedEncryptedContractExpiry(contract, HyperProtectOsType, encryptionCertificate, privateKey, caCert, caKey, string(csrParams), "", sampleContractExpiryDays)
}
func usingCsrPem() {
    signedEncryptedCEContract, inputSha256, outputSha256, err := HpcrContractSignedEncryptedContractExpiry(contract, encryptionCertificate, privateKey, caCert, caKey, "", csr, sampleContractExpiryDays)
}
The point 7 and 8 is one of. That is, either CSR parameters or CSR PEM file.
The CSR parameters should be of the format:-
"country":  "IN",
"state":    "Karnataka",
"location": "Bangalore",
"org":      "IBM",
"unit":     "ISDL",
"domain":   "HPVS",
"mail":     "sashwat.k@ibm.com"
This function verifies if network-config for ON PREM is schematically valid. The validation is successful, if error is nil.
import "github.com/ibm-hyper-protect/contract-go/network_schema"
func main() {
    err := HpcrVerifyNetworkConfig(network_config_file)
}