diff options
| author | jsing <> | 2015-09-12 10:09:16 +0000 |
|---|---|---|
| committer | jsing <> | 2015-09-12 10:09:16 +0000 |
| commit | e44eee81e5e20f236f4bce54afb725d6ba460437 (patch) | |
| tree | 4fc8d60557b1bffab0c51ca536ed13124b548095 | |
| parent | a6fad4398c5c6f137d4e06054ff993a175e1149b (diff) | |
| download | openbsd-e44eee81e5e20f236f4bce54afb725d6ba460437.tar.gz openbsd-e44eee81e5e20f236f4bce54afb725d6ba460437.tar.bz2 openbsd-e44eee81e5e20f236f4bce54afb725d6ba460437.zip | |
style(9) and whitespace cleanups.
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/s3_clnt.c | 54 | ||||
| -rw-r--r-- | src/lib/libssl/src/ssl/s3_clnt.c | 54 |
2 files changed, 50 insertions, 58 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index eed359450f..1424641047 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s3_clnt.c,v 1.127 2015/09/11 18:08:21 jsing Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.128 2015/09/12 10:09:16 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -1965,7 +1965,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 1965 | * make sure to clear it out afterwards. | 1965 | * make sure to clear it out afterwards. |
| 1966 | */ | 1966 | */ |
| 1967 | n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); | 1967 | n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); |
| 1968 | |||
| 1969 | if (n <= 0) { | 1968 | if (n <= 0) { |
| 1970 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | 1969 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 1971 | ERR_R_DH_LIB); | 1970 | ERR_R_DH_LIB); |
| @@ -1995,7 +1994,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 1995 | EC_KEY *tkey; | 1994 | EC_KEY *tkey; |
| 1996 | int field_size = 0; | 1995 | int field_size = 0; |
| 1997 | 1996 | ||
| 1998 | |||
| 1999 | /* Ensure that we have an ephemeral key for ECDHE. */ | 1997 | /* Ensure that we have an ephemeral key for ECDHE. */ |
| 2000 | if ((alg_k & SSL_kECDHE) && | 1998 | if ((alg_k & SSL_kECDHE) && |
| 2001 | s->session->sess_cert->peer_ecdh_tmp == NULL) { | 1999 | s->session->sess_cert->peer_ecdh_tmp == NULL) { |
| @@ -2045,8 +2043,7 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2045 | 2043 | ||
| 2046 | /* Generate a new ECDH key pair */ | 2044 | /* Generate a new ECDH key pair */ |
| 2047 | if (!(EC_KEY_generate_key(clnt_ecdh))) { | 2045 | if (!(EC_KEY_generate_key(clnt_ecdh))) { |
| 2048 | SSLerr( | 2046 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 2049 | SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 2050 | ERR_R_ECDH_LIB); | 2047 | ERR_R_ECDH_LIB); |
| 2051 | goto err; | 2048 | goto err; |
| 2052 | } | 2049 | } |
| @@ -2061,7 +2058,7 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2061 | ERR_R_ECDH_LIB); | 2058 | ERR_R_ECDH_LIB); |
| 2062 | goto err; | 2059 | goto err; |
| 2063 | } | 2060 | } |
| 2064 | n = ECDH_compute_key(p, (field_size + 7)/8, | 2061 | n = ECDH_compute_key(p, (field_size + 7) / 8, |
| 2065 | srvr_ecpoint, clnt_ecdh, NULL); | 2062 | srvr_ecpoint, clnt_ecdh, NULL); |
| 2066 | if (n <= 0) { | 2063 | if (n <= 0) { |
| 2067 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | 2064 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| @@ -2070,9 +2067,9 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2070 | } | 2067 | } |
| 2071 | 2068 | ||
| 2072 | /* generate master key from the result */ | 2069 | /* generate master key from the result */ |
| 2073 | s->session->master_key_length = s->method->ssl3_enc \ | 2070 | s->session->master_key_length = |
| 2074 | -> generate_master_secret(s, | 2071 | s->method->ssl3_enc->generate_master_secret(s, |
| 2075 | s->session->master_key, p, n); | 2072 | s->session->master_key, p, n); |
| 2076 | 2073 | ||
| 2077 | memset(p, 0, n); /* clean up */ | 2074 | memset(p, 0, n); /* clean up */ |
| 2078 | 2075 | ||
| @@ -2080,19 +2077,15 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2080 | * First check the size of encoding and | 2077 | * First check the size of encoding and |
| 2081 | * allocate memory accordingly. | 2078 | * allocate memory accordingly. |
| 2082 | */ | 2079 | */ |
| 2083 | encoded_pt_len = EC_POINT_point2oct( | 2080 | encoded_pt_len = EC_POINT_point2oct(srvr_group, |
| 2084 | srvr_group, | 2081 | EC_KEY_get0_public_key(clnt_ecdh), |
| 2085 | EC_KEY_get0_public_key(clnt_ecdh), | 2082 | POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); |
| 2086 | POINT_CONVERSION_UNCOMPRESSED, | ||
| 2087 | NULL, 0, NULL); | ||
| 2088 | 2083 | ||
| 2089 | encodedPoint = malloc(encoded_pt_len); | 2084 | encodedPoint = malloc(encoded_pt_len); |
| 2090 | 2085 | ||
| 2091 | bn_ctx = BN_CTX_new(); | 2086 | bn_ctx = BN_CTX_new(); |
| 2092 | if ((encodedPoint == NULL) || | 2087 | if ((encodedPoint == NULL) || (bn_ctx == NULL)) { |
| 2093 | (bn_ctx == NULL)) { | 2088 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 2094 | SSLerr( | ||
| 2095 | SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 2096 | ERR_R_MALLOC_FAILURE); | 2089 | ERR_R_MALLOC_FAILURE); |
| 2097 | goto err; | 2090 | goto err; |
| 2098 | } | 2091 | } |
| @@ -2100,8 +2093,8 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2100 | /* Encode the public key */ | 2093 | /* Encode the public key */ |
| 2101 | n = EC_POINT_point2oct(srvr_group, | 2094 | n = EC_POINT_point2oct(srvr_group, |
| 2102 | EC_KEY_get0_public_key(clnt_ecdh), | 2095 | EC_KEY_get0_public_key(clnt_ecdh), |
| 2103 | POINT_CONVERSION_UNCOMPRESSED, | 2096 | POINT_CONVERSION_UNCOMPRESSED, encodedPoint, |
| 2104 | encodedPoint, encoded_pt_len, bn_ctx); | 2097 | encoded_pt_len, bn_ctx); |
| 2105 | 2098 | ||
| 2106 | *p = n; /* length of encoded point */ | 2099 | *p = n; /* length of encoded point */ |
| 2107 | /* Encoded point will be copied here */ | 2100 | /* Encoded point will be copied here */ |
| @@ -2141,34 +2134,36 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2141 | pkey_ctx = EVP_PKEY_CTX_new( | 2134 | pkey_ctx = EVP_PKEY_CTX_new( |
| 2142 | pub_key = X509_get_pubkey(peer_cert), | 2135 | pub_key = X509_get_pubkey(peer_cert), |
| 2143 | NULL); | 2136 | NULL); |
| 2137 | |||
| 2144 | /* | 2138 | /* |
| 2145 | * If we have send a certificate, and certificate key | 2139 | * If we have send a certificate, and certificate key |
| 2146 | * parameters match those of server certificate, use | 2140 | * parameters match those of server certificate, use |
| 2147 | * certificate key for key exchange. | 2141 | * certificate key for key exchange. |
| 2148 | * Otherwise, generate ephemeral key pair. | 2142 | * Otherwise, generate ephemeral key pair. |
| 2149 | */ | 2143 | */ |
| 2150 | |||
| 2151 | EVP_PKEY_encrypt_init(pkey_ctx); | 2144 | EVP_PKEY_encrypt_init(pkey_ctx); |
| 2145 | |||
| 2152 | /* Generate session key. */ | 2146 | /* Generate session key. */ |
| 2153 | arc4random_buf(premaster_secret, 32); | 2147 | arc4random_buf(premaster_secret, 32); |
| 2148 | |||
| 2154 | /* | 2149 | /* |
| 2155 | * If we have client certificate, use its secret | 2150 | * If we have client certificate, use its secret as |
| 2156 | * as peer key. | 2151 | * peer key. |
| 2157 | */ | 2152 | */ |
| 2158 | if (s->s3->tmp.cert_req && s->cert->key->privatekey) { | 2153 | if (s->s3->tmp.cert_req && s->cert->key->privatekey) { |
| 2159 | if (EVP_PKEY_derive_set_peer(pkey_ctx, | 2154 | if (EVP_PKEY_derive_set_peer(pkey_ctx, |
| 2160 | s->cert->key->privatekey) <=0) { | 2155 | s->cert->key->privatekey) <=0) { |
| 2161 | /* | 2156 | /* |
| 2162 | * If there was an error - | 2157 | * If there was an error - just ignore |
| 2163 | * just ignore it. Ephemeral key | 2158 | * it. Ephemeral key would be used. |
| 2164 | * would be used | ||
| 2165 | */ | 2159 | */ |
| 2166 | ERR_clear_error(); | 2160 | ERR_clear_error(); |
| 2167 | } | 2161 | } |
| 2168 | } | 2162 | } |
| 2163 | |||
| 2169 | /* | 2164 | /* |
| 2170 | * Compute shared IV and store it in algorithm-specific | 2165 | * Compute shared IV and store it in algorithm-specific |
| 2171 | * context data | 2166 | * context data. |
| 2172 | */ | 2167 | */ |
| 2173 | ukm_hash = EVP_MD_CTX_create(); | 2168 | ukm_hash = EVP_MD_CTX_create(); |
| 2174 | if (ukm_hash == NULL) { | 2169 | if (ukm_hash == NULL) { |
| @@ -2195,9 +2190,10 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2195 | SSL_R_LIBRARY_BUG); | 2190 | SSL_R_LIBRARY_BUG); |
| 2196 | goto err; | 2191 | goto err; |
| 2197 | } | 2192 | } |
| 2193 | |||
| 2198 | /* | 2194 | /* |
| 2199 | * Make GOST keytransport blob message, | 2195 | * Make GOST keytransport blob message, encapsulate it |
| 2200 | * encapsulate it into sequence. | 2196 | * into sequence. |
| 2201 | */ | 2197 | */ |
| 2202 | *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; | 2198 | *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; |
| 2203 | msglen = 255; | 2199 | msglen = 255; |
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c index eed359450f..1424641047 100644 --- a/src/lib/libssl/src/ssl/s3_clnt.c +++ b/src/lib/libssl/src/ssl/s3_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s3_clnt.c,v 1.127 2015/09/11 18:08:21 jsing Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.128 2015/09/12 10:09:16 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -1965,7 +1965,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 1965 | * make sure to clear it out afterwards. | 1965 | * make sure to clear it out afterwards. |
| 1966 | */ | 1966 | */ |
| 1967 | n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); | 1967 | n = DH_compute_key(p, dh_srvr->pub_key, dh_clnt); |
| 1968 | |||
| 1969 | if (n <= 0) { | 1968 | if (n <= 0) { |
| 1970 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | 1969 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 1971 | ERR_R_DH_LIB); | 1970 | ERR_R_DH_LIB); |
| @@ -1995,7 +1994,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 1995 | EC_KEY *tkey; | 1994 | EC_KEY *tkey; |
| 1996 | int field_size = 0; | 1995 | int field_size = 0; |
| 1997 | 1996 | ||
| 1998 | |||
| 1999 | /* Ensure that we have an ephemeral key for ECDHE. */ | 1997 | /* Ensure that we have an ephemeral key for ECDHE. */ |
| 2000 | if ((alg_k & SSL_kECDHE) && | 1998 | if ((alg_k & SSL_kECDHE) && |
| 2001 | s->session->sess_cert->peer_ecdh_tmp == NULL) { | 1999 | s->session->sess_cert->peer_ecdh_tmp == NULL) { |
| @@ -2045,8 +2043,7 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2045 | 2043 | ||
| 2046 | /* Generate a new ECDH key pair */ | 2044 | /* Generate a new ECDH key pair */ |
| 2047 | if (!(EC_KEY_generate_key(clnt_ecdh))) { | 2045 | if (!(EC_KEY_generate_key(clnt_ecdh))) { |
| 2048 | SSLerr( | 2046 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 2049 | SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 2050 | ERR_R_ECDH_LIB); | 2047 | ERR_R_ECDH_LIB); |
| 2051 | goto err; | 2048 | goto err; |
| 2052 | } | 2049 | } |
| @@ -2061,7 +2058,7 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2061 | ERR_R_ECDH_LIB); | 2058 | ERR_R_ECDH_LIB); |
| 2062 | goto err; | 2059 | goto err; |
| 2063 | } | 2060 | } |
| 2064 | n = ECDH_compute_key(p, (field_size + 7)/8, | 2061 | n = ECDH_compute_key(p, (field_size + 7) / 8, |
| 2065 | srvr_ecpoint, clnt_ecdh, NULL); | 2062 | srvr_ecpoint, clnt_ecdh, NULL); |
| 2066 | if (n <= 0) { | 2063 | if (n <= 0) { |
| 2067 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | 2064 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| @@ -2070,9 +2067,9 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2070 | } | 2067 | } |
| 2071 | 2068 | ||
| 2072 | /* generate master key from the result */ | 2069 | /* generate master key from the result */ |
| 2073 | s->session->master_key_length = s->method->ssl3_enc \ | 2070 | s->session->master_key_length = |
| 2074 | -> generate_master_secret(s, | 2071 | s->method->ssl3_enc->generate_master_secret(s, |
| 2075 | s->session->master_key, p, n); | 2072 | s->session->master_key, p, n); |
| 2076 | 2073 | ||
| 2077 | memset(p, 0, n); /* clean up */ | 2074 | memset(p, 0, n); /* clean up */ |
| 2078 | 2075 | ||
| @@ -2080,19 +2077,15 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2080 | * First check the size of encoding and | 2077 | * First check the size of encoding and |
| 2081 | * allocate memory accordingly. | 2078 | * allocate memory accordingly. |
| 2082 | */ | 2079 | */ |
| 2083 | encoded_pt_len = EC_POINT_point2oct( | 2080 | encoded_pt_len = EC_POINT_point2oct(srvr_group, |
| 2084 | srvr_group, | 2081 | EC_KEY_get0_public_key(clnt_ecdh), |
| 2085 | EC_KEY_get0_public_key(clnt_ecdh), | 2082 | POINT_CONVERSION_UNCOMPRESSED, NULL, 0, NULL); |
| 2086 | POINT_CONVERSION_UNCOMPRESSED, | ||
| 2087 | NULL, 0, NULL); | ||
| 2088 | 2083 | ||
| 2089 | encodedPoint = malloc(encoded_pt_len); | 2084 | encodedPoint = malloc(encoded_pt_len); |
| 2090 | 2085 | ||
| 2091 | bn_ctx = BN_CTX_new(); | 2086 | bn_ctx = BN_CTX_new(); |
| 2092 | if ((encodedPoint == NULL) || | 2087 | if ((encodedPoint == NULL) || (bn_ctx == NULL)) { |
| 2093 | (bn_ctx == NULL)) { | 2088 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, |
| 2094 | SSLerr( | ||
| 2095 | SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
| 2096 | ERR_R_MALLOC_FAILURE); | 2089 | ERR_R_MALLOC_FAILURE); |
| 2097 | goto err; | 2090 | goto err; |
| 2098 | } | 2091 | } |
| @@ -2100,8 +2093,8 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2100 | /* Encode the public key */ | 2093 | /* Encode the public key */ |
| 2101 | n = EC_POINT_point2oct(srvr_group, | 2094 | n = EC_POINT_point2oct(srvr_group, |
| 2102 | EC_KEY_get0_public_key(clnt_ecdh), | 2095 | EC_KEY_get0_public_key(clnt_ecdh), |
| 2103 | POINT_CONVERSION_UNCOMPRESSED, | 2096 | POINT_CONVERSION_UNCOMPRESSED, encodedPoint, |
| 2104 | encodedPoint, encoded_pt_len, bn_ctx); | 2097 | encoded_pt_len, bn_ctx); |
| 2105 | 2098 | ||
| 2106 | *p = n; /* length of encoded point */ | 2099 | *p = n; /* length of encoded point */ |
| 2107 | /* Encoded point will be copied here */ | 2100 | /* Encoded point will be copied here */ |
| @@ -2141,34 +2134,36 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2141 | pkey_ctx = EVP_PKEY_CTX_new( | 2134 | pkey_ctx = EVP_PKEY_CTX_new( |
| 2142 | pub_key = X509_get_pubkey(peer_cert), | 2135 | pub_key = X509_get_pubkey(peer_cert), |
| 2143 | NULL); | 2136 | NULL); |
| 2137 | |||
| 2144 | /* | 2138 | /* |
| 2145 | * If we have send a certificate, and certificate key | 2139 | * If we have send a certificate, and certificate key |
| 2146 | * parameters match those of server certificate, use | 2140 | * parameters match those of server certificate, use |
| 2147 | * certificate key for key exchange. | 2141 | * certificate key for key exchange. |
| 2148 | * Otherwise, generate ephemeral key pair. | 2142 | * Otherwise, generate ephemeral key pair. |
| 2149 | */ | 2143 | */ |
| 2150 | |||
| 2151 | EVP_PKEY_encrypt_init(pkey_ctx); | 2144 | EVP_PKEY_encrypt_init(pkey_ctx); |
| 2145 | |||
| 2152 | /* Generate session key. */ | 2146 | /* Generate session key. */ |
| 2153 | arc4random_buf(premaster_secret, 32); | 2147 | arc4random_buf(premaster_secret, 32); |
| 2148 | |||
| 2154 | /* | 2149 | /* |
| 2155 | * If we have client certificate, use its secret | 2150 | * If we have client certificate, use its secret as |
| 2156 | * as peer key. | 2151 | * peer key. |
| 2157 | */ | 2152 | */ |
| 2158 | if (s->s3->tmp.cert_req && s->cert->key->privatekey) { | 2153 | if (s->s3->tmp.cert_req && s->cert->key->privatekey) { |
| 2159 | if (EVP_PKEY_derive_set_peer(pkey_ctx, | 2154 | if (EVP_PKEY_derive_set_peer(pkey_ctx, |
| 2160 | s->cert->key->privatekey) <=0) { | 2155 | s->cert->key->privatekey) <=0) { |
| 2161 | /* | 2156 | /* |
| 2162 | * If there was an error - | 2157 | * If there was an error - just ignore |
| 2163 | * just ignore it. Ephemeral key | 2158 | * it. Ephemeral key would be used. |
| 2164 | * would be used | ||
| 2165 | */ | 2159 | */ |
| 2166 | ERR_clear_error(); | 2160 | ERR_clear_error(); |
| 2167 | } | 2161 | } |
| 2168 | } | 2162 | } |
| 2163 | |||
| 2169 | /* | 2164 | /* |
| 2170 | * Compute shared IV and store it in algorithm-specific | 2165 | * Compute shared IV and store it in algorithm-specific |
| 2171 | * context data | 2166 | * context data. |
| 2172 | */ | 2167 | */ |
| 2173 | ukm_hash = EVP_MD_CTX_create(); | 2168 | ukm_hash = EVP_MD_CTX_create(); |
| 2174 | if (ukm_hash == NULL) { | 2169 | if (ukm_hash == NULL) { |
| @@ -2195,9 +2190,10 @@ ssl3_send_client_key_exchange(SSL *s) | |||
| 2195 | SSL_R_LIBRARY_BUG); | 2190 | SSL_R_LIBRARY_BUG); |
| 2196 | goto err; | 2191 | goto err; |
| 2197 | } | 2192 | } |
| 2193 | |||
| 2198 | /* | 2194 | /* |
| 2199 | * Make GOST keytransport blob message, | 2195 | * Make GOST keytransport blob message, encapsulate it |
| 2200 | * encapsulate it into sequence. | 2196 | * into sequence. |
| 2201 | */ | 2197 | */ |
| 2202 | *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; | 2198 | *(p++) = V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED; |
| 2203 | msglen = 255; | 2199 | msglen = 255; |
