Lines Matching refs:s
18 static int ssl3_generate_key_block(SSL_CONNECTION *s, unsigned char *km, int num) in ssl3_generate_key_block() argument
27 SSL_CTX *sctx = SSL_CONNECTION_GET_CTX(s); in ssl3_generate_key_block()
38 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB); in ssl3_generate_key_block()
45 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_generate_key_block()
53 || !EVP_DigestUpdate(s1, s->session->master_key, in ssl3_generate_key_block()
54 s->session->master_key_length) in ssl3_generate_key_block()
55 || !EVP_DigestUpdate(s1, s->s3.server_random, SSL3_RANDOM_SIZE) in ssl3_generate_key_block()
56 || !EVP_DigestUpdate(s1, s->s3.client_random, SSL3_RANDOM_SIZE) in ssl3_generate_key_block()
59 || !EVP_DigestUpdate(m5, s->session->master_key, in ssl3_generate_key_block()
60 s->session->master_key_length) in ssl3_generate_key_block()
62 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_generate_key_block()
67 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_generate_key_block()
73 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_generate_key_block()
90 int ssl3_change_cipher_state(SSL_CONNECTION *s, int which) in ssl3_change_cipher_state() argument
103 ciph = s->s3.tmp.new_sym_enc; in ssl3_change_cipher_state()
104 md = s->s3.tmp.new_hash; in ssl3_change_cipher_state()
107 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_change_cipher_state()
111 comp = s->s3.tmp.new_compression; in ssl3_change_cipher_state()
114 p = s->s3.tmp.key_block; in ssl3_change_cipher_state()
117 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_change_cipher_state()
142 if (n > s->s3.tmp.key_block_length) { in ssl3_change_cipher_state()
143 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_change_cipher_state()
147 if (!ssl_set_new_record_layer(s, SSL3_VERSION, in ssl3_change_cipher_state()
161 int ssl3_setup_key_block(SSL_CONNECTION *s) in ssl3_setup_key_block() argument
170 if (s->s3.tmp.key_block_length != 0) in ssl3_setup_key_block()
173 if (!ssl_cipher_get_evp(SSL_CONNECTION_GET_CTX(s), s->session, &c, &hash, in ssl3_setup_key_block()
176 SSLfatal_alert(s, SSL_AD_INTERNAL_ERROR); in ssl3_setup_key_block()
180 ssl_evp_cipher_free(s->s3.tmp.new_sym_enc); in ssl3_setup_key_block()
181 s->s3.tmp.new_sym_enc = c; in ssl3_setup_key_block()
182 ssl_evp_md_free(s->s3.tmp.new_hash); in ssl3_setup_key_block()
183 s->s3.tmp.new_hash = hash; in ssl3_setup_key_block()
185 s->s3.tmp.new_compression = NULL; in ssl3_setup_key_block()
187 s->s3.tmp.new_compression = comp; in ssl3_setup_key_block()
197 ssl3_cleanup_key_block(s); in ssl3_setup_key_block()
200 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_CRYPTO_LIB); in ssl3_setup_key_block()
204 s->s3.tmp.key_block_length = num; in ssl3_setup_key_block()
205 s->s3.tmp.key_block = p; in ssl3_setup_key_block()
208 ret = ssl3_generate_key_block(s, p, num); in ssl3_setup_key_block()
213 void ssl3_cleanup_key_block(SSL_CONNECTION *s) in ssl3_cleanup_key_block() argument
215 OPENSSL_clear_free(s->s3.tmp.key_block, s->s3.tmp.key_block_length); in ssl3_cleanup_key_block()
216 s->s3.tmp.key_block = NULL; in ssl3_cleanup_key_block()
217 s->s3.tmp.key_block_length = 0; in ssl3_cleanup_key_block()
220 int ssl3_init_finished_mac(SSL_CONNECTION *s) in ssl3_init_finished_mac() argument
225 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_BIO_LIB); in ssl3_init_finished_mac()
228 ssl3_free_digest_list(s); in ssl3_init_finished_mac()
229 s->s3.handshake_buffer = buf; in ssl3_init_finished_mac()
230 (void)BIO_set_close(s->s3.handshake_buffer, BIO_CLOSE); in ssl3_init_finished_mac()
239 void ssl3_free_digest_list(SSL_CONNECTION *s) in ssl3_free_digest_list() argument
241 BIO_free(s->s3.handshake_buffer); in ssl3_free_digest_list()
242 s->s3.handshake_buffer = NULL; in ssl3_free_digest_list()
243 EVP_MD_CTX_free(s->s3.handshake_dgst); in ssl3_free_digest_list()
244 s->s3.handshake_dgst = NULL; in ssl3_free_digest_list()
247 int ssl3_finish_mac(SSL_CONNECTION *s, const unsigned char *buf, size_t len) in ssl3_finish_mac() argument
251 if (s->s3.handshake_dgst == NULL) { in ssl3_finish_mac()
254 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_OVERFLOW_ERROR); in ssl3_finish_mac()
257 ret = BIO_write(s->s3.handshake_buffer, (void *)buf, (int)len); in ssl3_finish_mac()
259 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_finish_mac()
263 ret = EVP_DigestUpdate(s->s3.handshake_dgst, buf, len); in ssl3_finish_mac()
265 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_finish_mac()
272 int ssl3_digest_cached_records(SSL_CONNECTION *s, int keep) in ssl3_digest_cached_records() argument
278 if (s->s3.handshake_dgst == NULL) { in ssl3_digest_cached_records()
279 hdatalen = BIO_get_mem_data(s->s3.handshake_buffer, &hdata); in ssl3_digest_cached_records()
281 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_BAD_HANDSHAKE_LENGTH); in ssl3_digest_cached_records()
285 s->s3.handshake_dgst = EVP_MD_CTX_new(); in ssl3_digest_cached_records()
286 if (s->s3.handshake_dgst == NULL) { in ssl3_digest_cached_records()
287 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB); in ssl3_digest_cached_records()
291 md = ssl_handshake_md(s); in ssl3_digest_cached_records()
293 SSLfatal(s, SSL_AD_INTERNAL_ERROR, in ssl3_digest_cached_records()
297 if (!EVP_DigestInit_ex(s->s3.handshake_dgst, md, NULL) in ssl3_digest_cached_records()
298 || !EVP_DigestUpdate(s->s3.handshake_dgst, hdata, hdatalen)) { in ssl3_digest_cached_records()
299 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_digest_cached_records()
304 BIO_free(s->s3.handshake_buffer); in ssl3_digest_cached_records()
305 s->s3.handshake_buffer = NULL; in ssl3_digest_cached_records()
321 size_t ssl3_final_finish_mac(SSL_CONNECTION *s, const char *sender, size_t len, in ssl3_final_finish_mac() argument
327 if (!ssl3_digest_cached_records(s, 0)) { in ssl3_final_finish_mac()
332 if (EVP_MD_CTX_get_type(s->s3.handshake_dgst) != NID_md5_sha1) { in ssl3_final_finish_mac()
333 SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_R_NO_REQUIRED_DIGEST); in ssl3_final_finish_mac()
339 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB); in ssl3_final_finish_mac()
342 if (!EVP_MD_CTX_copy_ex(ctx, s->s3.handshake_dgst)) { in ssl3_final_finish_mac()
343 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_final_finish_mac()
350 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_final_finish_mac()
358 ssl3_digest_master_key_set_params(s->session, digest_cmd_params); in ssl3_final_finish_mac()
363 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_final_finish_mac()
374 int ssl3_generate_master_secret(SSL_CONNECTION *s, unsigned char *out, in ssl3_generate_master_secret() argument
396 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_EVP_LIB); in ssl3_generate_master_secret()
400 if (EVP_DigestInit_ex(ctx, SSL_CONNECTION_GET_CTX(s)->sha1, NULL) <= 0 in ssl3_generate_master_secret()
404 || EVP_DigestUpdate(ctx, &(s->s3.client_random[0]), in ssl3_generate_master_secret()
406 || EVP_DigestUpdate(ctx, &(s->s3.server_random[0]), in ssl3_generate_master_secret()
409 || EVP_DigestInit_ex(ctx, SSL_CONNECTION_GET_CTX(s)->md5, NULL) <= 0 in ssl3_generate_master_secret()
413 SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); in ssl3_generate_master_secret()