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
#define bitSet(value, bit)
Definition: BitManipulations.h:19
#define bitClear(value, bit)
Definition: BitManipulations.h:20
#define bitRead(value, bit)
Definition: BitManipulations.h:18
ByteArray< Engine::hashsize > Hash
Definition: HashContext.h:26
Maintains a set of fingerprint types.
Definition: Fingerprints.h:40
bool contains(Type type) const
Definition: Fingerprints.h:52
void remove(Type type)
Definition: Fingerprints.h:47
void add(Type type)
Definition: Fingerprints.h:42
Definition: Alert.h:16
Fingerprint based on the SHA1 value of the certificate.
Definition: Fingerprints.h:74
Crypto::Sha1::Hash hash
Definition: Fingerprints.h:76
static constexpr Type type
Definition: Fingerprints.h:75
Fingerprint based on the SHA256 value of the certificate.
Definition: Fingerprints.h:84
static constexpr Type type
Definition: Fingerprints.h:85
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:86
Fingerprint based on the SHA256 value of the Public Key Subject in the certificate.
Definition: Fingerprints.h:105
static constexpr Type type
Definition: Fingerprints.h:106
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:107
Fingerprints for the entire Certificate.
Definition: Fingerprints.h:64
Sha256 sha256
Definition: Fingerprints.h:88
Sha1 sha1
Definition: Fingerprints.h:78
Definition: Fingerprints.h:95
Sha256 sha256
Definition: Fingerprints.h:109
Various types of fingerprint.
Definition: Fingerprints.h:27
Pki pki
Definition: Fingerprints.h:111
Type
SSL Certificate fingerprint type.
Definition: Fingerprints.h:31
@ CertSha256
SHA256 Fingerprint of entire certificate.
@ CertSha1
SHA1 Fingerprint of entire certificate.
@ PkiSha256
SHA256 Fingerprint of Public Key Information.
Cert cert
Definition: Fingerprints.h:90