File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -964,6 +964,10 @@ int ECP256Certificate::importCompressedSignature() {
964964 rLen = result[1 ] - paddingBytes;
965965 /* Skip padding and ASN INTEGER sequence 0x02 0xXX */
966966 result += (2 + paddingBytes);
967+ /* Check data length */
968+ if (rLen != ECP256_CERT_SIGNATURE_R_LENGTH) {
969+ return 0 ;
970+ }
967971 /* Copy data to compressed slot */
968972 memcpy (_compressedCert.slot .one .values .signature , result, rLen);
969973 /* reset padding before importing S sequence */
@@ -977,6 +981,10 @@ int ECP256Certificate::importCompressedSignature() {
977981 sLen = result[1 ] - paddingBytes;
978982 /* Skip padding and ASN INTEGER sequence 0x02 0xXX */
979983 result += (2 + paddingBytes);
984+ /* Check data length */
985+ if (sLen != ECP256_CERT_SIGNATURE_S_LENGTH) {
986+ return 0 ;
987+ }
980988 /* Copy data to compressed slot */
981989 memcpy (&_compressedCert.slot .one .values .signature [rLen], result, sLen );
982990 return 1 ;
Original file line number Diff line number Diff line change 2222#define ECP256_CERT_SERIAL_NUMBER_LENGTH 16
2323#define ECP256_CERT_AUTHORITY_KEY_ID_LENGTH 20
2424#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)
2628#define ECP256_CERT_DATES_LENGTH 3
2729#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)
2931
3032#include < Arduino.h>
3133
You can’t perform that action at this time.
0 commit comments