Botan 3.11.0
Crypto and TLS for C&
msg_cert_verify_12.cpp
Go to the documentation of this file.
1/*
2* Certificate Verify Message
3* (C) 2004,2006,2011,2012 Jack Lloyd
4* 2017 Harry Reimann, Rohde & Schwarz Cybersecurity
5*
6* Botan is released under the Simplified BSD License (see license.txt)
7*/
8
9#include <botan/tls_messages_12.h>
10
11#include <botan/assert.h>
12#include <botan/tls_callbacks.h>
13#include <botan/tls_policy.h>
14#include <botan/x509cert.h>
15#include <botan/internal/target_info.h>
16#include <botan/internal/tls_handshake_state.h>
17
18namespace Botan::TLS {
19
20/*
21* Create a new Certificate Verify message for TLS 1.2
22*/
24 Handshake_State& state,
25 const Policy& policy,
27 const Private_Key* priv_key) {
28 BOTAN_ASSERT_NONNULL(priv_key);
29
30 const std::pair<std::string, Signature_Format> format = state.choose_sig_format(*priv_key, m_scheme, true, policy);
31
33 state.callbacks().tls_sign_message(*priv_key, rng, format.first, format.second, state.hash().get_contents());
34
35 state.hash().update(io.send(*this));
36}
37
39 const Handshake_State& state,
40 const Policy& policy) const {
41 auto key = cert.subject_public_key();
42
43 policy.check_peer_key_acceptable(*key);
44
45 const std::pair<std::string, Signature_Format> format =
46 state.parse_sig_format(*key, m_scheme, state.client_hello()->signature_schemes(), true, policy);
47
48 const bool signature_valid =
49 state.callbacks().tls_verify_message(*key, format.first, format.second, state.hash().get_contents(), m_signature);
50
51#if defined(BOTAN_UNSAFE_FUZZER_MODE)
52 BOTAN_UNUSED(signature_valid);
53 return true;
54
55#else
56 return signature_valid;
57
58#endif
59}
60
61} // namespace Botan::TLS
#define BOTAN_UNUSED
Definition assert.h:144
#define BOTAN_ASSERT_NONNULL(ptr)
Definition assert.h:114
virtual std::vector< uint8_t > tls_sign_message(const Private_Key &key, RandomNumberGenerator &rng, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg)
virtual bool tls_verify_message(const Public_Key &key, std::string_view padding, Signature_Format format, const std::vector< uint8_t > &msg, const std::vector< uint8_t > &sig)
bool verify(const X509_Certificate &cert, const Handshake_State &state, const Policy &policy) const
Certificate_Verify_12(Handshake_IO &io, Handshake_State &state, const Policy &policy, RandomNumberGenerator &rng, const Private_Key *key)
std::vector< uint8_t > m_signature
const std::vector< uint8_t > & get_contents() const
void update(const uint8_t in[], size_t length)
virtual std::vector< uint8_t > send(const Handshake_Message &msg)=0
std::pair< std::string, Signature_Format > parse_sig_format(const Public_Key &key, Signature_Scheme scheme, const std::vector< Signature_Scheme > &offered_schemes, bool for_client_auth, const Policy &policy) const
void client_hello(std::unique_ptr< Client_Hello_12 > client_hello)
std::pair< std::string, Signature_Format > choose_sig_format(const Private_Key &key, Signature_Scheme &scheme, bool for_client_auth, const Policy &policy) const
virtual void check_peer_key_acceptable(const Public_Key &public_key) const
std::unique_ptr< Public_Key > subject_public_key() const
Definition x509cert.cpp:622