Build a client hello message from cipher suites and compression method
| 34 | |
| 35 | // Build a client hello message from cipher suites and compression method |
| 36 | void buildClientHello(SSL& ssl, ClientHello& hello) |
| 37 | { |
| 38 | // store for pre master secret |
| 39 | ssl.useSecurity().use_connection().chVersion_ = hello.client_version_; |
| 40 | |
| 41 | ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN); |
| 42 | if (ssl.getSecurity().get_resuming()) { |
| 43 | hello.id_len_ = ID_LEN; |
| 44 | memcpy(hello.session_id_, ssl.getSecurity().get_resume().GetID(), |
| 45 | ID_LEN); |
| 46 | } |
| 47 | else |
| 48 | hello.id_len_ = 0; |
| 49 | hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_; |
| 50 | memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_, |
| 51 | hello.suite_len_); |
| 52 | hello.comp_len_ = 1; |
| 53 | |
| 54 | hello.set_length(sizeof(ProtocolVersion) + |
| 55 | RAN_LEN + |
| 56 | hello.id_len_ + sizeof(hello.id_len_) + |
| 57 | hello.suite_len_ + sizeof(hello.suite_len_) + |
| 58 | hello.comp_len_ + sizeof(hello.comp_len_)); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | // Build a server hello message |
no test coverage detected