Use BE/LE functions for packing uint16.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Submodule pico-keys-sdk updated: d530ea6979...d78e977926
@@ -70,8 +70,8 @@ int cmd_extras() {
|
||||
gettimeofday(&tv, NULL);
|
||||
#endif
|
||||
struct tm *tm = localtime(&tv.tv_sec);
|
||||
res_APDU[res_APDU_size++] = (tm->tm_year + 1900) >> 8;
|
||||
res_APDU[res_APDU_size++] = (tm->tm_year + 1900) & 0xff;
|
||||
put_uint16_t_be(tm->tm_year + 1900, res_APDU);
|
||||
res_APDU_size += 2;
|
||||
res_APDU[res_APDU_size++] = tm->tm_mon;
|
||||
res_APDU[res_APDU_size++] = tm->tm_mday;
|
||||
res_APDU[res_APDU_size++] = tm->tm_wday;
|
||||
@@ -110,8 +110,8 @@ int cmd_extras() {
|
||||
}
|
||||
uint16_t opts = get_device_options();
|
||||
if (apdu.nc == 0) {
|
||||
res_APDU[res_APDU_size++] = opts >> 8;
|
||||
res_APDU[res_APDU_size++] = opts & 0xff;
|
||||
put_uint16_t_be(opts, res_APDU);
|
||||
res_APDU_size += 2;
|
||||
}
|
||||
else {
|
||||
uint8_t newopts[] = { apdu.data[0], (opts & 0xff) };
|
||||
|
||||
@@ -22,12 +22,12 @@ int cmd_list_keys() {
|
||||
/* First we send DEV private key */
|
||||
/* Both below conditions should be always TRUE */
|
||||
if (search_file(EF_PRKD_DEV)) {
|
||||
res_APDU[res_APDU_size++] = EF_PRKD_DEV >> 8;
|
||||
res_APDU[res_APDU_size++] = EF_PRKD_DEV & 0xff;
|
||||
put_uint16_t_be(EF_PRKD_DEV, res_APDU + res_APDU_size);
|
||||
res_APDU_size += 2;
|
||||
}
|
||||
if (search_file(EF_KEY_DEV)) {
|
||||
res_APDU[res_APDU_size++] = EF_KEY_DEV >> 8;
|
||||
res_APDU[res_APDU_size++] = EF_KEY_DEV & 0xff;
|
||||
put_uint16_t_be(EF_KEY_DEV, res_APDU + res_APDU_size);
|
||||
res_APDU_size += 2;
|
||||
}
|
||||
//first CC
|
||||
for (int i = 0; i < dynamic_files; i++) {
|
||||
|
||||
@@ -119,8 +119,8 @@ int cmd_select() {
|
||||
res_APDU[res_APDU_size++] = 0x85;
|
||||
res_APDU[res_APDU_size++] = 5;
|
||||
uint16_t opts = get_device_options();
|
||||
res_APDU[res_APDU_size++] = opts >> 8;
|
||||
res_APDU[res_APDU_size++] = opts & 0xff;
|
||||
put_uint16_t_be(opts, res_APDU + res_APDU_size);
|
||||
res_APDU_size += 2;
|
||||
res_APDU[res_APDU_size++] = 0xFF;
|
||||
res_APDU[res_APDU_size++] = HSM_VERSION_MAJOR;
|
||||
res_APDU[res_APDU_size++] = HSM_VERSION_MINOR;
|
||||
|
||||
@@ -421,8 +421,7 @@ uint16_t asn1_build_cert_description(const uint8_t *label,
|
||||
p += format_tlv_len(asn1_len_tag(0x4, sizeof(uint16_t)), p);
|
||||
*p++ = 0x4;
|
||||
p += format_tlv_len(sizeof(uint16_t), p);
|
||||
*p++ = fid >> 8;
|
||||
*p++ = fid & 0xff;
|
||||
put_uint16_t_be(fid, p); p += sizeof(uint16_t);
|
||||
return (uint16_t)(p - buf);
|
||||
}
|
||||
|
||||
@@ -498,8 +497,8 @@ uint16_t asn1_build_prkd_generic(const uint8_t *label,
|
||||
p += format_tlv_len(asn1_len_tag(0x2, 2), p);
|
||||
*p++ = 0x2;
|
||||
p += format_tlv_len(2, p);
|
||||
*p++ = (keysize >> 8) & 0xff;
|
||||
*p++ = keysize & 0xff;
|
||||
put_uint16_t_be(keysize, p);
|
||||
p += 2;
|
||||
}
|
||||
|
||||
//Seq 4
|
||||
@@ -518,8 +517,8 @@ uint16_t asn1_build_prkd_generic(const uint8_t *label,
|
||||
if (key_type & PICO_KEYS_KEY_EC || key_type & PICO_KEYS_KEY_RSA) {
|
||||
*p++ = 0x2;
|
||||
p += format_tlv_len(2, p);
|
||||
*p++ = (keysize >> 8) & 0xff;
|
||||
*p++ = keysize & 0xff;
|
||||
put_uint16_t_be(keysize, p);
|
||||
p += 2;
|
||||
}
|
||||
return (uint16_t)(p - buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user