public class TpmPrivateKey extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
TpmPrivateKey.Error
A TpmPrivateKey.Error extends Exception and represents an error in private
key processing.
|
| Constructor and Description |
|---|
TpmPrivateKey()
Create an uninitialized TpmPrivateKey.
|
| Modifier and Type | Method and Description |
|---|---|
Blob |
decrypt(ByteBuffer cipherText)
Call the main decrypt where algorithmType is RsaOaep.
|
Blob |
decrypt(ByteBuffer cipherText,
EncryptAlgorithmType algorithmType)
Decrypt the cipherText using this private key according the encryption
algorithmType.
|
Blob |
derivePublicKey()
Get the encoded public key for this private key.
|
static TpmPrivateKey |
generatePrivateKey(KeyParams keyParams)
Generate a key pair according to keyParams and return a new TpmPrivateKey
with the private key.
|
void |
loadEncryptedPkcs8(ByteBuffer encoding,
ByteBuffer password)
Load the encrypted private key from a buffer with the PKCS #8 encoding of
the EncryptedPrivateKeyInfo.
|
void |
loadPkcs1(ByteBuffer encoding)
Load the unencrypted private key from a buffer with the PKCS #1 encoding.
|
void |
loadPkcs1(ByteBuffer encoding,
KeyType keyType)
Load the unencrypted private key from a buffer with the PKCS #1 encoding.
|
void |
loadPkcs8(ByteBuffer encoding)
Load the unencrypted private key from a buffer with the PKCS #8 encoding.
|
void |
loadPkcs8(ByteBuffer encoding,
KeyType keyType)
Load the unencrypted private key from a buffer with the PKCS #8 encoding.
|
Blob |
sign(ByteBuffer data,
DigestAlgorithm digestAlgorithm)
Sign the data with this private key, returning a signature Blob.
|
Blob |
toEncryptedPkcs8(ByteBuffer password)
Get the encoded encrypted private key in PKCS #8.
|
Blob |
toPkcs1()
Get the encoded unencrypted private key in PKCS #1.
|
Blob |
toPkcs8()
Get the encoded unencrypted private key in PKCS #8.
|
public TpmPrivateKey()
public final void loadPkcs1(ByteBuffer encoding, KeyType keyType) throws TpmPrivateKey.Error
encoding - The byte buffer with the private key encoding.keyType - The KeyType, such as KeyType.RSA. If null, then partially
decode the private key to determine the key type.TpmPrivateKey.Error - for errors decoding the key.public final void loadPkcs1(ByteBuffer encoding) throws TpmPrivateKey.Error
encoding - The byte buffer with the private key encoding.TpmPrivateKey.Error - for errors decoding the key.public final void loadPkcs8(ByteBuffer encoding, KeyType keyType) throws TpmPrivateKey.Error
encoding - The byte buffer with the private key encoding.keyType - The KeyType, such as KeyType.RSA. If null, then partially
decode the private key to determine the key type.TpmPrivateKey.Error - for errors decoding the key.public final void loadPkcs8(ByteBuffer encoding) throws TpmPrivateKey.Error
encoding - The byte buffer with the private key encoding.TpmPrivateKey.Error - for errors decoding the key.public final void loadEncryptedPkcs8(ByteBuffer encoding, ByteBuffer password) throws TpmPrivateKey.Error
encoding - The byte buffer with the private key encoding.password - The password for decrypting the private key, which should
have characters in the range of 1 to 127.TpmPrivateKey.Error - for errors decoding or decrypting the key.public final Blob derivePublicKey() throws TpmPrivateKey.Error
TpmPrivateKey.Error - if no private key is loaded, or error
converting to a public key.public final Blob decrypt(ByteBuffer cipherText, EncryptAlgorithmType algorithmType) throws TpmPrivateKey.Error
cipherText - The cipher text byte buffer.algorithmType - This decrypts according to algorithmType.TpmPrivateKey.Error - if the private key is not loaded, if
decryption is not supported for this key type, or for error decrypting.public final Blob decrypt(ByteBuffer cipherText) throws TpmPrivateKey.Error
TpmPrivateKey.Errorpublic final Blob sign(ByteBuffer data, DigestAlgorithm digestAlgorithm) throws TpmPrivateKey.Error
data - The input byte buffer.digestAlgorithm - the digest algorithm.TpmPrivateKey.Error - for unrecognized digestAlgorithm or an error
in signing.public final Blob toPkcs1() throws TpmPrivateKey.Error
TpmPrivateKey.Error - if no private key is loaded, or error encoding.public final Blob toPkcs8() throws TpmPrivateKey.Error
TpmPrivateKey.Error - if no private key is loaded, or error encoding.public final Blob toEncryptedPkcs8(ByteBuffer password) throws TpmPrivateKey.Error
password - The password for encrypting the private key, which should
have characters in the range of 1 to 127.TpmPrivateKey.Error - if no private key is loaded, or error encoding.public static TpmPrivateKey generatePrivateKey(KeyParams keyParams) throws IllegalArgumentException, TpmPrivateKey.Error
keyParams - The parameters of the key.IllegalArgumentException - if the key type is not supported.TpmPrivateKey.Error - for an invalid key size, or an error generating.Copyright © 2019. All rights reserved.