Pol Henarejos and GitHub
88380473ae
Merge pull request #138 from jobordu/fix/devaut-buffer-reset
...
fix(hsm): reset the output buffer before building C.DevAut (EF 2F02 holds an extra object)
nightly-development
nightly-master
2026-08-20 18:26:57 +02:00
Pol Henarejos
49616b4ee5
Fix initialization when no TERMCA is available
...
Closes #139 #137
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-08-20 18:20:54 +02:00
Pol Henarejos and GitHub
1abe1d717c
Simplify comment for output buffer reset
...
Updated comment for clarity and removed unnecessary details.
2026-08-20 18:17:50 +02:00
Pol Henarejos
53ca1ebe37
Pico Keys SDK 9
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-08-20 17:58:04 +02:00
Pol Henarejos
bea2cd224a
Do not delete func files
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-08-20 17:12:11 +02:00
open-swe[bot]
df9b45e833
fix(hsm): reset the output buffer before building C.DevAut
...
asn1_cvc_aut() and asn1_cvc_cert() both APPEND (output->len += out_len). The
shared 'certificates' buffer was never reset between them, so EF_TERMCA
(C.DevAut, EF 2F02) was written with the CUMULATIVE length and ended up holding
the EE authenticated request (tag 0x67, 497 bytes) followed by the certificate
(tag 7F21, 443 bytes) — 940 bytes instead of 443.
Consequence: OpenSC decodes the FIRST object, so its 'device certificate' was
actually the EE request, and offline TR-03110 verification failed outright
('not a parseable CVC certificate').
Measured on hardware: EF 2F02 940 -> 443 bytes, and the staging gate's hw_devaut
step goes from FAIL to PASS (CHR=ESP2202E14A00001 CAR=ESP2202E14A00001).
The EE request already reached the flash page cache via file_put_data above, so
reusing the buffer is safe.
2026-08-06 09:32:42 -04:00
Pol Henarejos
1ad8444136
Migrate HSM output APIs to stateful byte buffers
...
Update key-container, KEK, CVC, ASN.1, and command handlers to pass
byte_buffer_t by reference and consume its tracked length.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-27 11:42:28 +02:00
Pol Henarejos
20705d73c5
Use byte-array spans across HSM command handling
...
Migrate HSM command, CVC, KEK, metadata, authorization, and key-container interfaces from raw pointer/length pairs to byte-array spans.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-27 03:13:26 +02:00
Pol Henarejos
d2f6b72602
Use SDK container store for HSM key objects
...
Preserve allocation, authorization, rollback, and the existing flash format.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-26 20:47:16 +02:00
Pol Henarejos
a7095270b8
Expose container objects through legacy file interfaces
...
Remove PRKD, certificate and metadata shadow writes while preserving legacy compatibility
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-18 01:15:20 +02:00
Pol Henarejos
d2ebbb2a44
Enforce HSM object policy when opening v1 private key material
...
Require verified PIN, SO/admin, or isolated firmware authorization without migrating legacy keys
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 23:16:32 +02:00
Pol Henarejos
f77a07b927
Map HSM authentication state to object-policy facts
...
Bind PIN, SO-PIN, PKA and secure messaging to invalidatable session epochs
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 22:31:20 +02:00
Pol Henarejos
2f9227664c
Use the SDK object crypto provider with the existing MKEK
...
Add provider tests and preserve the current flash and APDU behavior
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 19:49:59 +02:00
Pol Henarejos
3c7741922d
Document protected object records and ID allocation
...
Define recovery and rollback limits before HSM provider adoption
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 18:23:46 +02:00
Pol Henarejos
4c8a6b972d
Document one-object container format implementation
...
Align manifest descriptors with 64-bit immutable record identities
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 18:03:23 +02:00
Pol Henarejos
b83b5577ef
Route HSM v1 key objects through opaque storage handles
...
Preserve legacy records while enforcing namespace-bound access and safe deletion
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 16:00:47 +02:00
Pol Henarejos
37c51fc9f3
Add migration-free HSM object compatibility layer
...
Store new keys in versioned object envelopes while preserving legacy records and logical FIDs; add dual-format access, security controls, and regression coverage.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-17 14:58:51 +02:00
Pol Henarejos
bfe73eaae0
Fix build
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 22:20:37 +02:00
Pol Henarejos
c377f3db86
Support multi-sector flash files with 32-bit lengths and cache draining
...
Add boundary, large-write, readback, overwrite, and truncation stress tests
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 21:34:48 +02:00
Pol Henarejos
5a54eef920
Expand dynamic file index to 2048 entries
...
Use a compact open-addressed hash table for fast lookup, stable deletion, and tombstone reuse without changing the flash format.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 20:37:52 +02:00
Pol Henarejos
a8ec85a508
Put list onto a function with prefix.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 20:26:33 +02:00
Pol Henarejos
a2fea57c8f
Fix domain mutation before auth.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 10:47:32 +02:00
Pol Henarejos
201a806d75
Add masked mkek.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 10:47:12 +02:00
Pol Henarejos
7da850f91a
New key objects use a self-identifying AEAD record. Keep accepting the legacy CFB layout so firmware upgrades do not invalidate deployed keys.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:46:33 +02:00
Pol Henarejos
050f449b1b
Reduce latency without unneeded mutex take and release.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:37:45 +02:00
Pol Henarejos
a2e1e1082c
Check no re-login in test not auth.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:37:15 +02:00
Pol Henarejos
b46db209b2
Generate master seed requires user auth.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:07:50 +02:00
Pol Henarejos
0ab33f47db
Add general authentication reject test.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:02:06 +02:00
Pol Henarejos
cb8065e6be
Check length equals mkek size + iv.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:01:56 +02:00
Pol Henarejos
9d45e24302
Add sanity check
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:01:43 +02:00
Pol Henarejos
d80b1f5d65
Fix memcmp for puk_store
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:01:34 +02:00
Pol Henarejos
45067c3d67
RP2350 secure-boot key indices are restricted to slots 0..5 before OTP address/bit calculations.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 01:01:24 +02:00
Pol Henarejos
2f17785039
RSA/EC private-key loaders reject oversized or empty blobs before fixed-buffer copies.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 00:56:42 +02:00
Pol Henarejos
e9b12c6ccd
GENERAL AUTHENTICATE rejects truncated/inconsistent envelopes before TLV parsing.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 00:56:32 +02:00
Pol Henarejos
3e4f73870a
Reject AES if no IV is provided.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 00:46:47 +02:00
Pol Henarejos
1c9ec5cf05
CHANGE PIN length validation before subtraction/KDF reads.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 00:14:20 +02:00
Pol Henarejos
ad244cc46c
Fail-closed physical presence for HSM button mode and rescue operations.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-16 00:13:57 +02:00
Pol Henarejos
7b36d47132
Fix PKA test requiring login
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 23:03:23 +02:00
Pol Henarejos
205ce7a1bb
Fix key domain deletion.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 23:03:12 +02:00
Pol Henarejos
df771e9d38
Fix PKA auth check.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 23:02:17 +02:00
Pol Henarejos
d52595d210
Fix long challenge requests.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:54:25 +02:00
Pol Henarejos
953a7933e9
Decrement counter.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:52:24 +02:00
Pol Henarejos
0f664f5d18
Clears PKA challenge state, selected PKA state, HD private context, and secure-lock mask on unload/reselection.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:51:55 +02:00
Pol Henarejos
d74caff4b1
Rolls back generated AES keys if metadata storage fails.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:50:44 +02:00
Pol Henarejos
0f566c6722
Fixed durable counter persistence and enforced counters for symmetric crypto, EC derivation, and XKEK derivation.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:50:31 +02:00
Pol Henarejos
71d5b751f4
PKA enrollment verifies the submitted CVC against the selected trusted issuer; replacement also requires authenticated state and HSM_OPT_REPLACE_PKA.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:50:20 +02:00
Pol Henarejos
34156c348d
Key-domain import/reset/delete requires an authenticated PIN session, including zero-data operations.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:50:10 +02:00
Pol Henarejos
27bffbbe94
UPDATE EF now resolves the target before its ACL check.
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:50:01 +02:00
Pol Henarejos
5a7c36b311
Propagated secure-message wrapping failure as SW_WRONG_LENGTH
...
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 22:37:15 +02:00
Pol Henarejos
5a8a27fa83
Refactor and delegate CVC handling to libcvc
...
- replace local CVC builders and parsers with libcvc APIs
- use libcvc algorithm policy and certificate signature verification
- pass typed mbedTLS PK contexts through CVC generation paths
- configure CVC writers exclusively through setter APIs
- retain HSM-specific CA-chain and inherited-curve resolution
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es >
2026-07-15 02:22:53 +02:00