A simple library to support serving https.

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Thu Jul 25 21:16:24 2019 +0000
Revision:
0:be515c9019e3
Child:
4:6a1d887f1cad
Pulled together existing modules from https and big numbers into this one. Added TLS PRF module.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:be515c9019e3 1 #include "base64.h"
andrewboyson 0:be515c9019e3 2 #include "log.h"
andrewboyson 0:be515c9019e3 3
andrewboyson 0:be515c9019e3 4 char SerCerData[1024];
andrewboyson 0:be515c9019e3 5 int SerCerSize = 0;
andrewboyson 0:be515c9019e3 6
andrewboyson 0:be515c9019e3 7 static const char* pNext;
andrewboyson 0:be515c9019e3 8 static const char* buffer =
andrewboyson 0:be515c9019e3 9 #include "ser-cer.inc"
andrewboyson 0:be515c9019e3 10 ;
andrewboyson 0:be515c9019e3 11 static char readChar()
andrewboyson 0:be515c9019e3 12 {
andrewboyson 0:be515c9019e3 13 char c = *pNext;
andrewboyson 0:be515c9019e3 14 if (!c) return 0;
andrewboyson 0:be515c9019e3 15 pNext++;
andrewboyson 0:be515c9019e3 16 return c;
andrewboyson 0:be515c9019e3 17 }
andrewboyson 0:be515c9019e3 18 static void readData()
andrewboyson 0:be515c9019e3 19 {
andrewboyson 0:be515c9019e3 20 SerCerSize = 0;
andrewboyson 0:be515c9019e3 21 while (true)
andrewboyson 0:be515c9019e3 22 {
andrewboyson 0:be515c9019e3 23 int c = Base64ReadByte();
andrewboyson 0:be515c9019e3 24 if (c == -1) return; //EOF or an error
andrewboyson 0:be515c9019e3 25 SerCerData[SerCerSize] = c;
andrewboyson 0:be515c9019e3 26 SerCerSize++;
andrewboyson 0:be515c9019e3 27 }
andrewboyson 0:be515c9019e3 28 }
andrewboyson 0:be515c9019e3 29 void SerCerInit()
andrewboyson 0:be515c9019e3 30 {
andrewboyson 0:be515c9019e3 31
andrewboyson 0:be515c9019e3 32 pNext = buffer;
andrewboyson 0:be515c9019e3 33 Base64ReadNextCharFunctionPointer = readChar;
andrewboyson 0:be515c9019e3 34
andrewboyson 0:be515c9019e3 35 int r = Base64SkipLine();
andrewboyson 0:be515c9019e3 36 if (r < 0) return;
andrewboyson 0:be515c9019e3 37
andrewboyson 0:be515c9019e3 38 readData();
andrewboyson 0:be515c9019e3 39
andrewboyson 0:be515c9019e3 40 LogF("Server certificate content - %d bytes\r\n", SerCerSize);
andrewboyson 0:be515c9019e3 41 LogBytesAsHex(SerCerData, SerCerSize); Log("\n\n");
andrewboyson 0:be515c9019e3 42 }