Commit c21b307a authored by yids's avatar yids

actaully calculate and use the shared secret to encrypt the messages instead of zeros...

parent 1e36243d
Pipeline #21 skipped
......@@ -28,8 +28,20 @@ uint8_t privkey[NUM_ECC_DIGITS+1] = {0xF6, 0x8B, 0x9B, 0x7F, 0xD9, 0xF8, 0xF7, 0
uint8_t remotePubkey[NUM_ECC_DIGITS*2] = {0x99, 0x61, 0xB5, 0x38, 0xB3, 0x83, 0x7E, 0xFB, 0xD9, 0x3F, 0x71, 0xA3, 0x81, 0x77, 0xB0, 0x48, 0x32, 0x29, 0x24, 0x6B, 0x76, 0x48, 0x9C, 0x7A, 0x70, 0xFD, 0x3F, 0xC4, 0xB8, 0xAB, 0x8E, 0xCD, 0x31, 0x88, 0x50, 0x2D, 0xE6, 0x53, 0x49, 0xE8, 0xC0, 0xB4, 0xB5, 0xC6, 0x4F, 0x97, 0x7F, 0x6B};
void hashSecret(uint8_t *p_secret)
{
Serial.println("Secret:");
for( int i=0; i < NUM_ECC_DIGITS; i++){
Serial.print(p_secret[i]);
Serial.print(" ");
}
Serial.println("");
}
char * encryptAES(char* p_data, uint8_t *p_key)
{
Serial.println("encrypting with key:");
hashSecret(p_key);
uint8_t iv[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
aes_context ctx;
ctx = aes192_cbc_enc_start(p_key, iv);
......@@ -52,16 +64,6 @@ char* decryptAES(char* p_data, uint8_t *p_key)
return p_data;
}
void hashSecret(uint8_t *p_secret)
{
Serial.println("Secret:");
for( int i=0; i < NUM_ECC_DIGITS; i++){
Serial.print(p_secret[i]);
Serial.print(" ");
}
Serial.println("");
}
uint8_t *calcSharedSecret(uint8_t *p_pubkey, uint8_t *p_privkey)
{
delay(100);
......@@ -112,6 +114,7 @@ void loop()
Serial.print("freeMemory()=");
Serial.println(freeMemory());
calcSharedSecret(remotePubkey, privkey);
sendPubkey();
delay(100);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment