@@ -55,11 +55,15 @@ int SecureElement::writeCert(ECP256Certificate & cert, const int certSlot)
5555 if (!_secureElement.writeSlot (certSlot + 1 , cert.compressedCertSerialAndAuthorityKeyIdBytes (), cert.compressedCertSerialAndAuthorityKeyIdLenght ())) {
5656 return 0 ;
5757 }
58+
59+ if (!_secureElement.writeSlot (certSlot + 2 , cert.subjectCommonNameBytes (), cert.subjectCommonNameLenght ())) {
60+ return 0 ;
61+ }
5862#endif
5963 return 1 ;
6064}
6165
62- int SecureElement::readCert (ECP256Certificate & cert, const int certSlot)
66+ int SecureElement::readCert (ECP256Certificate & cert, const int certSlot, const int keySlot )
6367{
6468#if defined(BOARD_HAS_SE050)
6569 byte derBuffer[SE_CERT_BUFFER_LENGTH];
@@ -72,16 +76,11 @@ int SecureElement::readCert(ECP256Certificate & cert, const int certSlot)
7276 return 0 ;
7377 }
7478#else
75- String deviceId;
79+ String deviceId = " xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx " ;
7680 byte publicKey[ECP256_CERT_PUBLIC_KEY_LENGTH];
7781
7882 cert.begin ();
7983
80- /* To do certificate is splitted into multiple slots */
81- // if (!readDeviceId(deviceId, 0)) {
82- // return 0;
83- // }
84-
8584 if (!_secureElement.readSlot (certSlot, cert.compressedCertSignatureAndDatesBytes (), cert.compressedCertSignatureAndDatesLength ())) {
8685 return 0 ;
8786 }
@@ -90,8 +89,11 @@ int SecureElement::readCert(ECP256Certificate & cert, const int certSlot)
9089 return 0 ;
9190 }
9291
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)) {
9597 return 0 ;
9698 }
9799
0 commit comments