File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -964,6 +964,10 @@ int ECP256Certificate::importCompressedSignature() {
964
964
rLen = result[1 ] - paddingBytes;
965
965
/* Skip padding and ASN INTEGER sequence 0x02 0xXX */
966
966
result += (2 + paddingBytes);
967
+ /* Check data length */
968
+ if (rLen != ECP256_CERT_SIGNATURE_R_LENGTH) {
969
+ return 0 ;
970
+ }
967
971
/* Copy data to compressed slot */
968
972
memcpy (_compressedCert.slot .one .values .signature , result, rLen);
969
973
/* reset padding before importing S sequence */
@@ -977,6 +981,10 @@ int ECP256Certificate::importCompressedSignature() {
977
981
sLen = result[1 ] - paddingBytes;
978
982
/* Skip padding and ASN INTEGER sequence 0x02 0xXX */
979
983
result += (2 + paddingBytes);
984
+ /* Check data length */
985
+ if (sLen != ECP256_CERT_SIGNATURE_S_LENGTH) {
986
+ return 0 ;
987
+ }
980
988
/* Copy data to compressed slot */
981
989
memcpy (&_compressedCert.slot .one .values .signature [rLen], result, sLen );
982
990
return 1 ;
Original file line number Diff line number Diff line change 22
22
#define ECP256_CERT_SERIAL_NUMBER_LENGTH 16
23
23
#define ECP256_CERT_AUTHORITY_KEY_ID_LENGTH 20
24
24
#define ECP256_CERT_PUBLIC_KEY_LENGTH 64
25
- #define ECP256_CERT_SIGNATURE_LENGTH 64
25
+ #define ECP256_CERT_SIGNATURE_R_LENGTH 32
26
+ #define ECP256_CERT_SIGNATURE_S_LENGTH ECP256_CERT_SIGNATURE_R_LENGTH
27
+ #define ECP256_CERT_SIGNATURE_LENGTH (ECP256_CERT_SIGNATURE_R_LENGTH + ECP256_CERT_SIGNATURE_S_LENGTH)
26
28
#define ECP256_CERT_DATES_LENGTH 3
27
29
#define ECP256_CERT_COMPRESSED_CERT_SLOT_LENGTH 72
28
- #define ECP256_CERT_COMPRESSED_CERT_LENGTH ECP256_CERT_COMPRESSED_CERT_SLOT_LENGTH + ECP256_CERT_SERIAL_NUMBER_LENGTH + ECP256_CERT_AUTHORITY_KEY_ID_LENGTH
30
+ #define ECP256_CERT_COMPRESSED_CERT_LENGTH ( ECP256_CERT_COMPRESSED_CERT_SLOT_LENGTH + ECP256_CERT_SERIAL_NUMBER_LENGTH + ECP256_CERT_AUTHORITY_KEY_ID_LENGTH)
29
31
30
32
#include < Arduino.h>
31
33
You can’t perform that action at this time.
0 commit comments