8 #include <botan/internal/tls_messages.h>
9 #include <botan/internal/tls_reader.h>
10 #include <botan/pubkey.h>
12 #include <botan/rsa.h>
13 #include <botan/dsa.h>
14 #include <botan/loadstor.h>
41 params.push_back(rsa_pub->
get_n());
42 params.push_back(rsa_pub->
get_e());
48 std::string padding =
"";
52 padding =
"EMSA3(TLS.Digest.0)";
55 padding =
"EMSA1(SHA-1)";
60 " is invalid/unknown for TLS signatures");
62 PK_Signer signer(*priv_key, padding, format);
64 signer.update(c_random);
65 signer.update(s_random);
66 signer.update(serialize_params());
67 signature = signer.signature(rng);
85 SecureVector<byte> Server_Key_Exchange::serialize_params()
const
87 SecureVector<byte> buf;
89 for(
size_t i = 0; i != params.size(); ++i)
98 void Server_Key_Exchange::deserialize(
const MemoryRegion<byte>& buf)
101 throw Decoding_Error(
"Server_Key_Exchange: Packet corrupted");
103 SecureVector<byte> values[4];
106 for(
size_t i = 0; i != 4; ++i)
111 if(len + so_far > buf.size())
112 throw Decoding_Error(
"Server_Key_Exchange: Packet corrupted");
114 values[i].resize(len);
115 copy_mem(&values[i][0], &buf[so_far], len);
118 if(i == 2 && so_far == buf.size())
127 signature = values[3];
130 signature = values[2];
138 if(params.size() == 2)
140 else if(params.size() == 3)
156 std::string padding =
"";
160 padding =
"EMSA3(TLS.Digest.0)";
163 padding =
"EMSA1(SHA-1)";
168 " is invalid/unknown for TLS signatures");
173 verifier.update(c_random);
174 verifier.update(s_random);
175 verifier.update(params_got);
177 return verifier.check_signature(signature);
void append_tls_length_value(MemoryRegion< byte > &buf, const T *vals, size_t vals_size, size_t tag_size)
void send(Record_Writer &, HandshakeHash &) const
const BigInt & get_e() const
virtual std::string algo_name() const =0
std::invalid_argument Invalid_Argument
const BigInt & get_p() const
static SecureVector< byte > encode(const BigInt &n, Base base=Binary)
bool verify(const X509_Certificate &, const MemoryRegion< byte > &, const MemoryRegion< byte > &) const
MemoryVector< byte > public_value() const
RandomNumberGenerator * rng
const BigInt & get_g() const
const DL_Group & get_domain() const
void copy_mem(T *out, const T *in, size_t n)
Server_Key_Exchange(RandomNumberGenerator &rng, Record_Writer &, const Public_Key *, const Private_Key *, const MemoryRegion< byte > &, const MemoryRegion< byte > &, HandshakeHash &)
u16bit make_u16bit(byte i0, byte i1)
static BigInt decode(const byte buf[], size_t length, Base base=Binary)
const BigInt & get_n() const
Public_Key * subject_public_key() const