|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Go to the source code of this file.
Functions | |
| algo_attr_status_t | algo_attr_parse (const uint8_t *bytes, size_t len, algo_attr_t *out) |
| Parse a raw algorithm-attribute byte sequence into structured form. | |
| algo_attr_status_t | algo_attr_build (const algo_attr_t *attr, uint8_t *out, size_t out_cap, size_t *out_len) |
| Serialise an algorithm-attribute structure to bytes. | |
| algo_attr_status_t | algo_attr_validate_role (const algo_attr_t *attr, algo_attr_role_t role) |
| Check whether the parsed attribute is compatible with the key role it will be installed into. | |
| algo_attr_status_t | algo_attr_validate_capability (const algo_attr_t *attr, bool rsa_supported) |
| Check whether the badge's secure element / mbedTLS combination can actually execute this algorithm. | |
| algo_attr_status_t algo_attr_build | ( | const algo_attr_t * | attr, |
| uint8_t * | out, | ||
| size_t | out_cap, | ||
| size_t * | out_len ) |
Serialise an algorithm-attribute structure to bytes.
The trailing 0xFF "import format" byte for ECC is emitted only when attr->has_import_format is set. RSA values are encoded in network byte order (big-endian) per spec.
Definition at line 86 of file algo_attr.cpp.
References ALGO_ATTR_ERR_BAD_ALGO, ALGO_ATTR_ERR_BAD_CURVE, ALGO_ATTR_ERR_BAD_RSA, ALGO_ATTR_ERR_BUF_TOO_SMALL, ALGO_ATTR_ERR_NULL, ALGO_ATTR_ID_RSA, ALGO_ATTR_OK, algo_attr_t::algo_id, algo_attr_t::curve, algo_attr_t::has_import_format, algo_attr_t::import_format, algo_attr_t::rsa_e_bits, algo_attr_t::rsa_import_fmt, and algo_attr_t::rsa_n_bits.
| algo_attr_status_t algo_attr_parse | ( | const uint8_t * | bytes, |
| size_t | len, | ||
| algo_attr_t * | out ) |
Parse a raw algorithm-attribute byte sequence into structured form.
The function recognises the three supported curves by OID match. Any other OID lands as ALGO_ATTR_CURVE_UNKNOWN with the call still succeeding so the caller can choose between rejection (6A80) and a permissive accept.
Definition at line 53 of file algo_attr.cpp.
References ALGO_ATTR_ERR_BAD_ALGO, ALGO_ATTR_ERR_BAD_RSA, ALGO_ATTR_ERR_NULL, ALGO_ATTR_ERR_TOO_SHORT, ALGO_ATTR_ID_RSA, ALGO_ATTR_OK, algo_attr_t::algo_id, algo_attr_t::curve, algo_attr_t::has_import_format, algo_attr_t::import_format, algo_attr_t::is_rsa, algo_attr_t::rsa_e_bits, algo_attr_t::rsa_import_fmt, and algo_attr_t::rsa_n_bits.
Referenced by put_data_algo_attr().
| algo_attr_status_t algo_attr_validate_capability | ( | const algo_attr_t * | attr, |
| bool | rsa_supported ) |
Check whether the badge's secure element / mbedTLS combination can actually execute this algorithm.
Returns ALGO_ATTR_OK for Ed25519, P-256 ECDSA, P-256 ECDH, and (if rsa_supported is true) RSA 2048/3072/4096. Anything else yields ALGO_ATTR_ERR_BAD_CURVE or ALGO_ATTR_ERR_BAD_RSA.
Definition at line 138 of file algo_attr.cpp.
References ALGO_ATTR_CURVE_ED25519, ALGO_ATTR_CURVE_P256, ALGO_ATTR_CURVE_UNKNOWN, ALGO_ATTR_CURVE_X25519, ALGO_ATTR_ERR_BAD_CURVE, ALGO_ATTR_ERR_BAD_RSA, ALGO_ATTR_ERR_NULL, ALGO_ATTR_ID_ECDH, ALGO_ATTR_ID_ECDSA, ALGO_ATTR_ID_EDDSA, ALGO_ATTR_OK, algo_attr_t::algo_id, algo_attr_t::curve, and algo_attr_t::is_rsa.
Referenced by put_data_algo_attr().
| algo_attr_status_t algo_attr_validate_role | ( | const algo_attr_t * | attr, |
| algo_attr_role_t | role ) |
Check whether the parsed attribute is compatible with the key role it will be installed into.
Encodes the badge-specific policy: ECDSA + EdDSA only for SIG/AUT, ECDH only for DEC; RSA is acceptable for any role when enabled.
Definition at line 119 of file algo_attr.cpp.
References ALGO_ATTR_ERR_NULL, ALGO_ATTR_ERR_ROLE_MISMATCH, ALGO_ATTR_ID_ECDH, ALGO_ATTR_ID_ECDSA, ALGO_ATTR_ID_EDDSA, ALGO_ATTR_OK, ALGO_ATTR_ROLE_AUT, ALGO_ATTR_ROLE_DEC, ALGO_ATTR_ROLE_SIG, algo_attr_t::algo_id, and algo_attr_t::is_rsa.
Referenced by put_data_algo_attr().