Skip to main content

Generate and Wrap Target Key

The target key to transfer needs to be created on your Primus HSM or Securosys CloudHSM with the flags ACCESS_EXTRACTABLE (and ACCESS_SENSITIVE) set.

Target key creation can be done via:

  • JCE (primus-tools, own application, …),
  • PKCS#11 (e.g. OpenSC pkcs11-tool, OpenSSL, own application, …),
  • MS CNG provider (MS certmgr/certutil tools).

Example target key creation using the Primus Tools is shown below. Visit Primus Tools User Guide for more information on the tools set.

note

Make sure to replace the parameters in the example commands to your own.

Create Target Key

Create a key with Primus Tools command CreateKey. To allow wrapped key export, key flags ACCESS_EXTRACTABLE and ACCESS_SENSITIVE must be set. Appropriate HSM Security Policy is required (see Primus HSM Configuration for more details):

java -jar primus-tools.jar CreateKey <HSM connection and credentials> -keyname myPrimusByoK -type RSA -size 4096 -flags sensitive,extractable

Consult Primus Tools User Guide regarding <HSM connection and credentials> parameter.

Verify Target Key Flags

Verify the key flags with the Primus Tools command ListKeyFlags:

java -jar primus-tools.jar ListKeyFlags <HSM connection and credentials> -keyname myPrimusByoK

Example output:

myPrimusByoK sensitive extractable modifiable copyable token nonindestructible private nonpublic nonneverextractable alwayssensitive local nonwrapwithtrusted nonunique decrypt sign unwrap notderive notintegrity notsignrecover

Wrap Target Key

Transfer the KEK public key (KEKforBYOK.publickey.pem) file to your HSM Client (offline) computer where you installed the Primus Tools (e.g. C:\Users\Public\byok).

Create the .byok file using the Primus Tools (connectivity to your HSM is required, see Primus Tools User Guide regarding <HSM connection and credentials> parameter).

Example:

java -jar primus-tools.jar AzureByokExport <HSM connection and credentials> -kekidentifier https://myKeyVaultHSM.vault.azure.net/keys/KEKforBYOK/d0dfd74d5bfc494abc572867b20e4260 -kekfile KEKforBYOK.publickey.pem -outfile myPrimusRSA4k.byok -rsakey myPrimusByoK

The output should look similar to the following SecurosysPrimusByokR4k.byok example:

{
"schema_version": "1.0.0",
"header":
{
"kid": "https://securosysprimuskeyvault.vault.azure.net/keys/KekForByokR4k/083cf1b67d314d15b1fa46915cde3217",
"alg": "d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rmteIFSeYd92UuOPHAdHE8FASG2PD4Nm99_ZXMVxITiHwMPxrTYw7AVCbMe5-RmhJm4DsHtwouxnrfHqY9fIV9GKyWUyVGH60lp4G-nnK7aLiY6cMBOF7qp9rYEjvXbvfoM1rTvgeVg-iLwWTAjk5K1X3fmVauN0rvpAt4ViSyUiyvw67uTGYt9BfIgYrDUXkUZwz_-SVaZlqH2VvLMRT4QJJ3bdyItFPNciwIX84sEcbo4VVB5JnhYZzcdEPDla7PQJI_RcqYyPtHXb0Gvg_JupSh9_anexNOS8sP4noXKbrklaXuoVi_rlymq5ZDzt9GOWh_TLynltDCHahe53e6egp7_Si237R-RiNaquEppLFGfVKQCyAyjN1GPZ8eInnf5GLm7GDtiG4xHQM-5gpkodpG2JIlLdAkAgQDQ2Dx-Ywpx_eFtkZd0Lv1sXxcO5zjvYfmDbNzn8qtEbuRxbcaTo1o1eAbv5_pWXfjV-ak1kt6JPOa3fnsduvcwnMPUfY_30lp5OgEKHKhiLYNDdj-6ga3IR66qosQ1LO1wjvwTPQ7ui5MEFTSHGKMENjPiPYSxt1fxW6WeaqkalnPAvm5LMSmUJ2T5-tNkzUt1Fn2ZMu--PyA8R2puYLNcxplH0LZDQr7NrX4MGIYJTg==",
"generator": "Primus Java BYOK-Tool v1.2; GRIMSEL RX-2.9.0-T"
}

Proceed to import the .byok package into the Azure key vault.