Skip to content

Commit 0a78f56

Browse files
committed
boot: Move to mbedtls >= 3.1 ASN.1
The ASN.1 library in mbedtls >= 3.1 no longer has any private fields in the ASN.1 parser structure. Remove the private accessors for these fields entirely. This will make the code now require newer versions of the Mbed TLS ASN.1 library. Signed-off-by: David Brown <[email protected]>
1 parent edea8ed commit 0a78f56

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

boot/bootutil/include/bootutil/crypto/ecdsa.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ static int bootutil_import_key(uint8_t **cp, uint8_t *end)
102102
return -2;
103103
}
104104
/* id-ecPublicKey (RFC5480) */
105-
if (alg.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_pubkey_oid) - 1 ||
106-
memcmp(alg.MBEDTLS_CONTEXT_MEMBER(p), ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
105+
if (alg.len != sizeof(ec_pubkey_oid) - 1 ||
106+
memcmp(alg.p, ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
107107
return -3;
108108
}
109109
/* namedCurve (RFC5480) */
110-
if (param.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_secp256r1_oid) - 1 ||
111-
memcmp(param.MBEDTLS_CONTEXT_MEMBER(p), ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
110+
if (param.len != sizeof(ec_secp256r1_oid) - 1 ||
111+
memcmp(param.p, ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
112112
return -4;
113113
}
114114
/* ECPoint (RFC5480) */
@@ -512,12 +512,12 @@ static int bootutil_parse_eckey(bootutil_ecdsa_context *ctx, uint8_t **p, uint8_
512512
if (mbedtls_asn1_get_alg(p, end, &alg, &param)) {
513513
return -2;
514514
}
515-
if (alg.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_pubkey_oid) - 1 ||
516-
memcmp(alg.MBEDTLS_CONTEXT_MEMBER(p), ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
515+
if (alg.len != sizeof(ec_pubkey_oid) - 1 ||
516+
memcmp(alg.p, ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
517517
return -3;
518518
}
519-
if (param.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_secp256r1_oid) - 1||
520-
memcmp(param.MBEDTLS_CONTEXT_MEMBER(p), ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
519+
if (param.len != sizeof(ec_secp256r1_oid) - 1||
520+
memcmp(param.p, ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
521521
return -4;
522522
}
523523

boot/bootutil/src/encrypted.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ parse_ec256_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
126126
return -5;
127127
}
128128

129-
if (alg.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_pubkey_oid) - 1 ||
130-
memcmp(alg.MBEDTLS_CONTEXT_MEMBER(p), ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
129+
if (alg.len != sizeof(ec_pubkey_oid) - 1 ||
130+
memcmp(alg.p, ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
131131
return -6;
132132
}
133-
if (param.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_secp256r1_oid) - 1 ||
134-
memcmp(param.MBEDTLS_CONTEXT_MEMBER(p), ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
133+
if (param.len != sizeof(ec_secp256r1_oid) - 1 ||
134+
memcmp(param.p, ec_secp256r1_oid, sizeof(ec_secp256r1_oid) - 1)) {
135135
return -7;
136136
}
137137

@@ -203,8 +203,8 @@ parse_x25519_enckey(uint8_t **p, uint8_t *end, uint8_t *private_key)
203203
return -4;
204204
}
205205

206-
if (alg.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ec_pubkey_oid) - 1 ||
207-
memcmp(alg.MBEDTLS_CONTEXT_MEMBER(p), ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
206+
if (alg.len != sizeof(ec_pubkey_oid) - 1 ||
207+
memcmp(alg.p, ec_pubkey_oid, sizeof(ec_pubkey_oid) - 1)) {
208208
return -5;
209209
}
210210

boot/bootutil/src/image_ed25519.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ bootutil_import_key(uint8_t **cp, uint8_t *end)
4545
return -2;
4646
}
4747

48-
if (alg.MBEDTLS_CONTEXT_MEMBER(len) != sizeof(ed25519_pubkey_oid) - 1 ||
49-
memcmp(alg.MBEDTLS_CONTEXT_MEMBER(p), ed25519_pubkey_oid, sizeof(ed25519_pubkey_oid) - 1)) {
48+
if (alg.len != sizeof(ed25519_pubkey_oid) - 1 ||
49+
memcmp(alg.p, ed25519_pubkey_oid, sizeof(ed25519_pubkey_oid) - 1)) {
5050
return -3;
5151
}
5252

0 commit comments

Comments
 (0)