Skip to content

Commit 2972229

Browse files
Using spritz_is_equal() in testing examples
1 parent 1ec157b commit 2972229

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed

examples/SpritzCryptTest/SpritzCryptTest.ino

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ void testFunc(const byte *msg, byte msgLen, const byte *key, byte keyLen)
6161
Serial.println();
6262

6363
/* Check the output */
64-
for (byte i = 0; i < msgLen; i++) {
65-
/* If the output is wrong */
66-
if (buf[i] != msg[i]) { /* Alert if test fail */
67-
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) ON */
68-
Serial.println("\n** WARNING: Output != ExpectedOutput **");
69-
break;
70-
}
64+
if (spritz_is_equal(buf, msg, msgLen)) {
65+
/* If the output is wrong "Alert" */
66+
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN On (Most boards have this LED connected to digital pin 13) */
67+
Serial.println("\n** WARNING: Output != Test_Vector **");
7168
}
7269
Serial.println();
7370
}

examples/SpritzHashChunksTest/SpritzHashChunksTest.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ void testFunc(const byte ExpectedOutput[32], const byte *data, byte dataLen)
7070
}
7171
Serial.print(digest[i], HEX);
7272
}
73+
7374
/* Check the output */
74-
for (byte i = 0; i < sizeof(digest); i++) {
75-
/* If the output is wrong */
76-
if (digest[i] != ExpectedOutput[i]) { /* Alert if test fail */
77-
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) ON */
78-
Serial.println("\n** WARNING: Output != Test_Vector **");
79-
break;
80-
}
75+
if (spritz_is_equal(digest, ExpectedOutput, sizeof(digest))) {
76+
/* If the output is wrong "Alert" */
77+
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN On (Most boards have this LED connected to digital pin 13) */
78+
Serial.println("\n** WARNING: Output != Test_Vector **");
8179
}
8280
Serial.println();
8381
}

examples/SpritzHashTest/SpritzHashTest.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ void testFunc(const byte ExpectedOutput[32], const byte *data, byte dataLen)
6464
}
6565
Serial.print(digest[i], HEX);
6666
}
67+
6768
/* Check the output */
68-
for (byte i = 0; i < sizeof(digest); i++) {
69-
/* If the output is wrong */
70-
if (digest[i] != ExpectedOutput[i]) { /* Alert if test fail */
71-
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) ON */
72-
Serial.println("\n** WARNING: Output != Test_Vector **");
73-
break;
74-
}
69+
if (spritz_is_equal(digest, ExpectedOutput, sizeof(digest))) {
70+
/* If the output is wrong "Alert" */
71+
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN On (Most boards have this LED connected to digital pin 13) */
72+
Serial.println("\n** WARNING: Output != Test_Vector **");
7573
}
7674
Serial.println();
7775
}

examples/SpritzMACTest/SpritzMACTest.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ void testFunc(const byte ExpectedOutput[32], const byte *msg, byte msgLen, const
4141
}
4242
Serial.print(digest[i], HEX);
4343
}
44+
4445
/* Check the output */
45-
for (byte i = 0; i < sizeof(digest); i++) {
46-
/* If the output is wrong */
47-
if (digest[i] != ExpectedOutput[i]) { /* Alert if test fail */
48-
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) ON */
49-
Serial.println("\n** WARNING: Output != Test_Vector **");
50-
break;
51-
}
46+
if (spritz_is_equal(digest, ExpectedOutput, sizeof(digest))) {
47+
/* If the output is wrong "Alert" */
48+
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN On (Most boards have this LED connected to digital pin 13) */
49+
Serial.println("\n** WARNING: Output != Test_Vector **");
5250
}
5351
Serial.println();
5452
}

examples/SpritzStreamTest/SpritzStreamTest.ino

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ void testFunc(const byte ExpectedOutput[32], const byte *data, byte dataLen)
6565
}
6666
Serial.print(buf[i], HEX);
6767
}
68+
6869
/* Check the output */
69-
for (byte i = 0; i < sizeof(buf); i++) {
70-
/* If the output is wrong */
71-
if (buf[i] != ExpectedOutput[i]) { /* Alert if test fail */
72-
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN (Most boards have this LED connected to digital pin 13) ON */
73-
Serial.println("\n** WARNING: Output != Test_Vector **");
74-
break;
75-
}
70+
if (spritz_is_equal(buf, ExpectedOutput, sizeof(buf))) {
71+
/* If the output is wrong "Alert" */
72+
digitalWrite(LED_BUILTIN, HIGH); /* Turn pin LED_BUILTIN On (Most boards have this LED connected to digital pin 13) */
73+
Serial.println("\n** WARNING: Output != Test_Vector **");
7674
}
7775
Serial.println();
7876
}

0 commit comments

Comments
 (0)