MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / read

Method read

extra/yassl/src/yassl_imp.cpp:221–255  ·  view source on GitHub ↗

read PreMaster secret and decrypt, server side

Source from the content-addressed store, hash-verified

219
220// read PreMaster secret and decrypt, server side
221void EncryptedPreMasterSecret::read(SSL& ssl, input_buffer& input)
222{
223 if (input.get_error()) {
224 ssl.SetError(bad_input);
225 return;
226 }
227
228 const CertManager& cert = ssl.getCrypto().get_certManager();
229 RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false);
230 uint16 cipherLen = rsa.get_cipherLength();
231 if (ssl.isTLS()) {
232 byte len[2];
233 len[0] = input[AUTO];
234 len[1] = input[AUTO];
235 ato16(len, cipherLen);
236 }
237 alloc(cipherLen);
238 input.read(secret_, length_);
239 if (input.get_error()) {
240 ssl.SetError(bad_input);
241 return;
242 }
243
244 opaque preMasterSecret[SECRET_LEN];
245 memset(preMasterSecret, 0, sizeof(preMasterSecret));
246 rsa.decrypt(preMasterSecret, secret_, length_,
247 ssl.getCrypto().get_random());
248
249 ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;
250 if (pv.major_ != preMasterSecret[0] || pv.minor_ != preMasterSecret[1])
251 ssl.SetError(pms_version_error); // continue deriving for timing attack
252
253 ssl.set_preMaster(preMasterSecret, SECRET_LEN);
254 ssl.makeMasterSecret();
255}
256
257
258EncryptedPreMasterSecret::EncryptedPreMasterSecret()

Callers 2

ProcessMethod · 0.45
yassl_imp.cppFile · 0.45

Calls 15

ato16Function · 0.85
DecodeDSA_SignatureFunction · 0.85
DiffieHellmanClass · 0.85
get_errorMethod · 0.80
get_privateKeyMethod · 0.80
get_privateKeyLengthMethod · 0.80
get_cipherLengthMethod · 0.80
isTLSMethod · 0.80
get_randomMethod · 0.80
set_preMasterMethod · 0.80
makeMasterSecretMethod · 0.80
get_remainingMethod · 0.80

Tested by

no test coverage detected