Central Heating controller using the real time clock, PHY module for internet, 1-wire interface for temperature sensors, a system log and a configuration file

Dependencies:   net 1-wire lpc1768 crypto clock web fram log

/media/uploads/andrewboyson/heating.sch

/media/uploads/andrewboyson/heating.brd

/media/uploads/andrewboyson/eagle.epf

Revision:
71:9edbc59d6f64
Parent:
70:c7d0d3d926e1
Child:
72:13bc405bd40b
--- a/web-this/system/web-system-html.c	Wed Aug 28 07:13:11 2019 +0000
+++ b/web-this/system/web-system-html.c	Sun Sep 01 18:15:50 2019 +0000
@@ -6,10 +6,11 @@
 #include "web-add.h"
 #include "log.h"
 #include "bignum.h"
-#include "sha-256.h"
 #include "sha256.h"
 #include "hmac-sha-256.h"
 #include "tls-prf.h"
+#include "aes128.h"
+#include "sha1.h"
 
 void WebSystemHtml()
 {
@@ -31,16 +32,31 @@
     
     WebAddH2("Compiler");
     WebAddLabelledInt("Version Vvvbbbb", __ARMCC_VERSION);
-    
-    WebAddH2("SHA 256 test");
-    uint8_t hash[32];
-    char* input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
-    Sha256Old((uint8_t*)input, strlen(input), hash);
+        
+    WebAddH2("AES 128 test");
+    uint8_t aeskey[] = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };
+    uint8_t in[]  = { 0x76, 0x49, 0xab, 0xac, 0x81, 0x19, 0xb2, 0x46, 0xce, 0xe9, 0x8e, 0x9b, 0x12, 0xe9, 0x19, 0x7d,
+                      0x50, 0x86, 0xcb, 0x9b, 0x50, 0x72, 0x19, 0xee, 0x95, 0xdb, 0x11, 0x3a, 0x91, 0x76, 0x78, 0xb2,
+                      0x73, 0xbe, 0xd6, 0xb8, 0xe3, 0xc1, 0x74, 0x3b, 0x71, 0x16, 0xe6, 0x9e, 0x22, 0x22, 0x95, 0x16,
+                      0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09, 0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7 };
+    uint8_t iv[]  = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
+    /*
+    uint8_t out[] = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+                      0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c, 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+                      0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11, 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+                      0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17, 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10 };
+    */
+    struct AES_ctx ctx;
+
+    AES_init_ctx_iv(&ctx, aeskey, iv);
+    AES_CBC_decrypt_buffer(&ctx, in, 64);
     HttpAddText("<code>");
-    HttpAddBytesAsHex(hash, sizeof(hash));
+    HttpAddBytesAsHex(in, sizeof(in));
     HttpAddText("</code>");
     
     WebAddH2("SHA 256 stream test");
+    uint8_t hash[32];
+    char* input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
     struct Sha256State sha256state;
     Sha256Start (&sha256state);
     Sha256Add   (&sha256state, (uint8_t*)input, strlen(input));
@@ -50,6 +66,16 @@
     HttpAddBytesAsHex(hash, sizeof(hash));
     HttpAddText("</code>");
     
+    WebAddH2("SHA1 stream test");
+    struct sha1_ctx sha1state;
+    sha1_init  (&sha1state);
+    sha1_update(&sha1state, (uint8_t*)input, strlen(input));
+    sha1_final (&sha1state);
+
+    HttpAddText("<code>");
+    HttpAddBytesAsHex(sha1state.buf.b, 20);
+    HttpAddText("</code>");
+    
     WebAddH2("HMAC SHA 256 test");
     char* key = "Jefe";
     char* msg = "what do ya want for nothing?";
@@ -81,13 +107,38 @@
                                   0x4d, 0x5b, 0xbf, 0x0e, 0xf7, 0xcd, 0xa8, 0x3c,
                                   0xe1, 0x02, 0x9b, 0x52, 0x1c, 0x3e, 0x7c, 0x35};
     uint8_t verifyData[12];
-    TlsPrfServerFinished12(masterSecret, hashHandshakes, verifyData);
+    TlsPrfServerFinished(masterSecret, hashHandshakes, verifyData);
     
     HttpAddText("<code>");
     HttpAddBytesAsHex(verifyData, sizeof(verifyData));
     HttpAddText("</code>");
     
     
+    WebAddH2("Key test");
+    
+    uint8_t clientRandom[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+                               0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+                               0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+                               0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f };
+                               
+    uint8_t serverRandom[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+                               0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+                               0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+                               0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f };
+
+    uint8_t client_MAC_key_20[20];
+    uint8_t server_MAC_key_20[20];
+    uint8_t client_key_16[16];
+    uint8_t server_key_16[16];
+    TlsPrfKeys(masterSecret, clientRandom, serverRandom, client_MAC_key_20, server_MAC_key_20, client_key_16, server_key_16);
+    HttpAddText("<code>");
+    HttpAddBytesAsHex(client_MAC_key_20, sizeof(client_MAC_key_20));
+    HttpAddBytesAsHex(server_MAC_key_20, sizeof(server_MAC_key_20));
+    HttpAddBytesAsHex(client_key_16, sizeof(client_key_16));
+    HttpAddBytesAsHex(server_key_16, sizeof(server_key_16));
+    HttpAddText("</code>");
+
+    
     
     WebAddH2("Big num test");