Skip to content

Commit

Permalink
Added phy_save() and phy_load() to save and load PHY.
Browse files Browse the repository at this point in the history
Signed-off-by: Pol Henarejos <[email protected]>
  • Loading branch information
polhenarejos committed Jan 29, 2025
1 parent e78ec82 commit a381e94
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pico-keys-sdk
Submodule pico-keys-sdk updated 2 files
+18 −7 src/fs/phy.c
+2 −0 src/fs/phy.h
7 changes: 1 addition & 6 deletions src/fido/cbor_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,9 @@ int cbor_config(const uint8_t *data, size_t len) {
else {
CBOR_ERROR(CTAP2_ERR_UNSUPPORTED_OPTION);
}
uint8_t tmp[PHY_MAX_SIZE];
uint16_t tmp_len = 0;
memset(tmp, 0, sizeof(tmp));
if (phy_serialize_data(&phy_data, tmp, &tmp_len) != PICOKEY_OK) {
if (phy_save() != PICOKEY_OK) {
CBOR_ERROR(CTAP2_ERR_PROCESSING);
}
file_put_data(ef_phy, tmp, tmp_len);
low_flash_available();
}
#endif
else {
Expand Down
12 changes: 2 additions & 10 deletions src/fido/cbor_make_credential.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,13 @@ int cbor_make_credential(const uint8_t *data, size_t len) {
if (memcmp(p, "CommissionProfile", 17) == 0) {
ret = phy_unserialize_data(user.id.data, user.id.len, &phy_data);
if (ret == PICOKEY_OK) {
uint8_t tmp[PHY_MAX_SIZE];
uint16_t tmp_len = 0;
memset(tmp, 0, sizeof(tmp));
if (phy_serialize_data(&phy_data, tmp, &tmp_len) != PICOKEY_OK) {
CBOR_ERROR(CTAP2_ERR_PROCESSING);
}
DEBUG_DATA(tmp,tmp_len);
file_put_data(ef_phy, tmp, tmp_len);
ret = phy_save();
}
}
#endif
if (ret != 0) {
if (ret != PICOKEY_OK) {
CBOR_ERROR(CTAP2_ERR_PROCESSING);
}
low_flash_available();
}
}

Expand Down

0 comments on commit a381e94

Please sign in to comment.