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

Method build

extra/yassl/src/yassl_imp.cpp:78–100  ·  view source on GitHub ↗

build/set PreMaster secret and encrypt, client side

Source from the content-addressed store, hash-verified

76
77// build/set PreMaster secret and encrypt, client side
78void EncryptedPreMasterSecret::build(SSL& ssl)
79{
80 opaque tmp[SECRET_LEN];
81 memset(tmp, 0, sizeof(tmp));
82 ssl.getCrypto().get_random().Fill(tmp, SECRET_LEN);
83 ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;
84 tmp[0] = pv.major_;
85 tmp[1] = pv.minor_;
86 ssl.set_preMaster(tmp, SECRET_LEN);
87
88 const CertManager& cert = ssl.getCrypto().get_certManager();
89 RSA rsa(cert.get_peerKey(), cert.get_peerKeyLength());
90 bool tls = ssl.isTLS(); // if TLS, put length for encrypted data
91 alloc(rsa.get_cipherLength() + (tls ? 2 : 0));
92 byte* holder = secret_;
93 if (tls) {
94 byte len[2];
95 c16toa(rsa.get_cipherLength(), len);
96 memcpy(secret_, len, sizeof(len));
97 holder += 2;
98 }
99 rsa.encrypt(holder, tmp, SECRET_LEN, ssl.getCrypto().get_random());
100}
101
102
103// build/set premaster and Client Public key, client side

Callers 2

sendClientKeyExchangeFunction · 0.45
sendServerKeyExchangeFunction · 0.45

Calls 15

c16toaFunction · 0.85
DSSClass · 0.85
EncodeDSA_SignatureFunction · 0.85
FillMethod · 0.80
get_randomMethod · 0.80
set_preMasterMethod · 0.80
get_peerKeyMethod · 0.80
get_peerKeyLengthMethod · 0.80
isTLSMethod · 0.80
get_cipherLengthMethod · 0.80
get_agreedKeyLengthMethod · 0.80
makeAgreementMethod · 0.80

Tested by

no test coverage detected