intiial commit
Dependencies: MAX8614X USBDevice max32630hsp_test
Diff: main.cpp
- Revision:
- 12:fc888315e5fd
- Parent:
- 11:ec7998257ec2
- Child:
- 13:97854f761347
diff -r ec7998257ec2 -r fc888315e5fd main.cpp
--- a/main.cpp Thu Aug 16 20:12:20 2018 +0000
+++ b/main.cpp Thu Aug 16 20:44:08 2018 +0000
@@ -36,7 +36,7 @@
#include "max32630hsp.h"
#include "MAX8614X.h"
#include "USBSerial.h"
-void executeSha256(MAX8614X &m, uint8_t *challenge, unsigned int challengeLen);
+void executeSha256(MAX8614X &m, uint8_t *challenge, unsigned int challengeLen, bool romID);
MAX32630HSP icarus(MAX32630HSP::VIO_1V8);
@@ -100,7 +100,7 @@
// m.readRegister(MAX8614X::MAX8614X_PART_ID_REG, data, 1);
// printf("device id should be 0x24, reg %02X = %02X\r\n", MAX8614X::MAX8614X_PART_ID_REG, data[0]);
- executeSha256(m, challenge_1, CHALLENGE_SZ_NO_SECRET);
+ executeSha256(m, challenge_1, CHALLENGE_SZ_NO_SECRET, 1);
//● Compare MAC from MAX86140 wth Host's precalculated MAC.
//● Check PASS or FAIL.
//● Disable SHA_EN bit ( Write 0 to SHA_EN bit).
@@ -143,7 +143,7 @@
}
-void executeSha256(MAX8614X &m, uint8_t *challenge, unsigned int challengeLen)
+void executeSha256(MAX8614X &m, uint8_t *challenge, unsigned int challengeLen, bool romID)
{
int i, j, k;
uint8_t macData[256];
@@ -205,7 +205,22 @@
// ROM ID replaces 64 of the 192 bits of constant data used in the hash operation. 16 bits out of the 160-bit secret and 16
// bits of ROM ID are programmable–8 bits each in metal and 8 bits each in OTP bits
//● Write command, with ROM ID (0x35) or without ROM ID (0x36), to SHA_CMD register
- m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG,MAX8614X::MAX8614X_SHACMD_MAC_ROM_ID);
+ if (romID) {
+ printf("ROMID \r\n");
+ m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG, MAX8614X::MAX8614X_SHACMD_MAC_ROM_ID);
+ m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG, MAX8614X::MAX8614X_SHACMD_MAC_ROM_ID);
+ wait(1);
+}
+ else
+{
+ printf("no ROMID \r\n");
+ m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG,MAX8614X::MAX8614X_SHACMD_MAC_NO_ROM_ID);
+ m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG,MAX8614X::MAX8614X_SHACMD_MAC_NO_ROM_ID);
+ wait(1);
+}
+
+
+// m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG,MAX8614X::MAX8614X_SHACMD_MAC_ROM_ID);
// m.writeRegister(MAX8614X::MAX8614X_SHA_CMD_REG,MAX8614X::MAX8614X_SHACMD_MAC_NO_ROM_ID);