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  };
78  Sha1 sha1;
79 
84  struct Sha256 {
85  static constexpr Type type = Type::CertSha256;
87  };
88  Sha256 sha256;
89  };
91 
95  union Pki {
105  struct Sha256 {
106  static constexpr Type type = Type::PkiSha256;
108  };
109  Sha256 sha256;
110  };
112 };
113 
114 } // namespace Ssl
#define bitClear(value, bit)
Definition: BitManipulations.h:20
Fingerprint based on the SHA256 value of the certificate.
Definition: Fingerprints.h:100
#define bitRead(value, bit)
Definition: BitManipulations.h:18
Sha256 sha256
Definition: Fingerprints.h:104
Pki pki
Definition: Fingerprints.h:127
HashContext< Sha1Engine > Sha1
Definition: Sha1.h:30
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:102
Sha256 sha256
Definition: Fingerprints.h:125
@ PkiSha256
SHA256 Fingerprint of Public Key Information.
@ CertSha256
SHA256 Fingerprint of entire certificate.
Definition: Fingerprints.h:111
static constexpr Type type
Definition: Fingerprints.h:101
Crypto::Sha1::Hash hash
Definition: Fingerprints.h:92
bool contains(Type type) const
Definition: Fingerprints.h:68
Cert cert
Definition: Fingerprints.h:106
void add(Type type)
Definition: Fingerprints.h:58
ByteArray< Engine::hashsize > Hash
Definition: HashContext.h:42
Crypto::Sha256::Hash hash
Definition: Fingerprints.h:123
HashContext< Sha256Engine > Sha256
Definition: Sha2.h:38
@ CertSha1
SHA1 Fingerprint of entire certificate.
#define bitSet(value, bit)
Definition: BitManipulations.h:19
Type
SSL Certificate fingerprint type.
Definition: Fingerprints.h:47
Sha1 sha1
Definition: Fingerprints.h:94
Fingerprints for the entire Certificate.
Definition: Fingerprints.h:80
static constexpr Type type
Definition: Fingerprints.h:122
void remove(Type type)
Definition: Fingerprints.h:63
Definition: Alert.h:15
static constexpr Type type
Definition: Fingerprints.h:91