All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | List of all members
ndn::RsaPrivateKeyLite Class Reference

An RsaPrivateKeyLite holds a decoded or generated RSA private key for use in crypto operations. More...

#include <rsa-private-key-lite.hpp>

Inheritance diagram for ndn::RsaPrivateKeyLite:
ndn_RsaPrivateKey

Public Member Functions

 RsaPrivateKeyLite ()
 Create an RsaPrivateKeyLite with a null value.
 
 ~RsaPrivateKeyLite ()
 Finalize the RsaPrivateKeyLite, freeing memory if needed.
 
ndn_Error decode (const uint8_t *privateKeyDer, size_t privateKeyDerLength)
 Decode the DER-encoded PKCS #1 privateKeyDer and set this RsaPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error decode (const BlobLite &privateKeyDer)
 Decode the DER-encoded PKCS #1 privateKeyDer and set this RsaPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error generate (uint32_t keySize)
 Generate a key pair and set this RsaPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error encodePrivateKey (uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded PKCS #1 private key. More...
 
ndn_Error encodePublicKey (uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded SubjectPublicKeyInfo. More...
 
ndn_Error signWithSha256 (const uint8_t *data, size_t dataLength, uint8_t *signature, size_t &signatureLength) const
 Use this private key to sign the data using RsaWithSha256. More...
 
ndn_Error signWithSha256 (const BlobLite &data, uint8_t *signature, size_t &signatureLength) const
 Use this private key to sign the data using RsaWithSha256. More...
 
ndn_Error decrypt (const uint8_t *encryptedData, size_t encryptedDataLength, ndn_EncryptAlgorithmType algorithmType, uint8_t *plainData, size_t &plainDataLength)
 Use the private key to decrypt encryptedData according to the algorithmType. More...
 
ndn_Error decrypt (const BlobLite &encryptedData, ndn_EncryptAlgorithmType algorithmType, uint8_t *plainData, size_t &plainDataLength)
 Use the private key to decrypt encryptedData according to the algorithmType. More...
 

Static Public Member Functions

static RsaPrivateKeyLitedownCast (ndn_RsaPrivateKey &blob)
 Downcast the reference to the ndn_RsaPrivateKey struct to a RsaPrivateKeyLite. More...
 
static const RsaPrivateKeyLitedownCast (const ndn_RsaPrivateKey &blob)
 

Detailed Description

An RsaPrivateKeyLite holds a decoded or generated RSA private key for use in crypto operations.

Member Function Documentation

ndn_Error ndn::RsaPrivateKeyLite::decode ( const uint8_t *  privateKeyDer,
size_t  privateKeyDerLength 
)

Decode the DER-encoded PKCS #1 privateKeyDer and set this RsaPrivateKeyLite, allocating memory as needed.

Parameters
privateKeyDerA pointer to the DER-encoded private key.
privateKeyDerLengthThe length of privateKeyDer.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if privateKeyDer can't be decoded as an RSA private key.
ndn_Error ndn::RsaPrivateKeyLite::decode ( const BlobLite privateKeyDer)
inline

Decode the DER-encoded PKCS #1 privateKeyDer and set this RsaPrivateKeyLite, allocating memory as needed.

Parameters
privateKeyDerThe DER-encoded private key.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if privateKeyDer can't be decoded as an RSA private key.
ndn_Error ndn::RsaPrivateKeyLite::decrypt ( const uint8_t *  encryptedData,
size_t  encryptedDataLength,
ndn_EncryptAlgorithmType  algorithmType,
uint8_t *  plainData,
size_t &  plainDataLength 
)

Use the private key to decrypt encryptedData according to the algorithmType.

Parameters
encryptedDataA pointer to the input byte array to decrypt.
encryptedDataLengthThe length of encryptedData.
algorithmTypeThis decrypts according to algorithmType.
plainDataA pointer to the decrypted output buffer. The caller must provide a buffer large enough to receive the bytes.
plainDataLengthSet plainDataLength to the number of bytes placed in the plainData buffer.
Returns
0 for success, else NDN_ERROR_Unsupported_algorithm_type for unsupported algorithmType padding scheme, or NDN_ERROR_Error_in_decrypt_operation if can't complete the decrypt operation.
ndn_Error ndn::RsaPrivateKeyLite::decrypt ( const BlobLite encryptedData,
ndn_EncryptAlgorithmType  algorithmType,
uint8_t *  plainData,
size_t &  plainDataLength 
)
inline

Use the private key to decrypt encryptedData according to the algorithmType.

Parameters
encryptedDataThe input byte array to decrypt.
algorithmTypeThis decrypts according to algorithmType.
plainDataA pointer to the decrypted output buffer. The caller must provide a buffer large enough to receive the bytes.
plainDataLengthSet plainDataLength to the number of bytes placed in the plainData buffer.
Returns
0 for success, else NDN_ERROR_Unsupported_algorithm_type for unsupported algorithmType padding scheme, or NDN_ERROR_Error_in_decrypt_operation if can't complete the decrypt operation.
static RsaPrivateKeyLite& ndn::RsaPrivateKeyLite::downCast ( ndn_RsaPrivateKey blob)
inlinestatic

Downcast the reference to the ndn_RsaPrivateKey struct to a RsaPrivateKeyLite.

Parameters
blobA reference to the ndn_RsaPrivateKey struct.
Returns
The same reference as RsaPrivateKeyLite.
ndn_Error ndn::RsaPrivateKeyLite::encodePrivateKey ( uint8_t *  encoding,
size_t &  encodingLength 
) const

Encode the DER-encoded PKCS #1 private key.

Parameters
encodingA pointer to the encoding output buffer. If this is null then only set encodingLength (which can be used to allocate a buffer of the correct size). Otherwise, the caller must provide a buffer large enough to receive the encoding bytes.
encodingLengthSet encodingLength to the number of bytes in the encoding.
Returns
0 for success, else NDN_ERROR_Error_encoding_key if can't encode the key.
ndn_Error ndn::RsaPrivateKeyLite::encodePublicKey ( uint8_t *  encoding,
size_t &  encodingLength 
) const

Encode the DER-encoded SubjectPublicKeyInfo.

Parameters
encodingA pointer to the encoding output buffer. If this is null then only set encodingLength (which can be used to allocate a buffer of the correct size). Otherwise, the caller must provide a buffer large enough to receive the encoding bytes.
encodingLengthSet encodingLength to the number of bytes in the encoding.
Returns
0 for success, else NDN_ERROR_Error_encoding_key if can't encode the key.
ndn_Error ndn::RsaPrivateKeyLite::generate ( uint32_t  keySize)

Generate a key pair and set this RsaPrivateKeyLite, allocating memory as needed.

Parameters
keySizeThe size in bits of the key to generate.
Returns
0 for success, else NDN_ERROR_Error_in_generate_operation if can't complete the generate operation.
ndn_Error ndn::RsaPrivateKeyLite::signWithSha256 ( const uint8_t *  data,
size_t  dataLength,
uint8_t *  signature,
size_t &  signatureLength 
) const

Use this private key to sign the data using RsaWithSha256.

Parameters
dataA pointer to the input byte array to sign.
dataLengthThe length of data.
signatureA pointer to the signature output buffer. The caller must provide a buffer large enough to receive the signature bytes.
signatureLengthSet signatureLength to the number of bytes placed in the signature buffer.
Returns
0 for success, else NDN_ERROR_Error_in_sign_operation if can't complete the sign operation.
ndn_Error ndn::RsaPrivateKeyLite::signWithSha256 ( const BlobLite data,
uint8_t *  signature,
size_t &  signatureLength 
) const
inline

Use this private key to sign the data using RsaWithSha256.

Parameters
dataThe input byte array to sign.
signatureA pointer to the signature output buffer. The caller must provide a buffer large enough to receive the signature bytes.
signatureLengthSet signatureLength to the number of bytes placed in the signature buffer.
Returns
0 for success, else NDN_ERROR_Error_in_sign_operation if can't complete the sign operation.

The documentation for this class was generated from the following file: