|
ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
|
NDN cryptographic utilities. More...
#include "ndn/common.hpp"Go to the source code of this file.
Functions | |
| Error | ndn::crypto::sha256 (const uint8_t *data, size_t len, uint8_t *out) |
| Compute SHA-256 hash. | |
| Error | ndn::crypto::hmacSha256 (const uint8_t *key, size_t keyLen, const uint8_t *data, size_t dataLen, uint8_t *out) |
| Compute HMAC-SHA256. | |
| bool | ndn::crypto::constantTimeCompare (const uint8_t *lhs, const uint8_t *rhs, size_t len) |
| Compare two buffers in constant time. | |
| Error | ndn::crypto::ecdsaP256GenerateKeyPair (uint8_t *privKey, uint8_t *pubKey) |
| Generate an ECDSA P-256 key pair. | |
| Error | ndn::crypto::ecdsaP256Sign (const uint8_t *privKey, const uint8_t *data, size_t dataLen, uint8_t *sig, size_t *sigLen) |
| Sign with ECDSA P-256. | |
| bool | ndn::crypto::ecdsaP256Verify (const uint8_t *pubKey, const uint8_t *data, size_t dataLen, const uint8_t *sig, size_t sigLen) |
| Verify an ECDSA P-256 signature. | |
NDN cryptographic utilities.
Provides utility functions for SHA-256 hash and HMAC-SHA256 computation. Uses the mbedtls library from ESP-IDF.
Definition in file crypto.hpp.
| bool ndn::crypto::constantTimeCompare | ( | const uint8_t * | lhs, |
| const uint8_t * | rhs, | ||
| size_t | len | ||
| ) |
Compare two buffers in constant time.
Always compares all bytes to prevent timing attacks.
| lhs | First buffer |
| rhs | Second buffer |
| len | Number of bytes to compare |
Definition at line 60 of file crypto.cpp.
References ndn::crypto::constantTimeCompare().
Referenced by ndn::crypto::constantTimeCompare().
| Error ndn::crypto::ecdsaP256GenerateKeyPair | ( | uint8_t * | privKey, |
| uint8_t * | pubKey | ||
| ) |
Generate an ECDSA P-256 key pair.
| privKey | Private key output buffer (32 bytes) |
| pubKey | Public key output buffer (65 bytes, uncompressed form 0x04 || X || Y) |
Definition at line 72 of file crypto.cpp.
References ndn::ECDSA_P256_PRIVKEY_SIZE, ndn::ECDSA_P256_PUBKEY_SIZE, and ndn::crypto::ecdsaP256GenerateKeyPair().
Referenced by ndn::crypto::ecdsaP256GenerateKeyPair().
| Error ndn::crypto::ecdsaP256Sign | ( | const uint8_t * | privKey, |
| const uint8_t * | data, | ||
| size_t | dataLen, | ||
| uint8_t * | sig, | ||
| size_t * | sigLen | ||
| ) |
Sign with ECDSA P-256.
Computes a SHA-256 hash and generates an ECDSA signature. The signature is encoded in DER format.
| privKey | Private key (32 bytes) |
| data | Data to sign |
| dataLen | Data length |
| sig | Signature output buffer (max 72 bytes) |
| sigLen | Stores the actual signature size |
Definition at line 126 of file crypto.cpp.
References ndn::ECDSA_P256_PRIVKEY_SIZE, ndn::ECDSA_P256_SIG_MAX_SIZE, ndn::crypto::ecdsaP256Sign(), ndn::crypto::sha256(), and ndn::SHA256_DIGEST_SIZE.
Referenced by ndn::crypto::ecdsaP256Sign().
| bool ndn::crypto::ecdsaP256Verify | ( | const uint8_t * | pubKey, |
| const uint8_t * | data, | ||
| size_t | dataLen, | ||
| const uint8_t * | sig, | ||
| size_t | sigLen | ||
| ) |
Verify an ECDSA P-256 signature.
| pubKey | Public key (65 bytes, uncompressed form) |
| data | Data that was signed |
| dataLen | Data length |
| sig | Signature (DER format) |
| sigLen | Signature length |
Definition at line 181 of file crypto.cpp.
References ndn::ECDSA_P256_PUBKEY_SIZE, ndn::crypto::ecdsaP256Verify(), ndn::crypto::sha256(), and ndn::SHA256_DIGEST_SIZE.
Referenced by ndn::crypto::ecdsaP256Verify().
| Error ndn::crypto::hmacSha256 | ( | const uint8_t * | key, |
| size_t | keyLen, | ||
| const uint8_t * | data, | ||
| size_t | dataLen, | ||
| uint8_t * | out | ||
| ) |
Compute HMAC-SHA256.
| key | Pointer to key data |
| keyLen | Key length (bytes) |
| data | Pointer to input data |
| dataLen | Input data length (bytes) |
| out | Output buffer (must be at least 32 bytes) |
Definition at line 45 of file crypto.cpp.
References ndn::crypto::hmacSha256().
Referenced by ndn::crypto::hmacSha256().
| Error ndn::crypto::sha256 | ( | const uint8_t * | data, |
| size_t | len, | ||
| uint8_t * | out | ||
| ) |
Compute SHA-256 hash.
| data | Pointer to input data |
| len | Input data length (bytes) |
| out | Output buffer (must be at least 32 bytes) |
Definition at line 19 of file crypto.cpp.
References ndn::crypto::sha256().
Referenced by ndn::crypto::ecdsaP256Sign(), ndn::crypto::ecdsaP256Verify(), and ndn::crypto::sha256().