23 #ifndef NDN_TPM_PRIVATE_KEY_HPP
24 #define NDN_TPM_PRIVATE_KEY_HPP
26 #include "../../lite/security/ec-private-key-lite.hpp"
27 #include "../../lite/security/rsa-private-key-lite.hpp"
28 #include "../../util/blob.hpp"
29 #include "../key-params.hpp"
30 #include "../security-common.hpp"
31 #include "../../encoding/oid.hpp"
32 #include "../../c/encrypt/algo/encrypt-params-types.h"
49 class Error :
public std::runtime_error
52 Error(
const std::string& what)
53 : std::runtime_error(what)
77 (
const uint8_t* encoding,
size_t encodingLength,
88 loadPkcs8(
const uint8_t* encoding,
size_t encodingLength);
112 (
const uint8_t* cipherText,
size_t cipherTextLength,
113 ndn_EncryptAlgorithmType algorithmType = ndn_EncryptAlgorithmType_RsaOaep);
126 sign(
const uint8_t *data,
size_t dataLength, DigestAlgorithm digestAlgorithm);
137 toPkcs1(
bool includeParameters =
true);
148 toPkcs8(
bool includeParameters =
true);
158 static ptr_lib::shared_ptr<TpmPrivateKey>
171 encodePkcs8PrivateKey
172 (
const std::vector<uint8_t>& privateKeyDer,
const OID& oid,
173 const ptr_lib::shared_ptr<DerNode>& parameters);
184 encodeSubjectPublicKeyInfo
185 (
const OID& oid,
const ptr_lib::shared_ptr<DerNode>& parameters,
186 const ptr_lib::shared_ptr<DerNode>& bitString);
200 (
const ptr_lib::shared_ptr<DerNode>& algorithmParameters,
218 ptr_lib::shared_ptr<EcPrivateKeyLite> ecPrivateKey_;
219 ptr_lib::shared_ptr<RsaPrivateKeyLite> rsaPrivateKey_;
A TpmPrivateKey holds an in-memory private key and provides cryptographic operations such as for sign...
Definition: tpm-private-key.hpp:43
void loadPkcs8(const uint8_t *encoding, size_t encodingLength)
Load the unencrypted private key from a buffer with the PKCS #8 encoding.
Definition: tpm-private-key.cpp:96
TpmPrivateKey()
Create an uninitialized TpmPrivateKey.
Definition: tpm-private-key.hpp:62
KeyType
Definition: security-common.hpp:50
Blob derivePublicKey() const
Get the encoded public key for this private key.
Definition: tpm-private-key.cpp:152
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
An EcPrivateKeyLite holds a decoded or generated EC private key for use in crypto operations...
Definition: ec-private-key-lite.hpp:35
Blob sign(const uint8_t *data, size_t dataLength, DigestAlgorithm digestAlgorithm)
Sign the data with this private key, returning a signature Blob.
Definition: tpm-private-key.cpp:231
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.
Definition: tpm-private-key.cpp:39
A TpmPrivateKey::Error extends runtime_error and represents an error in private key processing...
Definition: tpm-private-key.hpp:49
KeyParams is a base class for key parameters.
Definition: key-params.hpp:36
Blob toPkcs1(bool includeParameters=true)
Get the encoded unencrypted private key in PKCS #1.
Definition: tpm-private-key.cpp:262
static ptr_lib::shared_ptr< TpmPrivateKey > generatePrivateKey(const KeyParams &keyParams)
Generate a key pair according to keyParams and return a new TpmPrivateKey with the private key...
Definition: tpm-private-key.cpp:318
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.
Definition: tpm-private-key.cpp:201
Blob toPkcs8(bool includeParameters=true)
Get the encoded unencrypted private key in PKCS #8.
Definition: tpm-private-key.cpp:298