A simple library to support serving https.

Dependents:   oldheating gps motorhome heating

Revision:
4:6a1d887f1cad
Parent:
2:82268409e83f
Child:
10:e269fd7b9500
--- a/pki/pri-key.c	Fri Aug 02 15:07:18 2019 +0000
+++ b/pki/pri-key.c	Tue Aug 20 14:50:48 2019 +0000
@@ -1,3 +1,5 @@
+#include <stdint.h>
+
 #include "base64.h"
 #include "log.h"
 #include "bignum.h"
@@ -16,15 +18,15 @@
       otherPrimeInfos   OtherPrimeInfos OPTIONAL
 */
 
-char v   [  4]; //version
-char n   [128]; //modulus
-char e   [  4]; //publicExponent
-char d   [128]; //privateExponent
-char p   [ 64]; //prime1
-char q   [ 64]; //prime2
-char dp  [ 64]; //exponent1 -- d mod (p-1)
-char dq  [ 64]; //exponent2 -- d mod (q-1)
-char invq[ 64]; //coefficient -- (inverse of q) mod p
+uint8_t v   [  4]; //version
+uint8_t n   [128]; //modulus
+uint8_t e   [  4]; //publicExponent
+uint8_t d   [128]; //privateExponent
+uint8_t p   [ 64]; //prime1
+uint8_t q   [ 64]; //prime2
+uint8_t dp  [ 64]; //exponent1 -- d mod (p-1)
+uint8_t dq  [ 64]; //exponent2 -- d mod (q-1)
+uint8_t invq[ 64]; //coefficient -- (inverse of q) mod p
 
 static const char* pNext;
 static const char* buffer = 
@@ -62,7 +64,7 @@
     int len = readLength();
     return len;
 }
-static int readData(char* data, int size) //Reads the data from big-endian 'pem' format into little-endian 'bn' format
+static int readData(uint8_t* data, int size) //Reads the data from big-endian 'pem' format into little-endian 'bn' format
 {
     int c = Base64ReadByte();
     if (c ==   -1) return -1;            //EOF or an error
@@ -118,10 +120,10 @@
     LogBytesAsHex(  dq, sizeof(  dq)); Log("\n\n");
     LogBytesAsHex(invq, sizeof(invq)); Log("\n\n");
 }
-int PriKeyDecryptStart(char* message) //return the slot number for the decryption
+int PriKeyDecryptStart(uint8_t* message) //return the slot number for the decryption
 {
     //Convert message to big number (little endian) format prior to decryption
-    char leMessage[128];
+    uint8_t leMessage[128];
     for (int i = 0; i < 128; i++) leMessage[127 - i] = message[i];
     return BnExpModStart((uint32_t*)leMessage, (uint32_t*)d, (uint32_t*)n);
 }
@@ -129,9 +131,9 @@
 {
     return BnExpModStatus[slot] == BIGNUM_CALC_FINISHED;
 }
-char* PriKeyDecryptGetResult(int slot)
+uint8_t* PriKeyDecryptGetResult(int slot)
 {
-    return (char*) BnExpModGetResult(slot);
+    return (uint8_t*) BnExpModGetResult(slot);
 }
 void PriKeyDecryptClear(int slot)
 {