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

An RsaPublicKeyLite holds a decoded RSA public key for use in crypto operations. More...

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

Inheritance diagram for ndn::RsaPublicKeyLite:
ndn_RsaPublicKey

Public Member Functions

 RsaPublicKeyLite ()
 Create an RsaPublicKeyLite with a null value.
 
 ~RsaPublicKeyLite ()
 Finalize the RsaPublicKeyLite, freeing memory if needed.
 
ndn_Error decode (const uint8_t *publicKeyDer, size_t publicKeyDerLength)
 Decode the publicKeyDer and set this RsaPublicKeyLite, allocating memory as needed. More...
 
ndn_Error decode (const BlobLite &publicKeyDer)
 Decode the publicKeyDer and set this RsaPublicKeyLite, allocating memory as needed. More...
 
ndn_Error encode (uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded SubjectPublicKeyInfo. More...
 
bool verifyWithSha256 (const uint8_t *signature, size_t signatureLength, const uint8_t *data, size_t dataLength) const
 Use this public key to verify the data using RsaWithSha256. More...
 
bool verifyWithSha256 (const BlobLite &signature, const BlobLite &data) const
 Use this public key to verify the data using RsaWithSha256. More...
 
ndn_Error encrypt (const uint8_t *plainData, size_t plainDataLength, ndn_EncryptAlgorithmType algorithmType, uint8_t *encryptedData, size_t &encryptedDataLength) const
 Use this public key to encrypt plainData according to the algorithmType. More...
 
ndn_Error encrypt (const BlobLite &plainData, ndn_EncryptAlgorithmType algorithmType, uint8_t *encryptedData, size_t &encryptedDataLength) const
 Use this public key to encrypt plainData according to the algorithmType. More...
 

Static Public Member Functions

static ndn_Error verifySha256WithRsaSignature (const uint8_t *signature, size_t signatureLength, const uint8_t *data, size_t dataLength, const uint8_t *publicKeyDer, size_t publicKeyDerLength, bool &verified)
 Verify the RSA signature of the data using the given public key. More...
 
static ndn_Error verifySha256WithRsaSignature (const BlobLite &signature, const BlobLite &data, const BlobLite &publicKeyDer, bool &verified)
 Verify the RSA signature of the data using the given public key. More...
 
static RsaPublicKeyLitedownCast (ndn_RsaPublicKey &blob)
 Downcast the reference to the ndn_RsaPublicKey struct to a RsaPublicKeyLite. More...
 
static const RsaPublicKeyLitedownCast (const ndn_RsaPublicKey &blob)
 

Detailed Description

An RsaPublicKeyLite holds a decoded RSA public key for use in crypto operations.

Member Function Documentation

ndn_Error ndn::RsaPublicKeyLite::decode ( const uint8_t *  publicKeyDer,
size_t  publicKeyDerLength 
)

Decode the publicKeyDer and set this RsaPublicKeyLite, allocating memory as needed.

Parameters
publicKeyDerA pointer to the DER-encoded public key.
publicKeyDerLengthThe length of publicKeyDer.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if publicKeyDer can't be decoded as an RSA public key.
ndn_Error ndn::RsaPublicKeyLite::decode ( const BlobLite publicKeyDer)
inline

Decode the publicKeyDer and set this RsaPublicKeyLite, allocating memory as needed.

Parameters
publicKeyDerThe DER-encoded public key.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if publicKeyDer can't be decoded as an RSA public key.
static RsaPublicKeyLite& ndn::RsaPublicKeyLite::downCast ( ndn_RsaPublicKey blob)
inlinestatic

Downcast the reference to the ndn_RsaPublicKey struct to a RsaPublicKeyLite.

Parameters
blobA reference to the ndn_RsaPublicKey struct.
Returns
The same reference as RsaPublicKeyLite.
ndn_Error ndn::RsaPublicKeyLite::encode ( 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::RsaPublicKeyLite::encrypt ( const uint8_t *  plainData,
size_t  plainDataLength,
ndn_EncryptAlgorithmType  algorithmType,
uint8_t *  encryptedData,
size_t &  encryptedDataLength 
) const

Use this public key to encrypt plainData according to the algorithmType.

Parameters
plainDataA pointer to the input byte array to encrypt.
plainDataLengthThe length of plainData.
algorithmTypeThis encrypts according to algorithmType.
encryptedDataA pointer to the encrypted output buffer. The caller must provide a buffer large enough to receive the bytes.
encryptedDataLengthSet encryptedDataLength to the number of bytes placed in the encryptedData buffer.
Returns
0 for success, else NDN_ERROR_Unsupported_algorithm_type for unsupported algorithmType padding scheme, or NDN_ERROR_Error_in_encrypt_operation if can't complete the encrypt operation.
ndn_Error ndn::RsaPublicKeyLite::encrypt ( const BlobLite plainData,
ndn_EncryptAlgorithmType  algorithmType,
uint8_t *  encryptedData,
size_t &  encryptedDataLength 
) const
inline

Use this public key to encrypt plainData according to the algorithmType.

Parameters
plainDataThe input byte array to encrypt.
algorithmTypeThis encrypts according to algorithmType.
encryptedDataA pointer to the encrypted output buffer. The caller must provide a buffer large enough to receive the bytes.
encryptedDataLengthSet encryptedDataLength to the number of bytes placed in the encryptedData buffer.
Returns
0 for success, else NDN_ERROR_Unsupported_algorithm_type for unsupported algorithmType padding scheme, or NDN_ERROR_Error_in_encrypt_operation if can't complete the encrypt operation.
static ndn_Error ndn::RsaPublicKeyLite::verifySha256WithRsaSignature ( const uint8_t *  signature,
size_t  signatureLength,
const uint8_t *  data,
size_t  dataLength,
const uint8_t *  publicKeyDer,
size_t  publicKeyDerLength,
bool &  verified 
)
static

Verify the RSA signature of the data using the given public key.

Parameters
signatureA pointer to the signature bytes.
signatureLengthThe length of signature.
dataA pointer to the input byte array to verify.
dataLengthThe length of data.
publicKeyDerA pointer to the DER-encoded public key used to verify the signature.
publicKeyDerLengthThe length of publicKeyDer.
verifiedSet verified to true if the signature verifies, false if not.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if publicKeyDer can't be decoded as an RSA public key.
static ndn_Error ndn::RsaPublicKeyLite::verifySha256WithRsaSignature ( const BlobLite signature,
const BlobLite data,
const BlobLite publicKeyDer,
bool &  verified 
)
inlinestatic

Verify the RSA signature of the data using the given public key.

Parameters
signatureThe signature bytes.
dataThe input byte array to verify.
publicKeyDerThe DER-encoded public key used to verify the signature.
verifiedSet verified to true if the signature verifies, false if not.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if publicKeyDer can't be decoded as an RSA public key.
bool ndn::RsaPublicKeyLite::verifyWithSha256 ( const uint8_t *  signature,
size_t  signatureLength,
const uint8_t *  data,
size_t  dataLength 
) const

Use this public key to verify the data using RsaWithSha256.

Parameters
signatureA pointer to the signature bytes.
signatureLengthThe length of signature.
dataA pointer to the input byte array to verify.
dataLengthThe length of data.
Returns
True if the signature verifies, false if not.
bool ndn::RsaPublicKeyLite::verifyWithSha256 ( const BlobLite signature,
const BlobLite data 
) const
inline

Use this public key to verify the data using RsaWithSha256.

Parameters
signatureThe signature bytes.
dataThe input byte array to verify.
Returns
True if the signature verifies, false if not.

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