Skip to content

[CM-22] Authority Key Identifier support #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions examples/utility/Provisioning/Provisioning.ino
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ void setup() {
String authorityKeyIdentifier = promptAndReadLine("Please enter the certificates authority key identifier: ");
String signature = promptAndReadLine("Please enter the certificates signature: ");

serialNumber.toUpperCase();
signature.toUpperCase();

byte thingIdBytes[72];
byte serialNumberBytes[16];
byte authorityKeyIdentifierBytes[20];
Expand All @@ -90,7 +87,7 @@ void setup() {
hexStringToBytes(serialNumber, serialNumberBytes, sizeof(serialNumberBytes));
hexStringToBytes(authorityKeyIdentifier, authorityKeyIdentifierBytes, sizeof(authorityKeyIdentifierBytes));
hexStringToBytes(signature, signatureBytes, sizeof(signatureBytes));

if (!ECCX08.writeSlot(thingIdSlot, thingIdBytes, sizeof(thingIdBytes))) {
Serial.println("Error storing thing id!");
while (1);
Expand Down Expand Up @@ -179,8 +176,9 @@ String readLine() {
return line;
}

void hexStringToBytes(const String& in, byte out[], int length) {
void hexStringToBytes(String& in, byte out[], int length) {
int inLength = in.length();
in.toUpperCase();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authorityKeyIdentifier wasn't being capitalized. To prevent that from happening in the future, I added this line and remove the others about serialNumber and signature.

int outLength = 0;

for (int i = 0; i < inLength && outLength < length; i += 2) {
Expand All @@ -190,6 +188,6 @@ void hexStringToBytes(const String& in, byte out[], int length) {
byte highByte = (highChar <= '9') ? (highChar - '0') : (highChar + 10 - 'A');
byte lowByte = (lowChar <= '9') ? (lowChar - '0') : (lowChar + 10 - 'A');

out[outLength++] = (highByte << 4) | lowByte;
out[outLength++] = (highByte << 4) | (lowByte & 0xF);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this mask will prevent lowByte to overflow

}
}