CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
LargeBlobStore.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <cstddef>
15#include <cstdint>
16
17namespace cdc::mod_fido2 {
18
20inline constexpr uint16_t kLargeBlobMaxArray = 1024;
21
24inline constexpr uint16_t kLargeBlobEmptyLen = 17;
25
27extern const uint8_t kLargeBlobEmpty[kLargeBlobEmptyLen];
28
30enum class LbResult : uint8_t {
35};
36
42public:
44 void reset();
45
53 LbResult begin(uint8_t* buffer, uint16_t capacity, uint32_t totalLength);
54
62 LbResult append(uint32_t offset, const uint8_t* data, uint16_t len);
63
65 bool complete() const { return active_ && received_ == expected_; }
67 bool active() const { return active_; }
69 uint16_t nextOffset() const { return received_; }
71 const uint8_t* data() const { return buffer_; }
73 uint16_t length() const { return expected_; }
74
75private:
76 uint8_t* buffer_ = nullptr;
77 uint16_t capacity_ = 0;
78 uint16_t expected_ = 0;
79 uint16_t received_ = 0;
80 bool active_ = false;
81};
82
83} // namespace cdc::mod_fido2
Accumulates an offset-chunked authenticatorLargeBlobs write into a caller-owned buffer.
LbResult begin(uint8_t *buffer, uint16_t capacity, uint32_t totalLength)
Begins a write declaring the full serialized length.
bool complete() const
True once the declared length has been fully received.
LbResult append(uint32_t offset, const uint8_t *data, uint16_t len)
Appends one fragment at offset.
bool active() const
True while a write is in progress.
void reset()
Discards any partial write and returns to the idle state.
const uint8_t * data() const
Pointer to the accumulated buffer (valid after begin).
uint16_t length() const
Declared total length of the current write.
uint16_t nextOffset() const
Offset the next fragment must start at.
constexpr uint16_t kLargeBlobEmptyLen
LbResult
Outcome of a write-session step, mapped to a CTAP status by the caller.
@ StorageFull
declared total length exceeds the buffer / kLargeBlobMaxArray
@ BadSeq
fragment offset out of order, or no active session
@ BadLength
declared total too small, or a fragment overruns the total
constexpr uint16_t kLargeBlobMaxArray
Largest serialized large-blob array, advertised as maxSerializedLargeBlobArray.
const uint8_t kLargeBlobEmpty[kLargeBlobEmptyLen]
Canonical empty large-blob array bytes.