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

An EcPrivateKeyLite holds a decoded or generated EC private key for use in crypto operations. More...

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

Inheritance diagram for ndn::EcPrivateKeyLite:
ndn_EcPrivateKey

Public Member Functions

 EcPrivateKeyLite ()
 Create an EcPrivateKeyLite with a null value.
 
 ~EcPrivateKeyLite ()
 Finalize the EcPrivateKeyLite, freeing memory if needed.
 
ndn_Error decode (const uint8_t *privateKeyDer, size_t privateKeyDerLength)
 Decode the privateKeyDer and set this EcPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error decode (const BlobLite &privateKeyDer)
 Decode the privateKeyDer and set this EcPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error setByCurve (int curveId, const uint8_t *value, size_t valueLength)
 Set the the private key from the given curveId, using the value to create a BIGNUM, allocating memory as needed. More...
 
ndn_Error setByCurve (int curveId, const BlobLite &value)
 Set the the private key from the given curveId, using the value to create a BIGNUM, allocating memory as needed. More...
 
ndn_Error generate (uint32_t keySize)
 Generate a key pair and set this EcPrivateKeyLite, allocating memory as needed. More...
 
ndn_Error encodePrivateKey (bool includeParameters, uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded private key. More...
 
ndn_Error encodePublicKey (bool includeParameters, uint8_t *encoding, size_t &encodingLength) const
 Encode the DER-encoded EC 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 EcdsaWithSha256. More...
 
ndn_Error signWithSha256 (const BlobLite &data, uint8_t *signature, size_t &signatureLength) const
 Use this private key to sign the data using EcdsaWithSha256. More...
 
ndn_Error getCurveId (int &curveId) const
 Get the OpenSSL curve ID. More...
 

Static Public Member Functions

static EcPrivateKeyLitedownCast (ndn_EcPrivateKey &blob)
 Downcast the reference to the ndn_EcPrivateKey struct to a EcPrivateKeyLite. More...
 
static const EcPrivateKeyLitedownCast (const ndn_EcPrivateKey &blob)
 

Additional Inherited Members

- Public Attributes inherited from ndn_EcPrivateKey
struct ec_key_st * privateKey
 

Detailed Description

An EcPrivateKeyLite holds a decoded or generated EC private key for use in crypto operations.

Member Function Documentation

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

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

Decode the privateKeyDer and set this EcPrivateKeyLite, 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 EC private key.
static EcPrivateKeyLite& ndn::EcPrivateKeyLite::downCast ( ndn_EcPrivateKey blob)
inlinestatic

Downcast the reference to the ndn_EcPrivateKey struct to a EcPrivateKeyLite.

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

Encode the DER-encoded private key.

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.
ndn_Error ndn::EcPrivateKeyLite::encodePublicKey ( 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.
ndn_Error ndn::EcPrivateKeyLite::generate ( uint32_t  keySize)

Generate a key pair and set this EcPrivateKeyLite, 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, including if a curve can't be found for the keySize.
ndn_Error ndn::EcPrivateKeyLite::getCurveId ( int &  curveId) const

Get the OpenSSL curve ID.

Parameters
curveIdSet curveId to the OpenSSL curve ID such as NID_secp384r1.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if can't get the curve ID.
ndn_Error ndn::EcPrivateKeyLite::setByCurve ( int  curveId,
const uint8_t *  value,
size_t  valueLength 
)

Set the the private key from the given curveId, using the value to create a BIGNUM, allocating memory as needed.

Parameters
curveIdThe OpenSSL curve ID such as NID_secp384r1.
valueA pointer to the value array for the BIGNUM.
valueLengthThe length of value.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if can't create the private key from the curveId or value.
ndn_Error ndn::EcPrivateKeyLite::setByCurve ( int  curveId,
const BlobLite value 
)
inline

Set the the private key from the given curveId, using the value to create a BIGNUM, allocating memory as needed.

Parameters
curveIdThe OpenSSL curve ID such as NID_secp384r1.
valueThe value array for the BIGNUM.
Returns
0 for success, else NDN_ERROR_Error_decoding_key if can't create the private key from the curveId or value.
ndn_Error ndn::EcPrivateKeyLite::signWithSha256 ( const uint8_t *  data,
size_t  dataLength,
uint8_t *  signature,
size_t &  signatureLength 
) const

Use this private key to sign the data using EcdsaWithSha256.

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::EcPrivateKeyLite::signWithSha256 ( const BlobLite data,
uint8_t *  signature,
size_t &  signatureLength 
) const
inline

Use this private key to sign the data using EcdsaWithSha256.

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: