CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
KeyFingerprint.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Macros

#define KEY_FINGERPRINT_WORD_COUNT   5
#define KEY_FINGERPRINT_MAX_LEN   64

Functions

bool key_fingerprint_generate (uint8_t slot, char *buf, size_t len)
 Reads public key from secure element slot and generates fingerprint.
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.
const char * key_fingerprint_word (uint8_t index)
 Returns alchemical word for 5-bit index.

Macro Definition Documentation

◆ KEY_FINGERPRINT_MAX_LEN

◆ KEY_FINGERPRINT_WORD_COUNT

#define KEY_FINGERPRINT_WORD_COUNT   5

Definition at line 11 of file KeyFingerprint.h.

Referenced by key_fingerprint_from_pubkey().

Function Documentation

◆ key_fingerprint_from_pubkey()

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.

Parameters
pubkeyPublic key buffer.
pubkey_lenLength of pubkey.
bufOutput string buffer.
lenSize of output buffer.
Returns
true on success.

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().

◆ key_fingerprint_generate()

bool key_fingerprint_generate ( uint8_t slot,
char * buf,
size_t len )

Reads public key from secure element slot and generates fingerprint.

Parameters
slotSecure-element slot number.
bufOutput string buffer.
lenSize of output buffer.
Returns
true if a key was read and fingerprint generated.

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().

◆ key_fingerprint_word()

const char * key_fingerprint_word ( uint8_t index)

Returns alchemical word for 5-bit index.

Parameters
indexWord index in range [0,31].
Returns
Word string or "?" for invalid index.

Definition at line 36 of file KeyFingerprint.cpp.

References ALCHEMY_WORDS.