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

An EcPublicKeyLite holds a decoded EC public key for use in crypto operations. More...

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

Inheritance diagram for ndn::EcPublicKeyLite:
ndn_EcPublicKey

Public Member Functions

 EcPublicKeyLite ()
 Create an EcPublicKeyLite with a null value.
 
 ~EcPublicKeyLite ()
 Finalize the EcPublicKeyLite, freeing memory if needed.
 
ndn_Error decode (const uint8_t *publicKeyDer, size_t publicKeyDerLength)
 Decode the publicKeyDer and set this EcPublicKeyLite, allocating memory as needed. More...
 
ndn_Error decode (const BlobLite &publicKeyDer)
 Decode the publicKeyDer and set this EcPublicKeyLite, allocating memory as needed. More...
 
ndn_Error encode (bool includeParameters, uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded EC 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 EcdsaWithSha256. More...
 
bool verifyWithSha256 (const BlobLite &signature, const BlobLite &data) const
 Use this public key to verify the data using EcdsaWithSha256. More...
 

Static Public Member Functions

static ndn_Error verifySha256WithEcdsaSignature (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 ECDSA signature of the data using the given public key. More...
 
static ndn_Error verifySha256WithEcdsaSignature (const BlobLite &signature, const BlobLite &data, const BlobLite &publicKeyDer, bool &verified)
 Verify the ECDSA signature of the data using the given public key. More...
 
static EcPublicKeyLitedownCast (ndn_EcPublicKey &blob)
 Downcast the reference to the ndn_EcPublicKey struct to a EcPublicKeyLite. More...
 
static const EcPublicKeyLitedownCast (const ndn_EcPublicKey &blob)
 

Detailed Description

An EcPublicKeyLite holds a decoded EC public key for use in crypto operations.

Member Function Documentation

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

Decode the publicKeyDer and set this EcPublicKeyLite, 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 EC public key.
ndn_Error ndn::EcPublicKeyLite::decode ( const BlobLite publicKeyDer)
inline

Decode the publicKeyDer and set this EcPublicKeyLite, 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 EC public key.
static EcPublicKeyLite& ndn::EcPublicKeyLite::downCast ( ndn_EcPublicKey blob)
inlinestatic

Downcast the reference to the ndn_EcPublicKey struct to a EcPublicKeyLite.

Parameters
blobA reference to the ndn_EcPublicKey struct.
Returns
The same reference as EcPublicKeyLite.
ndn_Error ndn::EcPublicKeyLite::encode ( bool  includeParameters,
uint8_t *  encoding,
size_t &  encodingLength 
) const

Encode the DER-encoded EC SubjectPublicKeyInfo.

Parameters
includeParametersIf true, then include the EC parameters in the encoding.
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.
static ndn_Error ndn::EcPublicKeyLite::verifySha256WithEcdsaSignature ( 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 ECDSA 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 ECDSA public key.
static ndn_Error ndn::EcPublicKeyLite::verifySha256WithEcdsaSignature ( const BlobLite signature,
const BlobLite data,
const BlobLite publicKeyDer,
bool &  verified 
)
inlinestatic

Verify the ECDSA 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 ECDSA public key.
bool ndn::EcPublicKeyLite::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 EcdsaWithSha256.

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::EcPublicKeyLite::verifyWithSha256 ( const BlobLite signature,
const BlobLite data 
) const
inline

Use this public key to verify the data using EcdsaWithSha256.

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: