A TpmPrivateKey holds an in-memory private key and provides cryptographic operations such as for signing by the in-memory TPM.
More...
#include <tpm-private-key.hpp>
|
| | TpmPrivateKey () |
| | Create an uninitialized TpmPrivateKey. More...
|
| |
| void | loadPkcs1 (const uint8_t *encoding, size_t encodingLength, KeyType keyType=(KeyType)-1) |
| | Load the unencrypted private key from a buffer with the PKCS #1 encoding. More...
|
| |
| void | loadPkcs8 (const uint8_t *encoding, size_t encodingLength) |
| | Load the unencrypted private key from a buffer with the PKCS #8 encoding. More...
|
| |
| Blob | derivePublicKey () const |
| | Get the encoded public key for this private key. More...
|
| |
| Blob | decrypt (const uint8_t *cipherText, size_t cipherTextLength, ndn_EncryptAlgorithmType algorithmType=ndn_EncryptAlgorithmType_RsaOaep) |
| | Decrypt the cipherText using this private key according the encryption algorithmType. More...
|
| |
| Blob | sign (const uint8_t *data, size_t dataLength, DigestAlgorithm digestAlgorithm) |
| | Sign the data with this private key, returning a signature Blob. More...
|
| |
| Blob | toPkcs1 (bool includeParameters=true) |
| | Get the encoded unencrypted private key in PKCS #1. More...
|
| |
| Blob | toPkcs8 (bool includeParameters=true) |
| | Get the encoded unencrypted private key in PKCS #8. More...
|
| |
A TpmPrivateKey holds an in-memory private key and provides cryptographic operations such as for signing by the in-memory TPM.
| ndn::TpmPrivateKey::TpmPrivateKey |
( |
| ) |
|
|
inline |
Create an uninitialized TpmPrivateKey.
You must call a load method to initialize it, such as loadPkcs1.
| Blob ndn::TpmPrivateKey::decrypt |
( |
const uint8_t * |
cipherText, |
|
|
size_t |
cipherTextLength, |
|
|
ndn_EncryptAlgorithmType |
algorithmType = ndn_EncryptAlgorithmType_RsaOaep |
|
) |
| |
Decrypt the cipherText using this private key according the encryption algorithmType.
Only RSA encryption is supported for now.
- Parameters
-
| cipherText | The cipher text byte array. |
| cipherTextLength | The length of the cipher text byte array. |
| algorithmType | (optional) This decrypts according to algorithmType. If omitted, use RsaOaep. |
- Returns
- The decrypted data.
- Exceptions
-
| TpmPrivateKey::Error | if the private key is not loaded, if decryption is not supported for this key type, or for error decrypting. |
| Blob ndn::TpmPrivateKey::derivePublicKey |
( |
| ) |
const |
Get the encoded public key for this private key.
- Returns
- The public key encoding Blob.
- Exceptions
-
Generate a key pair according to keyParams and return a new TpmPrivateKey with the private key.
You can get the public key with derivePublicKey.
- Parameters
-
| keyParams | The parameters of the key. |
- Returns
- A new TpmPrivateKey.
- Exceptions
-
| std::invalid_argument | if the key type is not supported. |
| TpmPrivateKey::Error | for an invalid key size, or an error generating. |
| void ndn::TpmPrivateKey::loadPkcs1 |
( |
const uint8_t * |
encoding, |
|
|
size_t |
encodingLength, |
|
|
KeyType |
keyType = (KeyType)-1 |
|
) |
| |
Load the unencrypted private key from a buffer with the PKCS #1 encoding.
This replaces any existing private key in this object.
- Parameters
-
| encoding | The byte array with the private key encoding. |
| encodingLength | The length of the encoding. |
| keyType | (potional) The KeyType, such as KEY_TYPE_RSA. If omitted, then partially decode the private key to determine the key type. |
- Exceptions
-
| void ndn::TpmPrivateKey::loadPkcs8 |
( |
const uint8_t * |
encoding, |
|
|
size_t |
encodingLength |
|
) |
| |
Load the unencrypted private key from a buffer with the PKCS #8 encoding.
This replaces any existing private key in this object.
- Parameters
-
| encoding | The byte array with the private key encoding. |
| encodingLength | The length of the encoding. |
- Exceptions
-
| Blob ndn::TpmPrivateKey::sign |
( |
const uint8_t * |
data, |
|
|
size_t |
dataLength, |
|
|
DigestAlgorithm |
digestAlgorithm |
|
) |
| |
Sign the data with this private key, returning a signature Blob.
- Parameters
-
| data | The input byte array. |
| dataLength | The length of the byte array. |
| digestAlgorithm | the digest algorithm. |
- Returns
- The signature Blob, or an isNull Blob if this private key is not initialized.
- Exceptions
-
| Blob ndn::TpmPrivateKey::toPkcs1 |
( |
bool |
includeParameters = true | ) |
|
Get the encoded unencrypted private key in PKCS #1.
- Parameters
-
| includeParameters | (optional) If true and this is an EC key, then include the EC parameters in the encoding. If omitted, use true. Using false is deprecated. |
- Returns
- The private key encoding Blob.
- Exceptions
-
| Blob ndn::TpmPrivateKey::toPkcs8 |
( |
bool |
includeParameters = true | ) |
|
Get the encoded unencrypted private key in PKCS #8.
- Parameters
-
| includeParameters | (optional) If true and this is an EC key, then include the EC parameters in the encoding. If omitted, use true. Using false is deprecated. |
- Returns
- The private key encoding Blob.
- Exceptions
-
The documentation for this class was generated from the following files: