Fingerprints.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Fingerprints.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include <Crypto/Sha1.h>
14 #include <Crypto/Sha2.h>
15 #include <BitManipulations.h>
16 
17 namespace Ssl
18 {
27 union Fingerprint {
31  enum class Type {
32  CertSha1,
33  CertSha256,
34  PkiSha256,
35  };
39  class Types
40  {
41  public:
42  void add(Type type)
43  {
44  bitSet(mask, type);
45  }
46 
47  void remove(Type type)
48  {
49  bitClear(mask, type);
50  }
51 
52  bool contains(Type type) const
53  {
54  return bitRead(mask, type);
55  }
56 
57  private:
58  uint32_t mask = 0;
59  };
60 
64  union Cert {
74  struct Sha1 {
75  static constexpr Type type = Type::CertSha1;
77  };
79 
84  struct Sha256 {
85  static constexpr Type type = Type::CertSha256;
87  };
89  };
91 
95  union Pki {
105  struct Sha256 {
106  static constexpr Type type = Type::PkiSha256;
108  };
110  };
112 };
113 
114 } // namespace Ssl
Fingerprint based on the SHA256 value of the Public Key Subject in the certificate.
Definition: Fingerprints.h:105
Definition: Fingerprints.h:95
Definition: Alert.h:15
bool contains(Type type) const
Definition: Fingerprints.h:52
Various types of fingerprint.
Definition: Fingerprints.h:27
ByteArray< Engine::hashsize > Hash
Definition: HashContext.h:26
Sha1 sha1
Definition: Fingerprints.h:78
Cert cert
Definition: Fingerprints.h:90
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:107
Fingerprint based on the SHA256 value of the certificate.
Definition: Fingerprints.h:84
Type
SSL Certificate fingerprint type.
Definition: Fingerprints.h:31
Pki pki
Definition: Fingerprints.h:111
Crypto::Sha1::Hash hash
Definition: Fingerprints.h:76
Maintains a set of fingerprint types.
Definition: Fingerprints.h:39
Sha256 sha256
Definition: Fingerprints.h:109
SHA256 Fingerprint of entire certificate.
void add(Type type)
Definition: Fingerprints.h:42
Sha256 sha256
Definition: Fingerprints.h:88
SHA1 Fingerprint of entire certificate.
SHA256 Fingerprint of Public Key Information.
#define bitRead(value, bit)
Definition: BitManipulations.h:18
Fingerprint based on the SHA1 value of the certificate.
Definition: Fingerprints.h:74
Fingerprints for the entire Certificate.
Definition: Fingerprints.h:64
#define bitClear(value, bit)
Definition: BitManipulations.h:20
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:86
#define bitSet(value, bit)
Definition: BitManipulations.h:19