SSP21-CPP
ICertificateHandler.h
1 
2 #ifndef SSP21_ICERTIFICATEHANDLER_H
3 #define SSP21_ICERTIFICATEHANDLER_H
4 
5 #include "ser4cpp/util/Uncopyable.h"
6 
7 #include "ssp21/crypto/gen/HandshakeError.h"
8 #include "ssp21/crypto/gen/HandshakeMode.h"
9 #include "ssp21/crypto/BufferTypes.h"
10 
11 #include "ssp21/util/SequenceTypes.h"
12 #include "ssp21/util/ICollection.h"
13 #include "ssp21/util/SecureDynamicBuffer.h"
14 
15 #include <memory>
16 
17 namespace ssp21
18 {
19 
20  /**
21  * Interface used to verify certificate data.
22  *
23  * Implementations could be for preshared public keys or retrieved from a certificate chain
24  * authenticated by a trust anchor.
25  */
27  {
28  public:
29 
30  virtual ~ICertificateHandler() {}
31 
32  /**
33  * The certificate data to present to the other party during the handshake
34  */
35  virtual seq32_t certificate_data() const = 0;
36 
37  /**
38  * Initiator side mode query
39  */
40  virtual HandshakeMode mode() const = 0;
41 
42  /**
43  * Given a particular certificate mode, validate the certificate data payload, and return a seq_t pointing to the validated public key
44  */
45  virtual HandshakeError validate(HandshakeMode mode, const seq32_t& certificate_data, seq32_t& public_key_output) = 0;
46 
47  /**
48  * Given a particular certificate mode, validate the certificate data payload, and return a seq_t pointing to the validated public key
49  */
51  {
52  return this->validate(this->mode(), certificate_data, public_key_output);
53  }
54 
55  // ---- factory functions for various implementations ----
56 
57  static std::shared_ptr<ICertificateHandler> preshared_key(const std::shared_ptr<const PublicKey>& remote_static_public_key);
58 
59  static std::shared_ptr<ICertificateHandler> certificates(
60  const std::shared_ptr<ssp21::SecureDynamicBuffer>& anchor_cert_file_data,
61  const std::shared_ptr<ssp21::SecureDynamicBuffer>& presented_chain_file_data
62  );
63 
64  };
65 
66 
67 
68 }
69 
70 #endif
SSP21-cpp main namespace.
Definition: BufferTypes.h:12
HandshakeError validate(const seq32_t &certificate_data, seq32_t &public_key_output)
virtual HandshakeError validate(HandshakeMode mode, const seq32_t &certificate_data, seq32_t &public_key_output)=0
virtual seq32_t certificate_data() const =0
virtual HandshakeMode mode() const =0