Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
SslFingerprints.h
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/anakod/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * SslFingerprints.h
8  *
9  ****/
10 
11 #ifndef _SMING_CORE_NETWORK_SSL_SSL_FINGERPRINTS_H_
12 #define _SMING_CORE_NETWORK_SSL_SSL_FINGERPRINTS_H_
13 
14 #include "ssl/ssl.h"
15 
19 enum SslFingerprintType {
26  eSFT_CertSha1 = 0,
27 
34  eSFT_PkSha256,
35 };
36 
46  const uint8_t* certSha1 = nullptr;
47  const uint8_t* pkSha256 = nullptr;
48 
50  {
51  free();
52  }
53 
54  void free();
55 
61  bool setSha1(const uint8_t* cert, unsigned length)
62  {
63  return setValue(certSha1, SHA1_SIZE, cert, length);
64  }
65 
67  bool setSha1_P(const uint8_t* cert, unsigned length)
68  {
69  return setValue(certSha1, SHA1_SIZE, cert, length);
70  }
71 
77  bool setSha256(const uint8_t* cert, unsigned length)
78  {
79  return setValue(pkSha256, SHA256_SIZE, cert, length);
80  }
81 
83  bool setSha256_P(const uint8_t* cert, unsigned length)
84  {
85  return setValue(pkSha256, SHA256_SIZE, cert, length);
86  }
87 
90 
93 
94 private:
102  bool setValue(const uint8_t*& value, unsigned requiredLength, const uint8_t* newValue, unsigned newLength);
103 };
104 
105 #endif // _SMING_CORE_NETWORK_SSL_SSL_FINGERPRINTS_H_
SslFingerprints & operator=(SslFingerprints &source)
Moves values out of source.
bool setSha1_P(const uint8_t *cert, unsigned length)
Make copy of SHA1 certificate from data stored in flash.
Definition: SslFingerprints.h:67
bool setSha256(const uint8_t *cert, unsigned length)
Set the SHA256 fingerprint.
Definition: SslFingerprints.h:77
bool setSha1(const uint8_t *cert, unsigned length)
Set the SHA1 fingerprint.
Definition: SslFingerprints.h:61
bool setSha256_P(const uint8_t *cert, unsigned length)
Make copy of SHA256 certificate from data stored in flash.
Definition: SslFingerprints.h:83
const uint8_t * certSha1
certificate SHA1 fingerprint
Definition: SslFingerprints.h:46
const uint8_t * pkSha256
public key SHA256 fingerprint
Definition: SslFingerprints.h:47
Contains SSL fingerprint data.
Definition: SslFingerprints.h:45