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

Function ProcessOldClientHello

extra/yassl/src/handshake.cpp:523–594  ·  view source on GitHub ↗

some clients still send sslv2 client hello

Source from the content-addressed store, hash-verified

521
522// some clients still send sslv2 client hello
523void ProcessOldClientHello(input_buffer& input, SSL& ssl)
524{
525 if (input.get_error() || input.get_remaining() < 2) {
526 ssl.SetError(bad_input);
527 return;
528 }
529 byte b0 = input[AUTO];
530 byte b1 = input[AUTO];
531
532 uint16 sz = ((b0 & 0x7f) << 8) | b1;
533
534 if (sz > input.get_remaining()) {
535 ssl.SetError(bad_input);
536 return;
537 }
538
539 // hashHandShake manually
540 const opaque* buffer = input.get_buffer() + input.get_current();
541 ssl.useHashes().use_MD5().update(buffer, sz);
542 ssl.useHashes().use_SHA().update(buffer, sz);
543
544 b1 = input[AUTO]; // does this value mean client_hello?
545
546 ClientHello ch;
547 ch.client_version_.major_ = input[AUTO];
548 ch.client_version_.minor_ = input[AUTO];
549
550 byte len[2];
551
552 len[0] = input[AUTO];
553 len[1] = input[AUTO];
554 ato16(len, ch.suite_len_);
555
556 len[0] = input[AUTO];
557 len[1] = input[AUTO];
558 uint16 sessionLen;
559 ato16(len, sessionLen);
560 ch.id_len_ = sessionLen;
561
562 len[0] = input[AUTO];
563 len[1] = input[AUTO];
564 uint16 randomLen;
565 ato16(len, randomLen);
566
567 if (input.get_error() || ch.suite_len_ > MAX_SUITE_SZ ||
568 ch.suite_len_ > input.get_remaining() ||
569 sessionLen > ID_LEN || randomLen > RAN_LEN) {
570 ssl.SetError(bad_input);
571 return;
572 }
573
574 int j = 0;
575 for (uint16 i = 0; i < ch.suite_len_; i += 3) {
576 byte first = input[AUTO];
577 if (first) // sslv2 type
578 input.read(len, SUITE_LEN); // skip
579 else {
580 input.read(&ch.cipher_suites_[j], SUITE_LEN);

Callers 1

DoProcessReplyFunction · 0.85

Calls 9

ato16Function · 0.85
get_errorMethod · 0.80
get_remainingMethod · 0.80
SetErrorMethod · 0.45
get_bufferMethod · 0.45
get_currentMethod · 0.45
updateMethod · 0.45
readMethod · 0.45
ProcessMethod · 0.45

Tested by

no test coverage detected