CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
apdu.cpp File Reference
#include "mod_gpg/openpgp/apdu.h"
#include <string.h>

Go to the source code of this file.

Functions

bool apdu_parse (const uint8_t *raw, size_t raw_len, apdu_t *apdu)
 ISO 7816 APDU parsing/building helpers for CDC Badge OpenPGP stack.
size_t apdu_build_response (uint8_t *buf, size_t buf_max, const uint8_t *data, size_t data_len, uint16_t sw)
 Builds APDU response payload with status word trailer.

Function Documentation

◆ apdu_build_response()

size_t apdu_build_response ( uint8_t * buf,
size_t buf_max,
const uint8_t * data,
size_t data_len,
uint16_t sw )

Builds APDU response payload with status word trailer.

Parameters
bufOutput response buffer.
buf_maxCapacity of buf.
dataOptional payload bytes.
data_lenPayload length.
swISO7816 status word.
Returns
Total bytes written to buf.

Definition at line 99 of file apdu.cpp.

Referenced by cmd_generate_keypair(), cmd_get_data(), cmd_internal_authenticate(), cmd_pso_cds(), cmd_pso_decipher(), cmd_pso_decipher_aes(), and openpgp_process_apdu().

◆ apdu_parse()

bool apdu_parse ( const uint8_t * raw,
size_t raw_len,
apdu_t * apdu )

ISO 7816 APDU parsing/building helpers for CDC Badge OpenPGP stack.

Based on pico-openpgp (https://github.com/polhenarejos/pico-openpgp).

Parses raw APDU bytes into structured representation.

Parameters
rawRaw APDU buffer.
raw_lenLength of raw.
apduOutput APDU structure.
Returns
true if APDU framing is valid and parsing succeeded.

Definition at line 17 of file apdu.cpp.

Referenced by openpgp_process_apdu().