/// <summary> /// Import an encoded private key with name keyName in PKCS #8 format, possibly /// password-encrypted. /// </summary> /// /// <param name="keyName">The name of the key to use in the TPM.</param> /// <param name="pkcs8">unencrypted PKCS #8 PrivateKeyInfo.</param> /// <param name="password">it to decrypt the PKCS #8 EncryptedPrivateKeyInfo. If the password is null, import an unencrypted PKCS #8 PrivateKeyInfo.</param> /// <exception cref="TpmBackEnd.Error">for an error importing the key.</exception> protected internal override void doImportKey(Name keyName, ByteBuffer pkcs8, ByteBuffer password) { try { TpmPrivateKey key = new TpmPrivateKey(); if (password != null) { key.loadEncryptedPkcs8(pkcs8, password); } else { key.loadPkcs8(pkcs8); } // Copy the Name. ILOG.J2CsMapping.Collections.Collections.Put(keys_, new Name(keyName), key); } catch (TpmPrivateKey.Error ex) { throw new TpmBackEnd.Error("Cannot import private key: " + ex); } }
/// <summary> /// Import an encoded private key with name keyName in PKCS #8 format, possibly /// password-encrypted. /// </summary> /// /// <param name="keyName">The name of the key to use in the TPM.</param> /// <param name="pkcs8">unencrypted PKCS #8 PrivateKeyInfo.</param> /// <param name="password">it to decrypt the PKCS #8 EncryptedPrivateKeyInfo. If the password is null, import an unencrypted PKCS #8 PrivateKeyInfo.</param> /// <exception cref="TpmBackEnd.Error">for an error importing the key.</exception> protected internal override void doImportKey(Name keyName, ByteBuffer pkcs8, ByteBuffer password) { TpmPrivateKey key = new TpmPrivateKey(); try { if (password != null) { key.loadEncryptedPkcs8(pkcs8, password); } else { key.loadPkcs8(pkcs8); } } catch (TpmPrivateKey.Error ex) { throw new TpmBackEnd.Error("Cannot import private key: " + ex); } saveKey(keyName, key); }