@@ -78,9 +78,6 @@ void setup() {
7878 String authorityKeyIdentifier = promptAndReadLine (" Please enter the certificates authority key identifier: " );
7979 String signature = promptAndReadLine (" Please enter the certificates signature: " );
8080
81- serialNumber.toUpperCase ();
82- signature.toUpperCase ();
83-
8481 byte thingIdBytes[72 ];
8582 byte serialNumberBytes[16 ];
8683 byte authorityKeyIdentifierBytes[20 ];
@@ -90,7 +87,7 @@ void setup() {
9087 hexStringToBytes (serialNumber, serialNumberBytes, sizeof (serialNumberBytes));
9188 hexStringToBytes (authorityKeyIdentifier, authorityKeyIdentifierBytes, sizeof (authorityKeyIdentifierBytes));
9289 hexStringToBytes (signature, signatureBytes, sizeof (signatureBytes));
93-
90+
9491 if (!ECCX08.writeSlot (thingIdSlot, thingIdBytes, sizeof (thingIdBytes))) {
9592 Serial.println (" Error storing thing id!" );
9693 while (1 );
@@ -179,8 +176,9 @@ String readLine() {
179176 return line;
180177}
181178
182- void hexStringToBytes (const String& in, byte out[], int length) {
179+ void hexStringToBytes (String& in, byte out[], int length) {
183180 int inLength = in.length ();
181+ in.toUpperCase ();
184182 int outLength = 0 ;
185183
186184 for (int i = 0 ; i < inLength && outLength < length; i += 2 ) {
@@ -190,6 +188,6 @@ void hexStringToBytes(const String& in, byte out[], int length) {
190188 byte highByte = (highChar <= ' 9' ) ? (highChar - ' 0' ) : (highChar + 10 - ' A' );
191189 byte lowByte = (lowChar <= ' 9' ) ? (lowChar - ' 0' ) : (lowChar + 10 - ' A' );
192190
193- out[outLength++] = (highByte << 4 ) | lowByte;
191+ out[outLength++] = (highByte << 4 ) | ( lowByte & 0xF ) ;
194192 }
195193}
0 commit comments