CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
gpg.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5#include <stddef.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#define CDC_CURVE_ED25519 0
12#define CDC_CURVE_P256 1
13
14#define GPG_USER_ID_MAX 64
15#define GPG_FINGERPRINT_LEN 20
16#define GPG_PUBKEY_MAX_LEN 64
17
18#ifdef __DOXYGEN__
19namespace cdc::mod_gpg {
20#endif
21
25typedef struct {
27 uint8_t curve;
30 uint32_t created_at;
31 uint32_t sign_count;
33
34#ifdef __DOXYGEN__
35} // namespace cdc::mod_gpg
36#endif
37
45bool gpg_init(void);
46
51bool gpg_is_initialized(void);
52
57bool gpg_get_status(gpg_status_t *status);
58
64bool gpg_set_pending_user_id(const char *user_id);
65
70
78bool gpg_generate_key(uint8_t curve);
79
86bool gpg_reset(void);
87
92bool gpg_export_pubkey_pem(char *buf, size_t size, size_t *out_len);
93
105bool gpg_alchemy_fingerprint(char *buf, size_t len);
106
107#ifdef __cplusplus
108}
109#endif
uint8_t curve
uint8_t user_id[FIDO2_USER_ID_MAX_LEN]
bool gpg_has_pending_user_id(void)
Returns whether a user-id was staged via gpg_set_pending_user_id().
Definition gpg.cpp:128
bool gpg_init(void)
Initializes the GPG module bookkeeping.
Definition gpg.cpp:86
bool gpg_set_pending_user_id(const char *user_id)
Stages a user-id string for the next on-device key generation. The string is forwarded to OpenpgpNvsS...
Definition gpg.cpp:121
bool gpg_generate_key(uint8_t curve)
Generates SIG / DEC / AUT keys on the device and announces them to the OpenPGP card application (fing...
Definition gpg.cpp:132
bool gpg_alchemy_fingerprint(char *buf, size_t len)
Writes the alchemical-word fingerprint of the SIG public key.
Definition gpg.cpp:319
bool gpg_get_status(gpg_status_t *status)
Fills status from the OpenPGP card-application state.
Definition gpg.cpp:95
#define GPG_USER_ID_MAX
Definition gpg.h:14
bool gpg_is_initialized(void)
Reports whether at least one OpenPGP key role has a configured fingerprint on the card.
Definition gpg.cpp:91
bool gpg_export_pubkey_pem(char *buf, size_t size, size_t *out_len)
Renders the current SIG public key as a SubjectPublicKeyInfo PEM. The key is read straight from the s...
Definition gpg.cpp:233
#define GPG_FINGERPRINT_LEN
Definition gpg.h:15
bool gpg_reset(void)
Factory-resets all GPG key material and metadata.
Definition gpg.cpp:224
Snapshot of the current OpenPGP card-application state for UI display.
Definition gpg.h:25
uint8_t fingerprint[20]
Definition gpg.h:29