@@ -55,11 +55,15 @@ int SecureElement::writeCert(ECP256Certificate & cert, const int certSlot)
55
55
if (!_secureElement.writeSlot (certSlot + 1 , cert.compressedCertSerialAndAuthorityKeyIdBytes (), cert.compressedCertSerialAndAuthorityKeyIdLenght ())) {
56
56
return 0 ;
57
57
}
58
+
59
+ if (!_secureElement.writeSlot (certSlot + 2 , cert.subjectCommonNameBytes (), cert.subjectCommonNameLenght ())) {
60
+ return 0 ;
61
+ }
58
62
#endif
59
63
return 1 ;
60
64
}
61
65
62
- int SecureElement::readCert (ECP256Certificate & cert, const int certSlot)
66
+ int SecureElement::readCert (ECP256Certificate & cert, const int certSlot, const int keySlot )
63
67
{
64
68
#if defined(BOARD_HAS_SE050)
65
69
byte derBuffer[SE_CERT_BUFFER_LENGTH];
@@ -72,16 +76,11 @@ int SecureElement::readCert(ECP256Certificate & cert, const int certSlot)
72
76
return 0 ;
73
77
}
74
78
#else
75
- String deviceId;
79
+ String deviceId = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx " ;
76
80
byte publicKey[ECP256_CERT_PUBLIC_KEY_LENGTH];
77
81
78
82
cert.begin ();
79
83
80
- /* To do certificate is splitted into multiple slots */
81
- // if (!readDeviceId(deviceId, 0)) {
82
- // return 0;
83
- // }
84
-
85
84
if (!_secureElement.readSlot (certSlot, cert.compressedCertSignatureAndDatesBytes (), cert.compressedCertSignatureAndDatesLength ())) {
86
85
return 0 ;
87
86
}
@@ -90,8 +89,11 @@ int SecureElement::readCert(ECP256Certificate & cert, const int certSlot)
90
89
return 0 ;
91
90
}
92
91
93
- /* TODO check key slot */
94
- if (!_secureElement.generatePublicKey (0 , publicKey)) {
92
+ if (!_secureElement.readSlot (certSlot + 2 , (byte*)deviceId.begin (), deviceId.length ())) {
93
+ return 0 ;
94
+ }
95
+
96
+ if (!_secureElement.generatePublicKey (keySlot, publicKey)) {
95
97
return 0 ;
96
98
}
97
99
0 commit comments