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

CryptoLite has static methods for basic cryptography operations. More...

#include <crypto-lite.hpp>

Static Public Member Functions

static void digestSha256 (const uint8_t *data, size_t dataLength, uint8_t *digest)
 Compute the sha-256 digest of data. More...
 
static void digestSha256 (const BlobLite &data, uint8_t *digest)
 Compute the sha-256 digest of data. More...
 
static ndn_Error generateRandomBytes (uint8_t *buffer, size_t bufferLength)
 Fill the buffer with random bytes. More...
 
static void computeHmacWithSha256 (const uint8_t *key, size_t keyLength, const uint8_t *data, size_t dataLength, uint8_t *digest)
 Compute the HMAC with sha-256 of data, as defined in http://tools.ietf.org/html/rfc2104#section-2 . More...
 
static void computeHmacWithSha256 (const BlobLite &key, const BlobLite &data, uint8_t *digest)
 Compute the HMAC with sha-256 of data, as defined in http://tools.ietf.org/html/rfc2104#section-2 . More...
 
static bool verifyHmacWithSha256Signature (const uint8_t *key, size_t keyLength, const uint8_t *signature, size_t signatureLength, const uint8_t *data, size_t dataLength)
 Verify that the HMAC with sha-256 of the data equals the signature, as defined in http://tools.ietf.org/html/rfc2104#section-2 . More...
 
static bool verifyHmacWithSha256Signature (const BlobLite &key, const BlobLite &signature, const BlobLite &data)
 Verify that the HMAC with sha-256 of the data equals the signature, as defined in http://tools.ietf.org/html/rfc2104#section-2 . More...
 
static bool verifyDigestSha256Signature (const uint8_t *signature, size_t signatureLength, const uint8_t *data, size_t dataLength)
 Verify that the DigestSha256 of the data equals the signature. More...
 
static bool verifyDigestSha256Signature (const BlobLite &signature, const BlobLite &data)
 Verify that the DigestSha256 of the data equals the signature. More...
 

Detailed Description

CryptoLite has static methods for basic cryptography operations.

Member Function Documentation

static void ndn::CryptoLite::computeHmacWithSha256 ( const uint8_t *  key,
size_t  keyLength,
const uint8_t *  data,
size_t  dataLength,
uint8_t *  digest 
)
static

Compute the HMAC with sha-256 of data, as defined in http://tools.ietf.org/html/rfc2104#section-2 .

Parameters
keyA pointer to buffer with the key.
keyLengthThe length of key.
dataA pointer to the input byte array.
dataLengthThe length of data.
digestA pointer to a buffer of size ndn_SHA256_DIGEST_SIZE to receive the HMAC digest.
static void ndn::CryptoLite::computeHmacWithSha256 ( const BlobLite key,
const BlobLite data,
uint8_t *  digest 
)
inlinestatic

Compute the HMAC with sha-256 of data, as defined in http://tools.ietf.org/html/rfc2104#section-2 .

Parameters
keyThe key.
dataThe input byte array.
digestA pointer to a buffer of size ndn_SHA256_DIGEST_SIZE to receive the HMAC digest.
void ndn::CryptoLite::digestSha256 ( const uint8_t *  data,
size_t  dataLength,
uint8_t *  digest 
)
static

Compute the sha-256 digest of data.

Parameters
dataPointer to the input byte array.
dataLengthThe length of data.
digestA pointer to a buffer of size ndn_SHA256_DIGEST_SIZE to receive the digest.
static void ndn::CryptoLite::digestSha256 ( const BlobLite data,
uint8_t *  digest 
)
inlinestatic

Compute the sha-256 digest of data.

Parameters
dataThe input byte array.
digestA pointer to a buffer of size ndn_SHA256_DIGEST_SIZE to receive the digest.
ndn_Error ndn::CryptoLite::generateRandomBytes ( uint8_t *  buffer,
size_t  bufferLength 
)
static

Fill the buffer with random bytes.

Parameters
bufferWrite the random bytes to this buffer.
bufferLengthThe number of bytes to write to buffer.
Returns
0 for success, else NDN_ERROR_Error_in_generate_operation for an error including if the random number generator is not seeded.
bool ndn::CryptoLite::verifyDigestSha256Signature ( const uint8_t *  signature,
size_t  signatureLength,
const uint8_t *  data,
size_t  dataLength 
)
static

Verify that the DigestSha256 of the data equals the signature.

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.
static bool ndn::CryptoLite::verifyDigestSha256Signature ( const BlobLite signature,
const BlobLite data 
)
inlinestatic

Verify that the DigestSha256 of the data equals the signature.

Parameters
signatureThe signature bytes.
dataThe byte array to verify.
Returns
True if the signature verifies, false if not.
static bool ndn::CryptoLite::verifyHmacWithSha256Signature ( const uint8_t *  key,
size_t  keyLength,
const uint8_t *  signature,
size_t  signatureLength,
const uint8_t *  data,
size_t  dataLength 
)
static

Verify that the HMAC with sha-256 of the data equals the signature, as defined in http://tools.ietf.org/html/rfc2104#section-2 .

(This is a separate method from computeHmacWithSha256 so that we can use a crypto-safe comparison function.)

Parameters
keyA pointer to buffer with the key.
keyLengthThe length of key.
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.
static bool ndn::CryptoLite::verifyHmacWithSha256Signature ( const BlobLite key,
const BlobLite signature,
const BlobLite data 
)
inlinestatic

Verify that the HMAC with sha-256 of the data equals the signature, as defined in http://tools.ietf.org/html/rfc2104#section-2 .

(This is a separate method from computeHmacWithSha256 so that we can use a crypto-safe comparison function.)

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

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