|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
#include "cdc_core/KeyFingerprint.h"#include "cdc_hal/ISecureElement.h"#include "mbedtls/sha256.h"#include <string.h>Go to the source code of this file.
Functions | |
| const char * | key_fingerprint_word (uint8_t index) |
| Returns alchemical word for 5-bit index. | |
| bool | key_fingerprint_from_pubkey (const uint8_t *pubkey, size_t pubkey_len, char *buf, size_t len) |
| Generates human-readable fingerprint from public key bytes. | |
| bool | key_fingerprint_generate (uint8_t slot, char *buf, size_t len) |
| Reads public key from secure element slot and generates fingerprint. | |
Variables | |
| static constexpr size_t | SHA256_DIGEST_SIZE = 32 |
| Alchemical key fingerprints shared by FIDO and OpenPGP features. | |
| static constexpr size_t | P256_PUBKEY_RAW_SIZE = 64 |
| Uncompressed P-256 public key length in raw X||Y form (no SEC1 prefix). | |
| static constexpr size_t | ED25519_PUBKEY_SIZE = 32 |
| Ed25519 public key length in bytes (raw, RFC 8032). | |
| static const char *const | ALCHEMY_WORDS [32] |
| Lookup table of 32 alchemical element labels (5-bit index space). | |
| bool key_fingerprint_from_pubkey | ( | const uint8_t * | pubkey, |
| size_t | pubkey_len, | ||
| char * | buf, | ||
| size_t | len ) |
Generates human-readable fingerprint from public key bytes.
| pubkey | Public key buffer. |
| pubkey_len | Length of pubkey. |
| buf | Output string buffer. |
| len | Size of output buffer. |
Definition at line 49 of file KeyFingerprint.cpp.
References ALCHEMY_WORDS, KEY_FINGERPRINT_MAX_LEN, KEY_FINGERPRINT_WORD_COUNT, and SHA256_DIGEST_SIZE.
Referenced by key_fingerprint_generate(), and cdc::mod_fido2::showDetail().
| bool key_fingerprint_generate | ( | uint8_t | slot, |
| char * | buf, | ||
| size_t | len ) |
Reads public key from secure element slot and generates fingerprint.
| slot | Secure-element slot number. |
| buf | Output string buffer. |
| len | Size of output buffer. |
Definition at line 83 of file KeyFingerprint.cpp.
References curve, cdc::hal::ED25519, ED25519_PUBKEY_SIZE, cdc::hal::getSecureElementInstance(), key_fingerprint_from_pubkey(), KEY_FINGERPRINT_MAX_LEN, cdc::hal::OK, cdc::hal::P256, and P256_PUBKEY_RAW_SIZE.
Referenced by gpg_alchemy_fingerprint().
| const char * key_fingerprint_word | ( | uint8_t | index | ) |
Returns alchemical word for 5-bit index.
| index | Word index in range [0,31]. |
Definition at line 36 of file KeyFingerprint.cpp.
References ALCHEMY_WORDS.
|
static |
Lookup table of 32 alchemical element labels (5-bit index space).
Definition at line 20 of file KeyFingerprint.cpp.
Referenced by key_fingerprint_from_pubkey(), and key_fingerprint_word().
|
staticconstexpr |
Ed25519 public key length in bytes (raw, RFC 8032).
Definition at line 15 of file KeyFingerprint.cpp.
|
staticconstexpr |
Uncompressed P-256 public key length in raw X||Y form (no SEC1 prefix).
Definition at line 13 of file KeyFingerprint.cpp.
|
staticconstexpr |
Alchemical key fingerprints shared by FIDO and OpenPGP features.
Size of a SHA-256 digest in bytes (FIPS 180-4).
Definition at line 11 of file KeyFingerprint.cpp.