diff options
author | beck <> | 2014-07-11 09:24:44 +0000 |
---|---|---|
committer | beck <> | 2014-07-11 09:24:44 +0000 |
commit | 0ca5011d0600da1f218404c4541317bad356f8f1 (patch) | |
tree | fc72650b10ed2f0609c79c34b5d36f8e132e4aa1 /src/lib | |
parent | 4b550e7e97a6068d5f18fbfc47b22d8b4faa4ff6 (diff) | |
download | openbsd-0ca5011d0600da1f218404c4541317bad356f8f1.tar.gz openbsd-0ca5011d0600da1f218404c4541317bad356f8f1.tar.bz2 openbsd-0ca5011d0600da1f218404c4541317bad356f8f1.zip |
Remove the PSK code. We don't need to drag around this
baggage.
ok miod@ jsing@
Diffstat (limited to 'src/lib')
25 files changed, 27 insertions, 1507 deletions
diff --git a/src/lib/libssl/d1_clnt.c b/src/lib/libssl/d1_clnt.c index 04ae11d7bc..3f47a3854b 100644 --- a/src/lib/libssl/d1_clnt.c +++ b/src/lib/libssl/d1_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_clnt.c,v 1.27 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: d1_clnt.c,v 1.28 2014/07/11 09:24:44 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -1196,83 +1196,6 @@ dtls1_send_client_key_exchange(SSL *s) | |||
1196 | EVP_PKEY_free(srvr_pub_pkey); | 1196 | EVP_PKEY_free(srvr_pub_pkey); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | #ifndef OPENSSL_NO_PSK | ||
1200 | else if (alg_k & SSL_kPSK) { | ||
1201 | char identity[PSK_MAX_IDENTITY_LEN]; | ||
1202 | unsigned char *t = NULL; | ||
1203 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
1204 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
1205 | int psk_err = 1; | ||
1206 | |||
1207 | n = 0; | ||
1208 | if (s->psk_client_callback == NULL) { | ||
1209 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1210 | SSL_R_PSK_NO_CLIENT_CB); | ||
1211 | goto err; | ||
1212 | } | ||
1213 | |||
1214 | psk_len = s->psk_client_callback(s, | ||
1215 | s->ctx->psk_identity_hint, identity, | ||
1216 | PSK_MAX_IDENTITY_LEN, psk_or_pre_ms, | ||
1217 | sizeof(psk_or_pre_ms)); | ||
1218 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
1219 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1220 | ERR_R_INTERNAL_ERROR); | ||
1221 | goto psk_err; | ||
1222 | } else if (psk_len == 0) { | ||
1223 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1224 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
1225 | goto psk_err; | ||
1226 | } | ||
1227 | |||
1228 | /* create PSK pre_master_secret */ | ||
1229 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
1230 | t = psk_or_pre_ms; | ||
1231 | memmove(psk_or_pre_ms + psk_len + 4, | ||
1232 | psk_or_pre_ms, psk_len); | ||
1233 | s2n(psk_len, t); | ||
1234 | memset(t, 0, psk_len); | ||
1235 | t += psk_len; | ||
1236 | s2n(psk_len, t); | ||
1237 | |||
1238 | free(s->session->psk_identity_hint); | ||
1239 | s->session->psk_identity_hint = | ||
1240 | BUF_strdup(s->ctx->psk_identity_hint); | ||
1241 | if (s->ctx->psk_identity_hint != NULL && | ||
1242 | s->session->psk_identity_hint == NULL) { | ||
1243 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1244 | ERR_R_MALLOC_FAILURE); | ||
1245 | goto psk_err; | ||
1246 | } | ||
1247 | |||
1248 | free(s->session->psk_identity); | ||
1249 | s->session->psk_identity = BUF_strdup(identity); | ||
1250 | if (s->session->psk_identity == NULL) { | ||
1251 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1252 | ERR_R_MALLOC_FAILURE); | ||
1253 | goto psk_err; | ||
1254 | } | ||
1255 | |||
1256 | s->session->master_key_length = | ||
1257 | s->method->ssl3_enc->generate_master_secret(s, | ||
1258 | s->session->master_key, | ||
1259 | psk_or_pre_ms, pre_ms_len); | ||
1260 | |||
1261 | n = strlen(identity); | ||
1262 | s2n(n, p); | ||
1263 | memcpy(p, identity, n); | ||
1264 | n += 2; | ||
1265 | psk_err = 0; | ||
1266 | psk_err: | ||
1267 | OPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN); | ||
1268 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
1269 | if (psk_err != 0) { | ||
1270 | ssl3_send_alert(s, SSL3_AL_FATAL, | ||
1271 | SSL_AD_HANDSHAKE_FAILURE); | ||
1272 | goto err; | ||
1273 | } | ||
1274 | } | ||
1275 | #endif | ||
1276 | else { | 1199 | else { |
1277 | ssl3_send_alert(s, SSL3_AL_FATAL, | 1200 | ssl3_send_alert(s, SSL3_AL_FATAL, |
1278 | SSL_AD_HANDSHAKE_FAILURE); | 1201 | SSL_AD_HANDSHAKE_FAILURE); |
diff --git a/src/lib/libssl/d1_srvr.c b/src/lib/libssl/d1_srvr.c index 9fdb6c290b..d94c08a313 100644 --- a/src/lib/libssl/d1_srvr.c +++ b/src/lib/libssl/d1_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_srvr.c,v 1.29 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: d1_srvr.c,v 1.30 2014/07/11 09:24:44 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -464,11 +464,6 @@ dtls1_accept(SSL *s) | |||
464 | /* only send if a DH key exchange or | 464 | /* only send if a DH key exchange or |
465 | * RSA but we have a sign only certificate */ | 465 | * RSA but we have a sign only certificate */ |
466 | if (s->s3->tmp.use_rsa_tmp | 466 | if (s->s3->tmp.use_rsa_tmp |
467 | /* PSK: send ServerKeyExchange if PSK identity | ||
468 | * hint if provided */ | ||
469 | #ifndef OPENSSL_NO_PSK | ||
470 | || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) | ||
471 | #endif | ||
472 | || (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 467 | || (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) |
473 | || (alg_k & SSL_kEECDH) | 468 | || (alg_k & SSL_kEECDH) |
474 | || ((alg_k & SSL_kRSA) | 469 | || ((alg_k & SSL_kRSA) |
@@ -1011,9 +1006,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1011 | int curve_id = 0; | 1006 | int curve_id = 0; |
1012 | BN_CTX *bn_ctx = NULL; | 1007 | BN_CTX *bn_ctx = NULL; |
1013 | 1008 | ||
1014 | #ifndef OPENSSL_NO_PSK | ||
1015 | size_t pskhintlen = 0; | ||
1016 | #endif | ||
1017 | EVP_PKEY *pkey; | 1009 | EVP_PKEY *pkey; |
1018 | unsigned char *p, *d; | 1010 | unsigned char *p, *d; |
1019 | int al, i; | 1011 | int al, i; |
@@ -1200,13 +1192,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1200 | r[2] = NULL; | 1192 | r[2] = NULL; |
1201 | r[3] = NULL; | 1193 | r[3] = NULL; |
1202 | } else | 1194 | } else |
1203 | #ifndef OPENSSL_NO_PSK | ||
1204 | if (type & SSL_kPSK) { | ||
1205 | pskhintlen = strlen(s->ctx->psk_identity_hint); | ||
1206 | /* reserve size for record length and PSK identity hint*/ | ||
1207 | n += 2 + pskhintlen; | ||
1208 | } else | ||
1209 | #endif /* !OPENSSL_NO_PSK */ | ||
1210 | { | 1195 | { |
1211 | al = SSL_AD_HANDSHAKE_FAILURE; | 1196 | al = SSL_AD_HANDSHAKE_FAILURE; |
1212 | SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); | 1197 | SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); |
@@ -1265,15 +1250,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1265 | p += encodedlen; | 1250 | p += encodedlen; |
1266 | } | 1251 | } |
1267 | 1252 | ||
1268 | #ifndef OPENSSL_NO_PSK | ||
1269 | if (type & SSL_kPSK) { | ||
1270 | /* copy PSK identity hint */ | ||
1271 | s2n(pskhintlen, p); | ||
1272 | |||
1273 | memcpy(p, s->ctx->psk_identity_hint, pskhintlen); | ||
1274 | p += pskhintlen; | ||
1275 | } | ||
1276 | #endif | ||
1277 | 1253 | ||
1278 | /* not anonymous */ | 1254 | /* not anonymous */ |
1279 | if (pkey != NULL) { | 1255 | if (pkey != NULL) { |
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index 079544da84..b70719f75a 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.74 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.75 2014/07/11 09:24:44 beck 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 | * |
@@ -1173,20 +1173,6 @@ ssl3_get_key_exchange(SSL *s) | |||
1173 | return ((int)n); | 1173 | return ((int)n); |
1174 | 1174 | ||
1175 | if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { | 1175 | if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { |
1176 | #ifndef OPENSSL_NO_PSK | ||
1177 | /* | ||
1178 | * In plain PSK ciphersuite, ServerKeyExchange can be | ||
1179 | * omitted if no identity hint is sent. Set session->sess_cert | ||
1180 | * anyway to avoid problems later. | ||
1181 | */ | ||
1182 | if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) { | ||
1183 | s->session->sess_cert = ssl_sess_cert_new(); | ||
1184 | if (s->session->sess_cert == NULL) | ||
1185 | goto err; | ||
1186 | free(s->ctx->psk_identity_hint); | ||
1187 | s->ctx->psk_identity_hint = NULL; | ||
1188 | } | ||
1189 | #endif | ||
1190 | s->s3->tmp.reuse_message = 1; | 1176 | s->s3->tmp.reuse_message = 1; |
1191 | return (1); | 1177 | return (1); |
1192 | } | 1178 | } |
@@ -1212,50 +1198,6 @@ ssl3_get_key_exchange(SSL *s) | |||
1212 | alg_a = s->s3->tmp.new_cipher->algorithm_auth; | 1198 | alg_a = s->s3->tmp.new_cipher->algorithm_auth; |
1213 | EVP_MD_CTX_init(&md_ctx); | 1199 | EVP_MD_CTX_init(&md_ctx); |
1214 | 1200 | ||
1215 | #ifndef OPENSSL_NO_PSK | ||
1216 | if (alg_k & SSL_kPSK) { | ||
1217 | char tmp_id_hint[PSK_MAX_IDENTITY_LEN + 1]; | ||
1218 | |||
1219 | al = SSL_AD_HANDSHAKE_FAILURE; | ||
1220 | n2s(p, i); | ||
1221 | param_len = i + 2; | ||
1222 | /* | ||
1223 | * Store PSK identity hint for later use, hint is used | ||
1224 | * in ssl3_send_client_key_exchange. Assume that the | ||
1225 | * maximum length of a PSK identity hint can be as | ||
1226 | * long as the maximum length of a PSK identity. | ||
1227 | */ | ||
1228 | if (i > PSK_MAX_IDENTITY_LEN) { | ||
1229 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1230 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
1231 | goto f_err; | ||
1232 | } | ||
1233 | if (param_len > n) { | ||
1234 | al = SSL_AD_DECODE_ERROR; | ||
1235 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1236 | SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH); | ||
1237 | goto f_err; | ||
1238 | } | ||
1239 | /* | ||
1240 | * If received PSK identity hint contains NULL | ||
1241 | * characters, the hint is truncated from the first | ||
1242 | * NULL. p may not be ending with NULL, so create a | ||
1243 | * NULL-terminated string. | ||
1244 | */ | ||
1245 | memcpy(tmp_id_hint, p, i); | ||
1246 | memset(tmp_id_hint + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i); | ||
1247 | free(s->ctx->psk_identity_hint); | ||
1248 | s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint); | ||
1249 | if (s->ctx->psk_identity_hint == NULL) { | ||
1250 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1251 | ERR_R_MALLOC_FAILURE); | ||
1252 | goto f_err; | ||
1253 | } | ||
1254 | |||
1255 | p += i; | ||
1256 | n -= param_len; | ||
1257 | } else | ||
1258 | #endif /* !OPENSSL_NO_PSK */ | ||
1259 | if (alg_k & SSL_kRSA) { | 1201 | if (alg_k & SSL_kRSA) { |
1260 | if ((rsa = RSA_new()) == NULL) { | 1202 | if ((rsa = RSA_new()) == NULL) { |
1261 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | 1203 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, |
@@ -2363,83 +2305,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
2363 | EVP_PKEY_free(pub_key); | 2305 | EVP_PKEY_free(pub_key); |
2364 | 2306 | ||
2365 | } | 2307 | } |
2366 | #ifndef OPENSSL_NO_PSK | ||
2367 | else if (alg_k & SSL_kPSK) { | ||
2368 | char identity[PSK_MAX_IDENTITY_LEN]; | ||
2369 | unsigned char *t = NULL; | ||
2370 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
2371 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
2372 | int psk_err = 1; | ||
2373 | |||
2374 | n = 0; | ||
2375 | if (s->psk_client_callback == NULL) { | ||
2376 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2377 | SSL_R_PSK_NO_CLIENT_CB); | ||
2378 | goto err; | ||
2379 | } | ||
2380 | |||
2381 | psk_len = s->psk_client_callback(s, | ||
2382 | s->ctx->psk_identity_hint, identity, | ||
2383 | PSK_MAX_IDENTITY_LEN, psk_or_pre_ms, | ||
2384 | sizeof(psk_or_pre_ms)); | ||
2385 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
2386 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2387 | ERR_R_INTERNAL_ERROR); | ||
2388 | goto psk_err; | ||
2389 | } else if (psk_len == 0) { | ||
2390 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2391 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
2392 | goto psk_err; | ||
2393 | } | ||
2394 | |||
2395 | /* create PSK pre_master_secret */ | ||
2396 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
2397 | t = psk_or_pre_ms; | ||
2398 | memmove(psk_or_pre_ms + psk_len + 4, | ||
2399 | psk_or_pre_ms, psk_len); | ||
2400 | s2n(psk_len, t); | ||
2401 | memset(t, 0, psk_len); | ||
2402 | t += psk_len; | ||
2403 | s2n(psk_len, t); | ||
2404 | |||
2405 | free(s->session->psk_identity_hint); | ||
2406 | s->session->psk_identity_hint = | ||
2407 | BUF_strdup(s->ctx->psk_identity_hint); | ||
2408 | if (s->ctx->psk_identity_hint != NULL && | ||
2409 | s->session->psk_identity_hint == NULL) { | ||
2410 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2411 | ERR_R_MALLOC_FAILURE); | ||
2412 | goto psk_err; | ||
2413 | } | ||
2414 | |||
2415 | free(s->session->psk_identity); | ||
2416 | s->session->psk_identity = BUF_strdup(identity); | ||
2417 | if (s->session->psk_identity == NULL) { | ||
2418 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2419 | ERR_R_MALLOC_FAILURE); | ||
2420 | goto psk_err; | ||
2421 | } | ||
2422 | |||
2423 | s->session->master_key_length = | ||
2424 | s->method->ssl3_enc->generate_master_secret( | ||
2425 | s, s->session->master_key, psk_or_pre_ms, | ||
2426 | pre_ms_len); | ||
2427 | |||
2428 | n = strlen(identity); | ||
2429 | s2n(n, p); | ||
2430 | memcpy(p, identity, n); | ||
2431 | n += 2; | ||
2432 | psk_err = 0; | ||
2433 | psk_err: | ||
2434 | OPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN); | ||
2435 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2436 | if (psk_err != 0) { | ||
2437 | ssl3_send_alert(s, SSL3_AL_FATAL, | ||
2438 | SSL_AD_HANDSHAKE_FAILURE); | ||
2439 | goto err; | ||
2440 | } | ||
2441 | } | ||
2442 | #endif | ||
2443 | else { | 2308 | else { |
2444 | ssl3_send_alert(s, SSL3_AL_FATAL, | 2309 | ssl3_send_alert(s, SSL3_AL_FATAL, |
2445 | SSL_AD_HANDSHAKE_FAILURE); | 2310 | SSL_AD_HANDSHAKE_FAILURE); |
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 400c1b87e0..f94e207fc4 100644 --- a/src/lib/libssl/s3_lib.c +++ b/src/lib/libssl/s3_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_lib.c,v 1.68 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.69 2014/07/11 09:24:44 beck 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 | * |
@@ -1262,71 +1262,6 @@ SSL_CIPHER ssl3_ciphers[] = { | |||
1262 | }, | 1262 | }, |
1263 | #endif /* OPENSSL_NO_CAMELLIA */ | 1263 | #endif /* OPENSSL_NO_CAMELLIA */ |
1264 | 1264 | ||
1265 | #ifndef OPENSSL_NO_PSK | ||
1266 | /* Cipher 8A */ | ||
1267 | { | ||
1268 | .valid = 1, | ||
1269 | .name = TLS1_TXT_PSK_WITH_RC4_128_SHA, | ||
1270 | .id = TLS1_CK_PSK_WITH_RC4_128_SHA, | ||
1271 | .algorithm_mkey = SSL_kPSK, | ||
1272 | .algorithm_auth = SSL_aPSK, | ||
1273 | .algorithm_enc = SSL_RC4, | ||
1274 | .algorithm_mac = SSL_SHA1, | ||
1275 | .algorithm_ssl = SSL_TLSV1, | ||
1276 | .algo_strength = SSL_MEDIUM, | ||
1277 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1278 | .strength_bits = 128, | ||
1279 | .alg_bits = 128, | ||
1280 | }, | ||
1281 | |||
1282 | /* Cipher 8B */ | ||
1283 | { | ||
1284 | .valid = 1, | ||
1285 | .name = TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA, | ||
1286 | .id = TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA, | ||
1287 | .algorithm_mkey = SSL_kPSK, | ||
1288 | .algorithm_auth = SSL_aPSK, | ||
1289 | .algorithm_enc = SSL_3DES, | ||
1290 | .algorithm_mac = SSL_SHA1, | ||
1291 | .algorithm_ssl = SSL_TLSV1, | ||
1292 | .algo_strength = SSL_HIGH, | ||
1293 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1294 | .strength_bits = 112, | ||
1295 | .alg_bits = 168, | ||
1296 | }, | ||
1297 | |||
1298 | /* Cipher 8C */ | ||
1299 | { | ||
1300 | .valid = 1, | ||
1301 | .name = TLS1_TXT_PSK_WITH_AES_128_CBC_SHA, | ||
1302 | .id = TLS1_CK_PSK_WITH_AES_128_CBC_SHA, | ||
1303 | .algorithm_mkey = SSL_kPSK, | ||
1304 | .algorithm_auth = SSL_aPSK, | ||
1305 | .algorithm_enc = SSL_AES128, | ||
1306 | .algorithm_mac = SSL_SHA1, | ||
1307 | .algorithm_ssl = SSL_TLSV1, | ||
1308 | .algo_strength = SSL_HIGH, | ||
1309 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1310 | .strength_bits = 128, | ||
1311 | .alg_bits = 128, | ||
1312 | }, | ||
1313 | |||
1314 | /* Cipher 8D */ | ||
1315 | { | ||
1316 | .valid = 1, | ||
1317 | .name = TLS1_TXT_PSK_WITH_AES_256_CBC_SHA, | ||
1318 | .id = TLS1_CK_PSK_WITH_AES_256_CBC_SHA, | ||
1319 | .algorithm_mkey = SSL_kPSK, | ||
1320 | .algorithm_auth = SSL_aPSK, | ||
1321 | .algorithm_enc = SSL_AES256, | ||
1322 | .algorithm_mac = SSL_SHA1, | ||
1323 | .algorithm_ssl = SSL_TLSV1, | ||
1324 | .algo_strength = SSL_HIGH, | ||
1325 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1326 | .strength_bits = 256, | ||
1327 | .alg_bits = 256, | ||
1328 | }, | ||
1329 | #endif /* OPENSSL_NO_PSK */ | ||
1330 | 1265 | ||
1331 | /* GCM ciphersuites from RFC5288 */ | 1266 | /* GCM ciphersuites from RFC5288 */ |
1332 | 1267 | ||
@@ -3030,11 +2965,6 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, | |||
3030 | alg_k = c->algorithm_mkey; | 2965 | alg_k = c->algorithm_mkey; |
3031 | alg_a = c->algorithm_auth; | 2966 | alg_a = c->algorithm_auth; |
3032 | 2967 | ||
3033 | #ifndef OPENSSL_NO_PSK | ||
3034 | /* with PSK there must be server callback set */ | ||
3035 | if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL) | ||
3036 | continue; | ||
3037 | #endif /* OPENSSL_NO_PSK */ | ||
3038 | 2968 | ||
3039 | ok = (alg_k & mask_k) && (alg_a & mask_a); | 2969 | ok = (alg_k & mask_k) && (alg_a & mask_a); |
3040 | 2970 | ||
diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 8fb041c4f5..c31ac39fe1 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_srvr.c,v 1.71 2014/07/10 21:36:49 bcook Exp $ */ | 1 | /* $OpenBSD: s3_srvr.c,v 1.72 2014/07/11 09:24:44 beck 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 | * |
@@ -429,9 +429,6 @@ ssl3_accept(SSL *s) | |||
429 | * public key for key exchange. | 429 | * public key for key exchange. |
430 | */ | 430 | */ |
431 | if (s->s3->tmp.use_rsa_tmp | 431 | if (s->s3->tmp.use_rsa_tmp |
432 | #ifndef OPENSSL_NO_PSK | ||
433 | || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) | ||
434 | #endif | ||
435 | || (alg_k & (SSL_kDHr|SSL_kDHd|SSL_kEDH)) | 432 | || (alg_k & (SSL_kDHr|SSL_kDHd|SSL_kEDH)) |
436 | || (alg_k & SSL_kEECDH) | 433 | || (alg_k & SSL_kEECDH) |
437 | || ((alg_k & SSL_kRSA) | 434 | || ((alg_k & SSL_kRSA) |
@@ -1383,9 +1380,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1383 | int curve_id = 0; | 1380 | int curve_id = 0; |
1384 | BN_CTX *bn_ctx = NULL; | 1381 | BN_CTX *bn_ctx = NULL; |
1385 | 1382 | ||
1386 | #ifndef OPENSSL_NO_PSK | ||
1387 | size_t pskhintlen = 0; | ||
1388 | #endif | ||
1389 | EVP_PKEY *pkey; | 1383 | EVP_PKEY *pkey; |
1390 | const EVP_MD *md = NULL; | 1384 | const EVP_MD *md = NULL; |
1391 | unsigned char *p, *d; | 1385 | unsigned char *p, *d; |
@@ -1592,13 +1586,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1592 | r[2] = NULL; | 1586 | r[2] = NULL; |
1593 | r[3] = NULL; | 1587 | r[3] = NULL; |
1594 | } else | 1588 | } else |
1595 | #ifndef OPENSSL_NO_PSK | ||
1596 | if (type & SSL_kPSK) { | ||
1597 | pskhintlen = strlen(s->ctx->psk_identity_hint); | ||
1598 | /* reserve size for record length and PSK identity hint*/ | ||
1599 | n += 2 + pskhintlen; | ||
1600 | } else | ||
1601 | #endif /* !OPENSSL_NO_PSK */ | ||
1602 | { | 1589 | { |
1603 | al = SSL_AD_HANDSHAKE_FAILURE; | 1590 | al = SSL_AD_HANDSHAKE_FAILURE; |
1604 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | 1591 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, |
@@ -1661,15 +1648,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1661 | p += encodedlen; | 1648 | p += encodedlen; |
1662 | } | 1649 | } |
1663 | 1650 | ||
1664 | #ifndef OPENSSL_NO_PSK | ||
1665 | if (type & SSL_kPSK) { | ||
1666 | /* copy PSK identity hint */ | ||
1667 | s2n(pskhintlen, p); | ||
1668 | |||
1669 | memcpy(p, s->ctx->psk_identity_hint, pskhintlen); | ||
1670 | p += pskhintlen; | ||
1671 | } | ||
1672 | #endif | ||
1673 | 1651 | ||
1674 | /* not anonymous */ | 1652 | /* not anonymous */ |
1675 | if (pkey != NULL) { | 1653 | if (pkey != NULL) { |
@@ -2196,91 +2174,6 @@ ssl3_get_client_key_exchange(SSL *s) | |||
2196 | OPENSSL_cleanse(p, i); | 2174 | OPENSSL_cleanse(p, i); |
2197 | return (ret); | 2175 | return (ret); |
2198 | } else | 2176 | } else |
2199 | #ifndef OPENSSL_NO_PSK | ||
2200 | if (alg_k & SSL_kPSK) { | ||
2201 | unsigned char *t = NULL; | ||
2202 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
2203 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
2204 | int psk_err = 1; | ||
2205 | char tmp_id[PSK_MAX_IDENTITY_LEN + 1]; | ||
2206 | |||
2207 | al = SSL_AD_HANDSHAKE_FAILURE; | ||
2208 | |||
2209 | n2s(p, i); | ||
2210 | if (n != i + 2) { | ||
2211 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2212 | SSL_R_LENGTH_MISMATCH); | ||
2213 | goto psk_err; | ||
2214 | } | ||
2215 | if (i > PSK_MAX_IDENTITY_LEN) { | ||
2216 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2217 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2218 | goto psk_err; | ||
2219 | } | ||
2220 | if (s->psk_server_callback == NULL) { | ||
2221 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2222 | SSL_R_PSK_NO_SERVER_CB); | ||
2223 | goto psk_err; | ||
2224 | } | ||
2225 | |||
2226 | /* | ||
2227 | * Create guaranteed NULL-terminated identity | ||
2228 | * string for the callback | ||
2229 | */ | ||
2230 | memcpy(tmp_id, p, i); | ||
2231 | memset(tmp_id + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i); | ||
2232 | psk_len = s->psk_server_callback(s, tmp_id, | ||
2233 | psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2234 | OPENSSL_cleanse(tmp_id, PSK_MAX_IDENTITY_LEN + 1); | ||
2235 | |||
2236 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
2237 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2238 | ERR_R_INTERNAL_ERROR); | ||
2239 | goto psk_err; | ||
2240 | } else if (psk_len == 0) { | ||
2241 | /* PSK related to the given identity not found */ | ||
2242 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2243 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
2244 | al = SSL_AD_UNKNOWN_PSK_IDENTITY; | ||
2245 | goto psk_err; | ||
2246 | } | ||
2247 | |||
2248 | /* create PSK pre_master_secret */ | ||
2249 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
2250 | t = psk_or_pre_ms; | ||
2251 | memmove(psk_or_pre_ms + psk_len + 4, psk_or_pre_ms, psk_len); | ||
2252 | s2n(psk_len, t); | ||
2253 | memset(t, 0, psk_len); | ||
2254 | t += psk_len; | ||
2255 | s2n(psk_len, t); | ||
2256 | |||
2257 | free(s->session->psk_identity); | ||
2258 | s->session->psk_identity = BUF_strdup((char *)p); | ||
2259 | if (s->session->psk_identity == NULL) { | ||
2260 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2261 | ERR_R_MALLOC_FAILURE); | ||
2262 | goto psk_err; | ||
2263 | } | ||
2264 | |||
2265 | free(s->session->psk_identity_hint); | ||
2266 | s->session->psk_identity_hint = BUF_strdup(s->ctx->psk_identity_hint); | ||
2267 | if (s->ctx->psk_identity_hint != NULL && | ||
2268 | s->session->psk_identity_hint == NULL) { | ||
2269 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2270 | ERR_R_MALLOC_FAILURE); | ||
2271 | goto psk_err; | ||
2272 | } | ||
2273 | |||
2274 | s->session->master_key_length = | ||
2275 | s->method->ssl3_enc->generate_master_secret( | ||
2276 | s, s->session->master_key, psk_or_pre_ms, pre_ms_len); | ||
2277 | psk_err = 0; | ||
2278 | psk_err: | ||
2279 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2280 | if (psk_err != 0) | ||
2281 | goto f_err; | ||
2282 | } else | ||
2283 | #endif | ||
2284 | if (alg_k & SSL_kGOST) { | 2177 | if (alg_k & SSL_kGOST) { |
2285 | int ret = 0; | 2178 | int ret = 0; |
2286 | EVP_PKEY_CTX *pkey_ctx; | 2179 | EVP_PKEY_CTX *pkey_ctx; |
diff --git a/src/lib/libssl/src/apps/apps.h b/src/lib/libssl/src/apps/apps.h index 9909d7fa66..9d8725159b 100644 --- a/src/lib/libssl/src/apps/apps.h +++ b/src/lib/libssl/src/apps/apps.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: apps.h,v 1.34 2014/07/09 09:06:58 bcook Exp $ */ | 1 | /* $OpenBSD: apps.h,v 1.35 2014/07/11 09:24:44 beck 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 | * |
@@ -244,9 +244,6 @@ int do_X509_REQ_sign(BIO *err, X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md, | |||
244 | STACK_OF(OPENSSL_STRING) *sigopts); | 244 | STACK_OF(OPENSSL_STRING) *sigopts); |
245 | int do_X509_CRL_sign(BIO *err, X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md, | 245 | int do_X509_CRL_sign(BIO *err, X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md, |
246 | STACK_OF(OPENSSL_STRING) *sigopts); | 246 | STACK_OF(OPENSSL_STRING) *sigopts); |
247 | #ifndef OPENSSL_NO_PSK | ||
248 | extern char *psk_key; | ||
249 | #endif | ||
250 | 247 | ||
251 | #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) | 248 | #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG) |
252 | unsigned char *next_protos_parse(unsigned short *outlen, const char *in); | 249 | unsigned char *next_protos_parse(unsigned short *outlen, const char *in); |
diff --git a/src/lib/libssl/src/apps/s_client.c b/src/lib/libssl/src/apps/s_client.c index 2b313c84ff..ec23b92754 100644 --- a/src/lib/libssl/src/apps/s_client.c +++ b/src/lib/libssl/src/apps/s_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_client.c,v 1.65 2014/07/10 09:30:53 jsing Exp $ */ | 1 | /* $OpenBSD: s_client.c,v 1.66 2014/07/11 09:24:44 beck 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 | * |
@@ -198,70 +198,6 @@ static BIO *bio_c_out = NULL; | |||
198 | static int c_quiet = 0; | 198 | static int c_quiet = 0; |
199 | static int c_ign_eof = 0; | 199 | static int c_ign_eof = 0; |
200 | 200 | ||
201 | #ifndef OPENSSL_NO_PSK | ||
202 | /* Default PSK identity and key */ | ||
203 | static char *psk_identity = "Client_identity"; | ||
204 | /*char *psk_key=NULL; by default PSK is not used */ | ||
205 | |||
206 | static unsigned int | ||
207 | psk_client_cb(SSL * ssl, const char *hint, char *identity, | ||
208 | unsigned int max_identity_len, unsigned char *psk, | ||
209 | unsigned int max_psk_len) | ||
210 | { | ||
211 | unsigned int psk_len = 0; | ||
212 | size_t maxlen = 0; | ||
213 | int ret; | ||
214 | BIGNUM *bn = NULL; | ||
215 | |||
216 | if (c_debug) | ||
217 | BIO_printf(bio_c_out, "psk_client_cb\n"); | ||
218 | if (max_identity_len > INT_MAX) | ||
219 | goto out_err; | ||
220 | maxlen = max_identity_len; | ||
221 | if (!hint) { | ||
222 | /* no ServerKeyExchange message */ | ||
223 | if (c_debug) | ||
224 | BIO_printf(bio_c_out, "NULL received PSK identity hint, continuing anyway\n"); | ||
225 | } else if (c_debug) | ||
226 | BIO_printf(bio_c_out, "Received PSK identity hint '%s'\n", hint); | ||
227 | |||
228 | /* | ||
229 | * lookup PSK identity and PSK key based on the given identity hint | ||
230 | * here | ||
231 | */ | ||
232 | ret = snprintf(identity, maxlen, "%s", psk_identity); | ||
233 | if (ret == -1 || ret >= maxlen) | ||
234 | goto out_err; | ||
235 | if (c_debug) | ||
236 | BIO_printf(bio_c_out, "created identity '%s' len=%d\n", identity, ret); | ||
237 | ret = BN_hex2bn(&bn, psk_key); | ||
238 | if (!ret) { | ||
239 | BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n", psk_key); | ||
240 | if (bn) | ||
241 | BN_free(bn); | ||
242 | return 0; | ||
243 | } | ||
244 | if ((unsigned int) BN_num_bytes(bn) > max_psk_len) { | ||
245 | BIO_printf(bio_err, "psk buffer of callback is too small (%d) for key (%d)\n", | ||
246 | max_psk_len, BN_num_bytes(bn)); | ||
247 | BN_free(bn); | ||
248 | return 0; | ||
249 | } | ||
250 | psk_len = BN_bn2bin(bn, psk); | ||
251 | BN_free(bn); | ||
252 | if (psk_len == 0) | ||
253 | goto out_err; | ||
254 | |||
255 | if (c_debug) | ||
256 | BIO_printf(bio_c_out, "created PSK len=%d\n", psk_len); | ||
257 | |||
258 | return psk_len; | ||
259 | out_err: | ||
260 | if (c_debug) | ||
261 | BIO_printf(bio_err, "Error in PSK client callback\n"); | ||
262 | return 0; | ||
263 | } | ||
264 | #endif | ||
265 | 201 | ||
266 | static void | 202 | static void |
267 | sc_usage(void) | 203 | sc_usage(void) |
@@ -295,10 +231,6 @@ sc_usage(void) | |||
295 | BIO_printf(bio_err, " -quiet - no s_client output\n"); | 231 | BIO_printf(bio_err, " -quiet - no s_client output\n"); |
296 | BIO_printf(bio_err, " -ign_eof - ignore input eof (default when -quiet)\n"); | 232 | BIO_printf(bio_err, " -ign_eof - ignore input eof (default when -quiet)\n"); |
297 | BIO_printf(bio_err, " -no_ign_eof - don't ignore input eof\n"); | 233 | BIO_printf(bio_err, " -no_ign_eof - don't ignore input eof\n"); |
298 | #ifndef OPENSSL_NO_PSK | ||
299 | BIO_printf(bio_err, " -psk_identity arg - PSK identity\n"); | ||
300 | BIO_printf(bio_err, " -psk arg - PSK in hex (without 0x)\n"); | ||
301 | #endif | ||
302 | BIO_printf(bio_err, " -ssl3 - just use SSLv3\n"); | 234 | BIO_printf(bio_err, " -ssl3 - just use SSLv3\n"); |
303 | BIO_printf(bio_err, " -tls1_2 - just use TLSv1.2\n"); | 235 | BIO_printf(bio_err, " -tls1_2 - just use TLSv1.2\n"); |
304 | BIO_printf(bio_err, " -tls1_1 - just use TLSv1.1\n"); | 236 | BIO_printf(bio_err, " -tls1_1 - just use TLSv1.1\n"); |
@@ -560,25 +492,6 @@ s_client_main(int argc, char **argv) | |||
560 | nbio_test = 1; | 492 | nbio_test = 1; |
561 | else if (strcmp(*argv, "-state") == 0) | 493 | else if (strcmp(*argv, "-state") == 0) |
562 | state = 1; | 494 | state = 1; |
563 | #ifndef OPENSSL_NO_PSK | ||
564 | else if (strcmp(*argv, "-psk_identity") == 0) { | ||
565 | if (--argc < 1) | ||
566 | goto bad; | ||
567 | psk_identity = *(++argv); | ||
568 | } else if (strcmp(*argv, "-psk") == 0) { | ||
569 | size_t j; | ||
570 | |||
571 | if (--argc < 1) | ||
572 | goto bad; | ||
573 | psk_key = *(++argv); | ||
574 | for (j = 0; j < strlen(psk_key); j++) { | ||
575 | if (isxdigit((unsigned char) psk_key[j])) | ||
576 | continue; | ||
577 | BIO_printf(bio_err, "Not a hex number '%s'\n", *argv); | ||
578 | goto bad; | ||
579 | } | ||
580 | } | ||
581 | #endif | ||
582 | else if (strcmp(*argv, "-ssl3") == 0) | 495 | else if (strcmp(*argv, "-ssl3") == 0) |
583 | meth = SSLv3_client_method(); | 496 | meth = SSLv3_client_method(); |
584 | else if (strcmp(*argv, "-tls1_2") == 0) | 497 | else if (strcmp(*argv, "-tls1_2") == 0) |
@@ -827,13 +740,6 @@ bad: | |||
827 | } | 740 | } |
828 | #endif | 741 | #endif |
829 | 742 | ||
830 | #ifndef OPENSSL_NO_PSK | ||
831 | if (psk_key != NULL) { | ||
832 | if (c_debug) | ||
833 | BIO_printf(bio_c_out, "PSK key given, setting client callback\n"); | ||
834 | SSL_CTX_set_psk_client_callback(ctx, psk_client_cb); | ||
835 | } | ||
836 | #endif | ||
837 | #ifndef OPENSSL_NO_SRTP | 743 | #ifndef OPENSSL_NO_SRTP |
838 | if (srtp_profiles != NULL) | 744 | if (srtp_profiles != NULL) |
839 | SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles); | 745 | SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles); |
diff --git a/src/lib/libssl/src/apps/s_server.c b/src/lib/libssl/src/apps/s_server.c index 45c4f5fa9c..802150a29a 100644 --- a/src/lib/libssl/src/apps/s_server.c +++ b/src/lib/libssl/src/apps/s_server.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s_server.c,v 1.57 2014/07/10 08:59:15 bcook Exp $ */ | 1 | /* $OpenBSD: s_server.c,v 1.58 2014/07/11 09:24:44 beck 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 | * |
@@ -280,68 +280,6 @@ static int cert_chain = 0; | |||
280 | #endif | 280 | #endif |
281 | 281 | ||
282 | 282 | ||
283 | #ifndef OPENSSL_NO_PSK | ||
284 | static char *psk_identity = "Client_identity"; | ||
285 | char *psk_key = NULL; /* by default PSK is not used */ | ||
286 | |||
287 | static unsigned int | ||
288 | psk_server_cb(SSL * ssl, const char *identity, | ||
289 | unsigned char *psk, unsigned int max_psk_len) | ||
290 | { | ||
291 | unsigned int psk_len = 0; | ||
292 | int ret; | ||
293 | BIGNUM *bn = NULL; | ||
294 | |||
295 | if (s_debug) | ||
296 | BIO_printf(bio_s_out, "psk_server_cb\n"); | ||
297 | if (!identity) { | ||
298 | BIO_printf(bio_err, "Error: client did not send PSK identity\n"); | ||
299 | goto out_err; | ||
300 | } | ||
301 | if (s_debug) | ||
302 | BIO_printf(bio_s_out, "identity_len=%d identity=%s\n", | ||
303 | identity ? (int) strlen(identity) : 0, identity); | ||
304 | |||
305 | /* here we could lookup the given identity e.g. from a database */ | ||
306 | if (strcmp(identity, psk_identity) != 0) { | ||
307 | BIO_printf(bio_s_out, "PSK error: client identity not found" | ||
308 | " (got '%s' expected '%s')\n", identity, | ||
309 | psk_identity); | ||
310 | goto out_err; | ||
311 | } | ||
312 | if (s_debug) | ||
313 | BIO_printf(bio_s_out, "PSK client identity found\n"); | ||
314 | |||
315 | /* convert the PSK key to binary */ | ||
316 | ret = BN_hex2bn(&bn, psk_key); | ||
317 | if (!ret) { | ||
318 | BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n", psk_key); | ||
319 | if (bn) | ||
320 | BN_free(bn); | ||
321 | return 0; | ||
322 | } | ||
323 | if (BN_num_bytes(bn) > (int) max_psk_len) { | ||
324 | BIO_printf(bio_err, "psk buffer of callback is too small (%d) for key (%d)\n", | ||
325 | max_psk_len, BN_num_bytes(bn)); | ||
326 | BN_free(bn); | ||
327 | return 0; | ||
328 | } | ||
329 | ret = BN_bn2bin(bn, psk); | ||
330 | BN_free(bn); | ||
331 | |||
332 | if (ret < 0) | ||
333 | goto out_err; | ||
334 | psk_len = (unsigned int) ret; | ||
335 | |||
336 | if (s_debug) | ||
337 | BIO_printf(bio_s_out, "fetched PSK len=%d\n", psk_len); | ||
338 | return psk_len; | ||
339 | out_err: | ||
340 | if (s_debug) | ||
341 | BIO_printf(bio_err, "Error in PSK server callback\n"); | ||
342 | return 0; | ||
343 | } | ||
344 | #endif | ||
345 | 283 | ||
346 | 284 | ||
347 | static void | 285 | static void |
@@ -418,10 +356,6 @@ sv_usage(void) | |||
418 | BIO_printf(bio_err, " -serverpref - Use server's cipher preferences\n"); | 356 | BIO_printf(bio_err, " -serverpref - Use server's cipher preferences\n"); |
419 | BIO_printf(bio_err, " -quiet - Inhibit printing of session and certificate information\n"); | 357 | BIO_printf(bio_err, " -quiet - Inhibit printing of session and certificate information\n"); |
420 | BIO_printf(bio_err, " -no_tmp_rsa - Do not generate a tmp RSA key\n"); | 358 | BIO_printf(bio_err, " -no_tmp_rsa - Do not generate a tmp RSA key\n"); |
421 | #ifndef OPENSSL_NO_PSK | ||
422 | BIO_printf(bio_err, " -psk_hint arg - PSK identity hint to use\n"); | ||
423 | BIO_printf(bio_err, " -psk arg - PSK in hex (without 0x)\n"); | ||
424 | #endif | ||
425 | BIO_printf(bio_err, " -ssl3 - Just talk SSLv3\n"); | 359 | BIO_printf(bio_err, " -ssl3 - Just talk SSLv3\n"); |
426 | BIO_printf(bio_err, " -tls1_2 - Just talk TLSv1.2\n"); | 360 | BIO_printf(bio_err, " -tls1_2 - Just talk TLSv1.2\n"); |
427 | BIO_printf(bio_err, " -tls1_1 - Just talk TLSv1.1\n"); | 361 | BIO_printf(bio_err, " -tls1_1 - Just talk TLSv1.1\n"); |
@@ -699,10 +633,6 @@ s_server_main(int argc, char *argv[]) | |||
699 | tlsextnextprotoctx next_proto; | 633 | tlsextnextprotoctx next_proto; |
700 | #endif | 634 | #endif |
701 | #endif | 635 | #endif |
702 | #ifndef OPENSSL_NO_PSK | ||
703 | /* by default do not send a PSK identity hint */ | ||
704 | static char *psk_identity_hint = NULL; | ||
705 | #endif | ||
706 | meth = SSLv23_server_method(); | 636 | meth = SSLv23_server_method(); |
707 | 637 | ||
708 | local_argc = argc; | 638 | local_argc = argc; |
@@ -882,25 +812,6 @@ s_server_main(int argc, char *argv[]) | |||
882 | } else if (strcmp(*argv, "-no_ecdhe") == 0) { | 812 | } else if (strcmp(*argv, "-no_ecdhe") == 0) { |
883 | no_ecdhe = 1; | 813 | no_ecdhe = 1; |
884 | } | 814 | } |
885 | #ifndef OPENSSL_NO_PSK | ||
886 | else if (strcmp(*argv, "-psk_hint") == 0) { | ||
887 | if (--argc < 1) | ||
888 | goto bad; | ||
889 | psk_identity_hint = *(++argv); | ||
890 | } else if (strcmp(*argv, "-psk") == 0) { | ||
891 | size_t i; | ||
892 | |||
893 | if (--argc < 1) | ||
894 | goto bad; | ||
895 | psk_key = *(++argv); | ||
896 | for (i = 0; i < strlen(psk_key); i++) { | ||
897 | if (isxdigit((unsigned char) psk_key[i])) | ||
898 | continue; | ||
899 | BIO_printf(bio_err, "Not a hex number '%s'\n", *argv); | ||
900 | goto bad; | ||
901 | } | ||
902 | } | ||
903 | #endif | ||
904 | else if (strcmp(*argv, "-www") == 0) { | 815 | else if (strcmp(*argv, "-www") == 0) { |
905 | www = 1; | 816 | www = 1; |
906 | } else if (strcmp(*argv, "-WWW") == 0) { | 817 | } else if (strcmp(*argv, "-WWW") == 0) { |
@@ -1328,18 +1239,6 @@ bad: | |||
1328 | #endif | 1239 | #endif |
1329 | } | 1240 | } |
1330 | 1241 | ||
1331 | #ifndef OPENSSL_NO_PSK | ||
1332 | if (psk_key != NULL) { | ||
1333 | if (s_debug) | ||
1334 | BIO_printf(bio_s_out, "PSK key given, setting server callback\n"); | ||
1335 | SSL_CTX_set_psk_server_callback(ctx, psk_server_cb); | ||
1336 | } | ||
1337 | if (!SSL_CTX_use_psk_identity_hint(ctx, psk_identity_hint)) { | ||
1338 | BIO_printf(bio_err, "error setting PSK identity hint to context\n"); | ||
1339 | ERR_print_errors(bio_err); | ||
1340 | goto end; | ||
1341 | } | ||
1342 | #endif | ||
1343 | 1242 | ||
1344 | if (cipher != NULL) { | 1243 | if (cipher != NULL) { |
1345 | if (!SSL_CTX_set_cipher_list(ctx, cipher)) { | 1244 | if (!SSL_CTX_set_cipher_list(ctx, cipher)) { |
diff --git a/src/lib/libssl/src/ssl/d1_clnt.c b/src/lib/libssl/src/ssl/d1_clnt.c index 04ae11d7bc..3f47a3854b 100644 --- a/src/lib/libssl/src/ssl/d1_clnt.c +++ b/src/lib/libssl/src/ssl/d1_clnt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_clnt.c,v 1.27 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: d1_clnt.c,v 1.28 2014/07/11 09:24:44 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -1196,83 +1196,6 @@ dtls1_send_client_key_exchange(SSL *s) | |||
1196 | EVP_PKEY_free(srvr_pub_pkey); | 1196 | EVP_PKEY_free(srvr_pub_pkey); |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | #ifndef OPENSSL_NO_PSK | ||
1200 | else if (alg_k & SSL_kPSK) { | ||
1201 | char identity[PSK_MAX_IDENTITY_LEN]; | ||
1202 | unsigned char *t = NULL; | ||
1203 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
1204 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
1205 | int psk_err = 1; | ||
1206 | |||
1207 | n = 0; | ||
1208 | if (s->psk_client_callback == NULL) { | ||
1209 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1210 | SSL_R_PSK_NO_CLIENT_CB); | ||
1211 | goto err; | ||
1212 | } | ||
1213 | |||
1214 | psk_len = s->psk_client_callback(s, | ||
1215 | s->ctx->psk_identity_hint, identity, | ||
1216 | PSK_MAX_IDENTITY_LEN, psk_or_pre_ms, | ||
1217 | sizeof(psk_or_pre_ms)); | ||
1218 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
1219 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1220 | ERR_R_INTERNAL_ERROR); | ||
1221 | goto psk_err; | ||
1222 | } else if (psk_len == 0) { | ||
1223 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1224 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
1225 | goto psk_err; | ||
1226 | } | ||
1227 | |||
1228 | /* create PSK pre_master_secret */ | ||
1229 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
1230 | t = psk_or_pre_ms; | ||
1231 | memmove(psk_or_pre_ms + psk_len + 4, | ||
1232 | psk_or_pre_ms, psk_len); | ||
1233 | s2n(psk_len, t); | ||
1234 | memset(t, 0, psk_len); | ||
1235 | t += psk_len; | ||
1236 | s2n(psk_len, t); | ||
1237 | |||
1238 | free(s->session->psk_identity_hint); | ||
1239 | s->session->psk_identity_hint = | ||
1240 | BUF_strdup(s->ctx->psk_identity_hint); | ||
1241 | if (s->ctx->psk_identity_hint != NULL && | ||
1242 | s->session->psk_identity_hint == NULL) { | ||
1243 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1244 | ERR_R_MALLOC_FAILURE); | ||
1245 | goto psk_err; | ||
1246 | } | ||
1247 | |||
1248 | free(s->session->psk_identity); | ||
1249 | s->session->psk_identity = BUF_strdup(identity); | ||
1250 | if (s->session->psk_identity == NULL) { | ||
1251 | SSLerr(SSL_F_DTLS1_SEND_CLIENT_KEY_EXCHANGE, | ||
1252 | ERR_R_MALLOC_FAILURE); | ||
1253 | goto psk_err; | ||
1254 | } | ||
1255 | |||
1256 | s->session->master_key_length = | ||
1257 | s->method->ssl3_enc->generate_master_secret(s, | ||
1258 | s->session->master_key, | ||
1259 | psk_or_pre_ms, pre_ms_len); | ||
1260 | |||
1261 | n = strlen(identity); | ||
1262 | s2n(n, p); | ||
1263 | memcpy(p, identity, n); | ||
1264 | n += 2; | ||
1265 | psk_err = 0; | ||
1266 | psk_err: | ||
1267 | OPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN); | ||
1268 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
1269 | if (psk_err != 0) { | ||
1270 | ssl3_send_alert(s, SSL3_AL_FATAL, | ||
1271 | SSL_AD_HANDSHAKE_FAILURE); | ||
1272 | goto err; | ||
1273 | } | ||
1274 | } | ||
1275 | #endif | ||
1276 | else { | 1199 | else { |
1277 | ssl3_send_alert(s, SSL3_AL_FATAL, | 1200 | ssl3_send_alert(s, SSL3_AL_FATAL, |
1278 | SSL_AD_HANDSHAKE_FAILURE); | 1201 | SSL_AD_HANDSHAKE_FAILURE); |
diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c index 9fdb6c290b..d94c08a313 100644 --- a/src/lib/libssl/src/ssl/d1_srvr.c +++ b/src/lib/libssl/src/ssl/d1_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: d1_srvr.c,v 1.29 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: d1_srvr.c,v 1.30 2014/07/11 09:24:44 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
@@ -464,11 +464,6 @@ dtls1_accept(SSL *s) | |||
464 | /* only send if a DH key exchange or | 464 | /* only send if a DH key exchange or |
465 | * RSA but we have a sign only certificate */ | 465 | * RSA but we have a sign only certificate */ |
466 | if (s->s3->tmp.use_rsa_tmp | 466 | if (s->s3->tmp.use_rsa_tmp |
467 | /* PSK: send ServerKeyExchange if PSK identity | ||
468 | * hint if provided */ | ||
469 | #ifndef OPENSSL_NO_PSK | ||
470 | || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) | ||
471 | #endif | ||
472 | || (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) | 467 | || (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) |
473 | || (alg_k & SSL_kEECDH) | 468 | || (alg_k & SSL_kEECDH) |
474 | || ((alg_k & SSL_kRSA) | 469 | || ((alg_k & SSL_kRSA) |
@@ -1011,9 +1006,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1011 | int curve_id = 0; | 1006 | int curve_id = 0; |
1012 | BN_CTX *bn_ctx = NULL; | 1007 | BN_CTX *bn_ctx = NULL; |
1013 | 1008 | ||
1014 | #ifndef OPENSSL_NO_PSK | ||
1015 | size_t pskhintlen = 0; | ||
1016 | #endif | ||
1017 | EVP_PKEY *pkey; | 1009 | EVP_PKEY *pkey; |
1018 | unsigned char *p, *d; | 1010 | unsigned char *p, *d; |
1019 | int al, i; | 1011 | int al, i; |
@@ -1200,13 +1192,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1200 | r[2] = NULL; | 1192 | r[2] = NULL; |
1201 | r[3] = NULL; | 1193 | r[3] = NULL; |
1202 | } else | 1194 | } else |
1203 | #ifndef OPENSSL_NO_PSK | ||
1204 | if (type & SSL_kPSK) { | ||
1205 | pskhintlen = strlen(s->ctx->psk_identity_hint); | ||
1206 | /* reserve size for record length and PSK identity hint*/ | ||
1207 | n += 2 + pskhintlen; | ||
1208 | } else | ||
1209 | #endif /* !OPENSSL_NO_PSK */ | ||
1210 | { | 1195 | { |
1211 | al = SSL_AD_HANDSHAKE_FAILURE; | 1196 | al = SSL_AD_HANDSHAKE_FAILURE; |
1212 | SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); | 1197 | SSLerr(SSL_F_DTLS1_SEND_SERVER_KEY_EXCHANGE, SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE); |
@@ -1265,15 +1250,6 @@ dtls1_send_server_key_exchange(SSL *s) | |||
1265 | p += encodedlen; | 1250 | p += encodedlen; |
1266 | } | 1251 | } |
1267 | 1252 | ||
1268 | #ifndef OPENSSL_NO_PSK | ||
1269 | if (type & SSL_kPSK) { | ||
1270 | /* copy PSK identity hint */ | ||
1271 | s2n(pskhintlen, p); | ||
1272 | |||
1273 | memcpy(p, s->ctx->psk_identity_hint, pskhintlen); | ||
1274 | p += pskhintlen; | ||
1275 | } | ||
1276 | #endif | ||
1277 | 1253 | ||
1278 | /* not anonymous */ | 1254 | /* not anonymous */ |
1279 | if (pkey != NULL) { | 1255 | if (pkey != NULL) { |
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c index 079544da84..b70719f75a 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.74 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: s3_clnt.c,v 1.75 2014/07/11 09:24:44 beck 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 | * |
@@ -1173,20 +1173,6 @@ ssl3_get_key_exchange(SSL *s) | |||
1173 | return ((int)n); | 1173 | return ((int)n); |
1174 | 1174 | ||
1175 | if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { | 1175 | if (s->s3->tmp.message_type != SSL3_MT_SERVER_KEY_EXCHANGE) { |
1176 | #ifndef OPENSSL_NO_PSK | ||
1177 | /* | ||
1178 | * In plain PSK ciphersuite, ServerKeyExchange can be | ||
1179 | * omitted if no identity hint is sent. Set session->sess_cert | ||
1180 | * anyway to avoid problems later. | ||
1181 | */ | ||
1182 | if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK) { | ||
1183 | s->session->sess_cert = ssl_sess_cert_new(); | ||
1184 | if (s->session->sess_cert == NULL) | ||
1185 | goto err; | ||
1186 | free(s->ctx->psk_identity_hint); | ||
1187 | s->ctx->psk_identity_hint = NULL; | ||
1188 | } | ||
1189 | #endif | ||
1190 | s->s3->tmp.reuse_message = 1; | 1176 | s->s3->tmp.reuse_message = 1; |
1191 | return (1); | 1177 | return (1); |
1192 | } | 1178 | } |
@@ -1212,50 +1198,6 @@ ssl3_get_key_exchange(SSL *s) | |||
1212 | alg_a = s->s3->tmp.new_cipher->algorithm_auth; | 1198 | alg_a = s->s3->tmp.new_cipher->algorithm_auth; |
1213 | EVP_MD_CTX_init(&md_ctx); | 1199 | EVP_MD_CTX_init(&md_ctx); |
1214 | 1200 | ||
1215 | #ifndef OPENSSL_NO_PSK | ||
1216 | if (alg_k & SSL_kPSK) { | ||
1217 | char tmp_id_hint[PSK_MAX_IDENTITY_LEN + 1]; | ||
1218 | |||
1219 | al = SSL_AD_HANDSHAKE_FAILURE; | ||
1220 | n2s(p, i); | ||
1221 | param_len = i + 2; | ||
1222 | /* | ||
1223 | * Store PSK identity hint for later use, hint is used | ||
1224 | * in ssl3_send_client_key_exchange. Assume that the | ||
1225 | * maximum length of a PSK identity hint can be as | ||
1226 | * long as the maximum length of a PSK identity. | ||
1227 | */ | ||
1228 | if (i > PSK_MAX_IDENTITY_LEN) { | ||
1229 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1230 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
1231 | goto f_err; | ||
1232 | } | ||
1233 | if (param_len > n) { | ||
1234 | al = SSL_AD_DECODE_ERROR; | ||
1235 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1236 | SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH); | ||
1237 | goto f_err; | ||
1238 | } | ||
1239 | /* | ||
1240 | * If received PSK identity hint contains NULL | ||
1241 | * characters, the hint is truncated from the first | ||
1242 | * NULL. p may not be ending with NULL, so create a | ||
1243 | * NULL-terminated string. | ||
1244 | */ | ||
1245 | memcpy(tmp_id_hint, p, i); | ||
1246 | memset(tmp_id_hint + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i); | ||
1247 | free(s->ctx->psk_identity_hint); | ||
1248 | s->ctx->psk_identity_hint = BUF_strdup(tmp_id_hint); | ||
1249 | if (s->ctx->psk_identity_hint == NULL) { | ||
1250 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | ||
1251 | ERR_R_MALLOC_FAILURE); | ||
1252 | goto f_err; | ||
1253 | } | ||
1254 | |||
1255 | p += i; | ||
1256 | n -= param_len; | ||
1257 | } else | ||
1258 | #endif /* !OPENSSL_NO_PSK */ | ||
1259 | if (alg_k & SSL_kRSA) { | 1201 | if (alg_k & SSL_kRSA) { |
1260 | if ((rsa = RSA_new()) == NULL) { | 1202 | if ((rsa = RSA_new()) == NULL) { |
1261 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, | 1203 | SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, |
@@ -2363,83 +2305,6 @@ ssl3_send_client_key_exchange(SSL *s) | |||
2363 | EVP_PKEY_free(pub_key); | 2305 | EVP_PKEY_free(pub_key); |
2364 | 2306 | ||
2365 | } | 2307 | } |
2366 | #ifndef OPENSSL_NO_PSK | ||
2367 | else if (alg_k & SSL_kPSK) { | ||
2368 | char identity[PSK_MAX_IDENTITY_LEN]; | ||
2369 | unsigned char *t = NULL; | ||
2370 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
2371 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
2372 | int psk_err = 1; | ||
2373 | |||
2374 | n = 0; | ||
2375 | if (s->psk_client_callback == NULL) { | ||
2376 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2377 | SSL_R_PSK_NO_CLIENT_CB); | ||
2378 | goto err; | ||
2379 | } | ||
2380 | |||
2381 | psk_len = s->psk_client_callback(s, | ||
2382 | s->ctx->psk_identity_hint, identity, | ||
2383 | PSK_MAX_IDENTITY_LEN, psk_or_pre_ms, | ||
2384 | sizeof(psk_or_pre_ms)); | ||
2385 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
2386 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2387 | ERR_R_INTERNAL_ERROR); | ||
2388 | goto psk_err; | ||
2389 | } else if (psk_len == 0) { | ||
2390 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2391 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
2392 | goto psk_err; | ||
2393 | } | ||
2394 | |||
2395 | /* create PSK pre_master_secret */ | ||
2396 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
2397 | t = psk_or_pre_ms; | ||
2398 | memmove(psk_or_pre_ms + psk_len + 4, | ||
2399 | psk_or_pre_ms, psk_len); | ||
2400 | s2n(psk_len, t); | ||
2401 | memset(t, 0, psk_len); | ||
2402 | t += psk_len; | ||
2403 | s2n(psk_len, t); | ||
2404 | |||
2405 | free(s->session->psk_identity_hint); | ||
2406 | s->session->psk_identity_hint = | ||
2407 | BUF_strdup(s->ctx->psk_identity_hint); | ||
2408 | if (s->ctx->psk_identity_hint != NULL && | ||
2409 | s->session->psk_identity_hint == NULL) { | ||
2410 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2411 | ERR_R_MALLOC_FAILURE); | ||
2412 | goto psk_err; | ||
2413 | } | ||
2414 | |||
2415 | free(s->session->psk_identity); | ||
2416 | s->session->psk_identity = BUF_strdup(identity); | ||
2417 | if (s->session->psk_identity == NULL) { | ||
2418 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2419 | ERR_R_MALLOC_FAILURE); | ||
2420 | goto psk_err; | ||
2421 | } | ||
2422 | |||
2423 | s->session->master_key_length = | ||
2424 | s->method->ssl3_enc->generate_master_secret( | ||
2425 | s, s->session->master_key, psk_or_pre_ms, | ||
2426 | pre_ms_len); | ||
2427 | |||
2428 | n = strlen(identity); | ||
2429 | s2n(n, p); | ||
2430 | memcpy(p, identity, n); | ||
2431 | n += 2; | ||
2432 | psk_err = 0; | ||
2433 | psk_err: | ||
2434 | OPENSSL_cleanse(identity, PSK_MAX_IDENTITY_LEN); | ||
2435 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2436 | if (psk_err != 0) { | ||
2437 | ssl3_send_alert(s, SSL3_AL_FATAL, | ||
2438 | SSL_AD_HANDSHAKE_FAILURE); | ||
2439 | goto err; | ||
2440 | } | ||
2441 | } | ||
2442 | #endif | ||
2443 | else { | 2308 | else { |
2444 | ssl3_send_alert(s, SSL3_AL_FATAL, | 2309 | ssl3_send_alert(s, SSL3_AL_FATAL, |
2445 | SSL_AD_HANDSHAKE_FAILURE); | 2310 | SSL_AD_HANDSHAKE_FAILURE); |
diff --git a/src/lib/libssl/src/ssl/s3_lib.c b/src/lib/libssl/src/ssl/s3_lib.c index 400c1b87e0..f94e207fc4 100644 --- a/src/lib/libssl/src/ssl/s3_lib.c +++ b/src/lib/libssl/src/ssl/s3_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_lib.c,v 1.68 2014/07/10 08:51:14 tedu Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.69 2014/07/11 09:24:44 beck 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 | * |
@@ -1262,71 +1262,6 @@ SSL_CIPHER ssl3_ciphers[] = { | |||
1262 | }, | 1262 | }, |
1263 | #endif /* OPENSSL_NO_CAMELLIA */ | 1263 | #endif /* OPENSSL_NO_CAMELLIA */ |
1264 | 1264 | ||
1265 | #ifndef OPENSSL_NO_PSK | ||
1266 | /* Cipher 8A */ | ||
1267 | { | ||
1268 | .valid = 1, | ||
1269 | .name = TLS1_TXT_PSK_WITH_RC4_128_SHA, | ||
1270 | .id = TLS1_CK_PSK_WITH_RC4_128_SHA, | ||
1271 | .algorithm_mkey = SSL_kPSK, | ||
1272 | .algorithm_auth = SSL_aPSK, | ||
1273 | .algorithm_enc = SSL_RC4, | ||
1274 | .algorithm_mac = SSL_SHA1, | ||
1275 | .algorithm_ssl = SSL_TLSV1, | ||
1276 | .algo_strength = SSL_MEDIUM, | ||
1277 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1278 | .strength_bits = 128, | ||
1279 | .alg_bits = 128, | ||
1280 | }, | ||
1281 | |||
1282 | /* Cipher 8B */ | ||
1283 | { | ||
1284 | .valid = 1, | ||
1285 | .name = TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA, | ||
1286 | .id = TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA, | ||
1287 | .algorithm_mkey = SSL_kPSK, | ||
1288 | .algorithm_auth = SSL_aPSK, | ||
1289 | .algorithm_enc = SSL_3DES, | ||
1290 | .algorithm_mac = SSL_SHA1, | ||
1291 | .algorithm_ssl = SSL_TLSV1, | ||
1292 | .algo_strength = SSL_HIGH, | ||
1293 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1294 | .strength_bits = 112, | ||
1295 | .alg_bits = 168, | ||
1296 | }, | ||
1297 | |||
1298 | /* Cipher 8C */ | ||
1299 | { | ||
1300 | .valid = 1, | ||
1301 | .name = TLS1_TXT_PSK_WITH_AES_128_CBC_SHA, | ||
1302 | .id = TLS1_CK_PSK_WITH_AES_128_CBC_SHA, | ||
1303 | .algorithm_mkey = SSL_kPSK, | ||
1304 | .algorithm_auth = SSL_aPSK, | ||
1305 | .algorithm_enc = SSL_AES128, | ||
1306 | .algorithm_mac = SSL_SHA1, | ||
1307 | .algorithm_ssl = SSL_TLSV1, | ||
1308 | .algo_strength = SSL_HIGH, | ||
1309 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1310 | .strength_bits = 128, | ||
1311 | .alg_bits = 128, | ||
1312 | }, | ||
1313 | |||
1314 | /* Cipher 8D */ | ||
1315 | { | ||
1316 | .valid = 1, | ||
1317 | .name = TLS1_TXT_PSK_WITH_AES_256_CBC_SHA, | ||
1318 | .id = TLS1_CK_PSK_WITH_AES_256_CBC_SHA, | ||
1319 | .algorithm_mkey = SSL_kPSK, | ||
1320 | .algorithm_auth = SSL_aPSK, | ||
1321 | .algorithm_enc = SSL_AES256, | ||
1322 | .algorithm_mac = SSL_SHA1, | ||
1323 | .algorithm_ssl = SSL_TLSV1, | ||
1324 | .algo_strength = SSL_HIGH, | ||
1325 | .algorithm2 = SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF, | ||
1326 | .strength_bits = 256, | ||
1327 | .alg_bits = 256, | ||
1328 | }, | ||
1329 | #endif /* OPENSSL_NO_PSK */ | ||
1330 | 1265 | ||
1331 | /* GCM ciphersuites from RFC5288 */ | 1266 | /* GCM ciphersuites from RFC5288 */ |
1332 | 1267 | ||
@@ -3030,11 +2965,6 @@ SSL_CIPHER *ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt, | |||
3030 | alg_k = c->algorithm_mkey; | 2965 | alg_k = c->algorithm_mkey; |
3031 | alg_a = c->algorithm_auth; | 2966 | alg_a = c->algorithm_auth; |
3032 | 2967 | ||
3033 | #ifndef OPENSSL_NO_PSK | ||
3034 | /* with PSK there must be server callback set */ | ||
3035 | if ((alg_k & SSL_kPSK) && s->psk_server_callback == NULL) | ||
3036 | continue; | ||
3037 | #endif /* OPENSSL_NO_PSK */ | ||
3038 | 2968 | ||
3039 | ok = (alg_k & mask_k) && (alg_a & mask_a); | 2969 | ok = (alg_k & mask_k) && (alg_a & mask_a); |
3040 | 2970 | ||
diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c index 8fb041c4f5..c31ac39fe1 100644 --- a/src/lib/libssl/src/ssl/s3_srvr.c +++ b/src/lib/libssl/src/ssl/s3_srvr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: s3_srvr.c,v 1.71 2014/07/10 21:36:49 bcook Exp $ */ | 1 | /* $OpenBSD: s3_srvr.c,v 1.72 2014/07/11 09:24:44 beck 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 | * |
@@ -429,9 +429,6 @@ ssl3_accept(SSL *s) | |||
429 | * public key for key exchange. | 429 | * public key for key exchange. |
430 | */ | 430 | */ |
431 | if (s->s3->tmp.use_rsa_tmp | 431 | if (s->s3->tmp.use_rsa_tmp |
432 | #ifndef OPENSSL_NO_PSK | ||
433 | || ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint) | ||
434 | #endif | ||
435 | || (alg_k & (SSL_kDHr|SSL_kDHd|SSL_kEDH)) | 432 | || (alg_k & (SSL_kDHr|SSL_kDHd|SSL_kEDH)) |
436 | || (alg_k & SSL_kEECDH) | 433 | || (alg_k & SSL_kEECDH) |
437 | || ((alg_k & SSL_kRSA) | 434 | || ((alg_k & SSL_kRSA) |
@@ -1383,9 +1380,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1383 | int curve_id = 0; | 1380 | int curve_id = 0; |
1384 | BN_CTX *bn_ctx = NULL; | 1381 | BN_CTX *bn_ctx = NULL; |
1385 | 1382 | ||
1386 | #ifndef OPENSSL_NO_PSK | ||
1387 | size_t pskhintlen = 0; | ||
1388 | #endif | ||
1389 | EVP_PKEY *pkey; | 1383 | EVP_PKEY *pkey; |
1390 | const EVP_MD *md = NULL; | 1384 | const EVP_MD *md = NULL; |
1391 | unsigned char *p, *d; | 1385 | unsigned char *p, *d; |
@@ -1592,13 +1586,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1592 | r[2] = NULL; | 1586 | r[2] = NULL; |
1593 | r[3] = NULL; | 1587 | r[3] = NULL; |
1594 | } else | 1588 | } else |
1595 | #ifndef OPENSSL_NO_PSK | ||
1596 | if (type & SSL_kPSK) { | ||
1597 | pskhintlen = strlen(s->ctx->psk_identity_hint); | ||
1598 | /* reserve size for record length and PSK identity hint*/ | ||
1599 | n += 2 + pskhintlen; | ||
1600 | } else | ||
1601 | #endif /* !OPENSSL_NO_PSK */ | ||
1602 | { | 1589 | { |
1603 | al = SSL_AD_HANDSHAKE_FAILURE; | 1590 | al = SSL_AD_HANDSHAKE_FAILURE; |
1604 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, | 1591 | SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, |
@@ -1661,15 +1648,6 @@ ssl3_send_server_key_exchange(SSL *s) | |||
1661 | p += encodedlen; | 1648 | p += encodedlen; |
1662 | } | 1649 | } |
1663 | 1650 | ||
1664 | #ifndef OPENSSL_NO_PSK | ||
1665 | if (type & SSL_kPSK) { | ||
1666 | /* copy PSK identity hint */ | ||
1667 | s2n(pskhintlen, p); | ||
1668 | |||
1669 | memcpy(p, s->ctx->psk_identity_hint, pskhintlen); | ||
1670 | p += pskhintlen; | ||
1671 | } | ||
1672 | #endif | ||
1673 | 1651 | ||
1674 | /* not anonymous */ | 1652 | /* not anonymous */ |
1675 | if (pkey != NULL) { | 1653 | if (pkey != NULL) { |
@@ -2196,91 +2174,6 @@ ssl3_get_client_key_exchange(SSL *s) | |||
2196 | OPENSSL_cleanse(p, i); | 2174 | OPENSSL_cleanse(p, i); |
2197 | return (ret); | 2175 | return (ret); |
2198 | } else | 2176 | } else |
2199 | #ifndef OPENSSL_NO_PSK | ||
2200 | if (alg_k & SSL_kPSK) { | ||
2201 | unsigned char *t = NULL; | ||
2202 | unsigned char psk_or_pre_ms[PSK_MAX_PSK_LEN*2 + 4]; | ||
2203 | unsigned int pre_ms_len = 0, psk_len = 0; | ||
2204 | int psk_err = 1; | ||
2205 | char tmp_id[PSK_MAX_IDENTITY_LEN + 1]; | ||
2206 | |||
2207 | al = SSL_AD_HANDSHAKE_FAILURE; | ||
2208 | |||
2209 | n2s(p, i); | ||
2210 | if (n != i + 2) { | ||
2211 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2212 | SSL_R_LENGTH_MISMATCH); | ||
2213 | goto psk_err; | ||
2214 | } | ||
2215 | if (i > PSK_MAX_IDENTITY_LEN) { | ||
2216 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2217 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2218 | goto psk_err; | ||
2219 | } | ||
2220 | if (s->psk_server_callback == NULL) { | ||
2221 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2222 | SSL_R_PSK_NO_SERVER_CB); | ||
2223 | goto psk_err; | ||
2224 | } | ||
2225 | |||
2226 | /* | ||
2227 | * Create guaranteed NULL-terminated identity | ||
2228 | * string for the callback | ||
2229 | */ | ||
2230 | memcpy(tmp_id, p, i); | ||
2231 | memset(tmp_id + i, 0, PSK_MAX_IDENTITY_LEN + 1 - i); | ||
2232 | psk_len = s->psk_server_callback(s, tmp_id, | ||
2233 | psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2234 | OPENSSL_cleanse(tmp_id, PSK_MAX_IDENTITY_LEN + 1); | ||
2235 | |||
2236 | if (psk_len > PSK_MAX_PSK_LEN) { | ||
2237 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2238 | ERR_R_INTERNAL_ERROR); | ||
2239 | goto psk_err; | ||
2240 | } else if (psk_len == 0) { | ||
2241 | /* PSK related to the given identity not found */ | ||
2242 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2243 | SSL_R_PSK_IDENTITY_NOT_FOUND); | ||
2244 | al = SSL_AD_UNKNOWN_PSK_IDENTITY; | ||
2245 | goto psk_err; | ||
2246 | } | ||
2247 | |||
2248 | /* create PSK pre_master_secret */ | ||
2249 | pre_ms_len = 2 + psk_len + 2 + psk_len; | ||
2250 | t = psk_or_pre_ms; | ||
2251 | memmove(psk_or_pre_ms + psk_len + 4, psk_or_pre_ms, psk_len); | ||
2252 | s2n(psk_len, t); | ||
2253 | memset(t, 0, psk_len); | ||
2254 | t += psk_len; | ||
2255 | s2n(psk_len, t); | ||
2256 | |||
2257 | free(s->session->psk_identity); | ||
2258 | s->session->psk_identity = BUF_strdup((char *)p); | ||
2259 | if (s->session->psk_identity == NULL) { | ||
2260 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2261 | ERR_R_MALLOC_FAILURE); | ||
2262 | goto psk_err; | ||
2263 | } | ||
2264 | |||
2265 | free(s->session->psk_identity_hint); | ||
2266 | s->session->psk_identity_hint = BUF_strdup(s->ctx->psk_identity_hint); | ||
2267 | if (s->ctx->psk_identity_hint != NULL && | ||
2268 | s->session->psk_identity_hint == NULL) { | ||
2269 | SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, | ||
2270 | ERR_R_MALLOC_FAILURE); | ||
2271 | goto psk_err; | ||
2272 | } | ||
2273 | |||
2274 | s->session->master_key_length = | ||
2275 | s->method->ssl3_enc->generate_master_secret( | ||
2276 | s, s->session->master_key, psk_or_pre_ms, pre_ms_len); | ||
2277 | psk_err = 0; | ||
2278 | psk_err: | ||
2279 | OPENSSL_cleanse(psk_or_pre_ms, sizeof(psk_or_pre_ms)); | ||
2280 | if (psk_err != 0) | ||
2281 | goto f_err; | ||
2282 | } else | ||
2283 | #endif | ||
2284 | if (alg_k & SSL_kGOST) { | 2177 | if (alg_k & SSL_kGOST) { |
2285 | int ret = 0; | 2178 | int ret = 0; |
2286 | EVP_PKEY_CTX *pkey_ctx; | 2179 | EVP_PKEY_CTX *pkey_ctx; |
diff --git a/src/lib/libssl/src/ssl/ssl.h b/src/lib/libssl/src/ssl/ssl.h index 0301fd0b96..5ea440231a 100644 --- a/src/lib/libssl/src/ssl/ssl.h +++ b/src/lib/libssl/src/ssl/ssl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl.h,v 1.60 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl.h,v 1.61 2014/07/11 09:24:44 beck 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 | * |
@@ -460,10 +460,6 @@ struct ssl_session_st { | |||
460 | unsigned int sid_ctx_length; | 460 | unsigned int sid_ctx_length; |
461 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; | 461 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; |
462 | 462 | ||
463 | #ifndef OPENSSL_NO_PSK | ||
464 | char *psk_identity_hint; | ||
465 | char *psk_identity; | ||
466 | #endif | ||
467 | /* Used to indicate that session resumption is not allowed. | 463 | /* Used to indicate that session resumption is not allowed. |
468 | * Applications can also set this bit for a new session via | 464 | * Applications can also set this bit for a new session via |
469 | * not_resumable_session_cb to disable session caching and tickets. */ | 465 | * not_resumable_session_cb to disable session caching and tickets. */ |
@@ -835,14 +831,6 @@ struct ssl_ctx_st { | |||
835 | int (*tlsext_status_cb)(SSL *ssl, void *arg); | 831 | int (*tlsext_status_cb)(SSL *ssl, void *arg); |
836 | void *tlsext_status_arg; | 832 | void *tlsext_status_arg; |
837 | 833 | ||
838 | #ifndef OPENSSL_NO_PSK | ||
839 | char *psk_identity_hint; | ||
840 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
841 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
842 | unsigned int max_psk_len); | ||
843 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
844 | unsigned char *psk, unsigned int max_psk_len); | ||
845 | #endif | ||
846 | 834 | ||
847 | 835 | ||
848 | 836 | ||
@@ -955,30 +943,6 @@ void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, | |||
955 | #define OPENSSL_NPN_NO_OVERLAP 2 | 943 | #define OPENSSL_NPN_NO_OVERLAP 2 |
956 | #endif | 944 | #endif |
957 | 945 | ||
958 | #ifndef OPENSSL_NO_PSK | ||
959 | /* the maximum length of the buffer given to callbacks containing the | ||
960 | * resulting identity/psk */ | ||
961 | #define PSK_MAX_IDENTITY_LEN 128 | ||
962 | #define PSK_MAX_PSK_LEN 256 | ||
963 | void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, | ||
964 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
965 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
966 | unsigned int max_psk_len)); | ||
967 | void SSL_set_psk_client_callback(SSL *ssl, | ||
968 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
969 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
970 | unsigned int max_psk_len)); | ||
971 | void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, | ||
972 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
973 | unsigned char *psk, unsigned int max_psk_len)); | ||
974 | void SSL_set_psk_server_callback(SSL *ssl, | ||
975 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
976 | unsigned char *psk, unsigned int max_psk_len)); | ||
977 | int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); | ||
978 | int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); | ||
979 | const char *SSL_get_psk_identity_hint(const SSL *s); | ||
980 | const char *SSL_get_psk_identity(const SSL *s); | ||
981 | #endif | ||
982 | 946 | ||
983 | #define SSL_NOTHING 1 | 947 | #define SSL_NOTHING 1 |
984 | #define SSL_WRITING 2 | 948 | #define SSL_WRITING 2 |
@@ -1123,13 +1087,6 @@ struct ssl_st { | |||
1123 | int error_code; /* actual code */ | 1087 | int error_code; /* actual code */ |
1124 | 1088 | ||
1125 | 1089 | ||
1126 | #ifndef OPENSSL_NO_PSK | ||
1127 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
1128 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
1129 | unsigned int max_psk_len); | ||
1130 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
1131 | unsigned char *psk, unsigned int max_psk_len); | ||
1132 | #endif | ||
1133 | 1090 | ||
1134 | SSL_CTX *ctx; | 1091 | SSL_CTX *ctx; |
1135 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() | 1092 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() |
diff --git a/src/lib/libssl/src/ssl/ssl_asn1.c b/src/lib/libssl/src/ssl/ssl_asn1.c index 43366b33b8..dd958d6570 100644 --- a/src/lib/libssl/src/ssl/ssl_asn1.c +++ b/src/lib/libssl/src/ssl/ssl_asn1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_asn1.c,v 1.27 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_asn1.c,v 1.28 2014/07/11 09:24:44 beck 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 | * |
@@ -103,17 +103,13 @@ typedef struct ssl_session_asn1_st { | |||
103 | ASN1_OCTET_STRING tlsext_hostname; | 103 | ASN1_OCTET_STRING tlsext_hostname; |
104 | ASN1_INTEGER tlsext_tick_lifetime; | 104 | ASN1_INTEGER tlsext_tick_lifetime; |
105 | ASN1_OCTET_STRING tlsext_tick; | 105 | ASN1_OCTET_STRING tlsext_tick; |
106 | #ifndef OPENSSL_NO_PSK | ||
107 | ASN1_OCTET_STRING psk_identity_hint; | ||
108 | ASN1_OCTET_STRING psk_identity; | ||
109 | #endif /* OPENSSL_NO_PSK */ | ||
110 | } SSL_SESSION_ASN1; | 106 | } SSL_SESSION_ASN1; |
111 | 107 | ||
112 | int | 108 | int |
113 | i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | 109 | i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) |
114 | { | 110 | { |
115 | #define LSIZE2 (sizeof(long)*2) | 111 | #define LSIZE2 (sizeof(long)*2) |
116 | int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v7 = 0, v8 = 0; | 112 | int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0; |
117 | unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; | 113 | unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; |
118 | unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; | 114 | unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; |
119 | int v6 = 0, v9 = 0, v10 = 0; | 115 | int v6 = 0, v9 = 0, v10 = 0; |
@@ -202,18 +198,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
202 | a.tlsext_tick_lifetime.data = ibuf6; | 198 | a.tlsext_tick_lifetime.data = ibuf6; |
203 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); | 199 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); |
204 | } | 200 | } |
205 | #ifndef OPENSSL_NO_PSK | ||
206 | if (in->psk_identity_hint) { | ||
207 | a.psk_identity_hint.length = strlen(in->psk_identity_hint); | ||
208 | a.psk_identity_hint.type = V_ASN1_OCTET_STRING; | ||
209 | a.psk_identity_hint.data = (unsigned char *)(in->psk_identity_hint); | ||
210 | } | ||
211 | if (in->psk_identity) { | ||
212 | a.psk_identity.length = strlen(in->psk_identity); | ||
213 | a.psk_identity.type = V_ASN1_OCTET_STRING; | ||
214 | a.psk_identity.data = (unsigned char *)(in->psk_identity); | ||
215 | } | ||
216 | #endif /* OPENSSL_NO_PSK */ | ||
217 | 201 | ||
218 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); | 202 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); |
219 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); | 203 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); |
@@ -236,12 +220,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
236 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); | 220 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); |
237 | if (in->tlsext_hostname) | 221 | if (in->tlsext_hostname) |
238 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); | 222 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
239 | #ifndef OPENSSL_NO_PSK | ||
240 | if (in->psk_identity_hint) | ||
241 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); | ||
242 | if (in->psk_identity) | ||
243 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); | ||
244 | #endif /* OPENSSL_NO_PSK */ | ||
245 | 223 | ||
246 | M_ASN1_I2D_seq_total(); | 224 | M_ASN1_I2D_seq_total(); |
247 | 225 | ||
@@ -262,12 +240,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
262 | M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); | 240 | M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); |
263 | if (in->tlsext_hostname) | 241 | if (in->tlsext_hostname) |
264 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); | 242 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
265 | #ifndef OPENSSL_NO_PSK | ||
266 | if (in->psk_identity_hint) | ||
267 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); | ||
268 | if (in->psk_identity) | ||
269 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); | ||
270 | #endif /* OPENSSL_NO_PSK */ | ||
271 | if (in->tlsext_tick_lifetime_hint > 0) | 243 | if (in->tlsext_tick_lifetime_hint > 0) |
272 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); | 244 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); |
273 | if (in->tlsext_tick) | 245 | if (in->tlsext_tick) |
@@ -415,29 +387,6 @@ d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length) | |||
415 | } else | 387 | } else |
416 | ret->tlsext_hostname = NULL; | 388 | ret->tlsext_hostname = NULL; |
417 | 389 | ||
418 | #ifndef OPENSSL_NO_PSK | ||
419 | os.length = 0; | ||
420 | os.data = NULL; | ||
421 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 7); | ||
422 | if (os.data) { | ||
423 | ret->psk_identity_hint = BUF_strndup((char *)os.data, os.length); | ||
424 | free(os.data); | ||
425 | os.data = NULL; | ||
426 | os.length = 0; | ||
427 | } else | ||
428 | ret->psk_identity_hint = NULL; | ||
429 | |||
430 | os.length = 0; | ||
431 | os.data = NULL; | ||
432 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 8); | ||
433 | if (os.data) { | ||
434 | ret->psk_identity = BUF_strndup((char *)os.data, os.length); | ||
435 | free(os.data); | ||
436 | os.data = NULL; | ||
437 | os.length = 0; | ||
438 | } else | ||
439 | ret->psk_identity = NULL; | ||
440 | #endif /* OPENSSL_NO_PSK */ | ||
441 | 390 | ||
442 | ai.length = 0; | 391 | ai.length = 0; |
443 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); | 392 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); |
diff --git a/src/lib/libssl/src/ssl/ssl_ciph.c b/src/lib/libssl/src/ssl/ssl_ciph.c index 92d2417cb9..a79eafc9cf 100644 --- a/src/lib/libssl/src/ssl/ssl_ciph.c +++ b/src/lib/libssl/src/ssl/ssl_ciph.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_ciph.c,v 1.62 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_ciph.c,v 1.63 2014/07/11 09:24:44 beck 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 | * |
@@ -883,10 +883,8 @@ ssl_cipher_get_disabled(unsigned long *mkey, unsigned long *auth, unsigned long | |||
883 | *auth |= SSL_aDH; | 883 | *auth |= SSL_aDH; |
884 | *mkey |= SSL_kKRB5; | 884 | *mkey |= SSL_kKRB5; |
885 | *auth |= SSL_aKRB5; | 885 | *auth |= SSL_aKRB5; |
886 | #ifdef OPENSSL_NO_PSK | ||
887 | *mkey |= SSL_kPSK; | 886 | *mkey |= SSL_kPSK; |
888 | *auth |= SSL_aPSK; | 887 | *auth |= SSL_aPSK; |
889 | #endif | ||
890 | *mkey |= SSL_kSRP; | 888 | *mkey |= SSL_kSRP; |
891 | /* Check for presence of GOST 34.10 algorithms, and if they | 889 | /* Check for presence of GOST 34.10 algorithms, and if they |
892 | * do not present, disable appropriate auth and key exchange */ | 890 | * do not present, disable appropriate auth and key exchange */ |
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c index 5473690e09..c3169204f6 100644 --- a/src/lib/libssl/src/ssl/ssl_lib.c +++ b/src/lib/libssl/src/ssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.73 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.74 2014/07/11 09:24:44 beck 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 | * |
@@ -349,10 +349,6 @@ SSL_new(SSL_CTX *ctx) | |||
349 | 349 | ||
350 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); | 350 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); |
351 | 351 | ||
352 | #ifndef OPENSSL_NO_PSK | ||
353 | s->psk_client_callback = ctx->psk_client_callback; | ||
354 | s->psk_server_callback = ctx->psk_server_callback; | ||
355 | #endif | ||
356 | 352 | ||
357 | return (s); | 353 | return (s); |
358 | err: | 354 | err: |
@@ -1391,13 +1387,6 @@ ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, unsigned char *p, | |||
1391 | if ((c->algorithm_ssl & SSL_TLSV1_2) && | 1387 | if ((c->algorithm_ssl & SSL_TLSV1_2) && |
1392 | (TLS1_get_client_version(s) < TLS1_2_VERSION)) | 1388 | (TLS1_get_client_version(s) < TLS1_2_VERSION)) |
1393 | continue; | 1389 | continue; |
1394 | #ifndef OPENSSL_NO_PSK | ||
1395 | /* with PSK there must be client callback set */ | ||
1396 | if (((c->algorithm_mkey & SSL_kPSK) || | ||
1397 | (c->algorithm_auth & SSL_aPSK)) && | ||
1398 | s->psk_client_callback == NULL) | ||
1399 | continue; | ||
1400 | #endif /* OPENSSL_NO_PSK */ | ||
1401 | j = put_cb ? put_cb(c, p) : ssl_put_cipher_by_char(s, c, p); | 1390 | j = put_cb ? put_cb(c, p) : ssl_put_cipher_by_char(s, c, p); |
1402 | p += j; | 1391 | p += j; |
1403 | } | 1392 | } |
@@ -1811,11 +1800,6 @@ SSL_CTX_new(const SSL_METHOD *meth) | |||
1811 | ret->next_protos_advertised_cb = 0; | 1800 | ret->next_protos_advertised_cb = 0; |
1812 | ret->next_proto_select_cb = 0; | 1801 | ret->next_proto_select_cb = 0; |
1813 | # endif | 1802 | # endif |
1814 | #ifndef OPENSSL_NO_PSK | ||
1815 | ret->psk_identity_hint = NULL; | ||
1816 | ret->psk_client_callback = NULL; | ||
1817 | ret->psk_server_callback = NULL; | ||
1818 | #endif | ||
1819 | #ifndef OPENSSL_NO_ENGINE | 1803 | #ifndef OPENSSL_NO_ENGINE |
1820 | ret->client_cert_engine = NULL; | 1804 | ret->client_cert_engine = NULL; |
1821 | #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO | 1805 | #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO |
@@ -1902,9 +1886,6 @@ SSL_CTX_free(SSL_CTX *a) | |||
1902 | sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles); | 1886 | sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles); |
1903 | #endif | 1887 | #endif |
1904 | 1888 | ||
1905 | #ifndef OPENSSL_NO_PSK | ||
1906 | free(a->psk_identity_hint); | ||
1907 | #endif | ||
1908 | #ifndef OPENSSL_NO_ENGINE | 1889 | #ifndef OPENSSL_NO_ENGINE |
1909 | if (a->client_cert_engine) | 1890 | if (a->client_cert_engine) |
1910 | ENGINE_finish(a->client_cert_engine); | 1891 | ENGINE_finish(a->client_cert_engine); |
@@ -2048,10 +2029,6 @@ ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher) | |||
2048 | mask_k|=SSL_kEECDH; | 2029 | mask_k|=SSL_kEECDH; |
2049 | } | 2030 | } |
2050 | 2031 | ||
2051 | #ifndef OPENSSL_NO_PSK | ||
2052 | mask_k |= SSL_kPSK; | ||
2053 | mask_a |= SSL_aPSK; | ||
2054 | #endif | ||
2055 | 2032 | ||
2056 | c->mask_k = mask_k; | 2033 | c->mask_k = mask_k; |
2057 | c->mask_a = mask_a; | 2034 | c->mask_a = mask_a; |
@@ -2914,97 +2891,6 @@ SSL_set_tmp_ecdh_callback(SSL *ssl, EC_KEY *(*ecdh)(SSL *ssl, int is_export, | |||
2914 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | 2891 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); |
2915 | } | 2892 | } |
2916 | 2893 | ||
2917 | #ifndef OPENSSL_NO_PSK | ||
2918 | int | ||
2919 | SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint) | ||
2920 | { | ||
2921 | if (identity_hint != NULL && strlen(identity_hint) > | ||
2922 | PSK_MAX_IDENTITY_LEN) { | ||
2923 | SSLerr(SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT, | ||
2924 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2925 | return (0); | ||
2926 | } | ||
2927 | free(ctx->psk_identity_hint); | ||
2928 | if (identity_hint != NULL) { | ||
2929 | ctx->psk_identity_hint = BUF_strdup(identity_hint); | ||
2930 | if (ctx->psk_identity_hint == NULL) | ||
2931 | return (0); | ||
2932 | } else | ||
2933 | ctx->psk_identity_hint = NULL; | ||
2934 | return (1); | ||
2935 | } | ||
2936 | |||
2937 | int | ||
2938 | SSL_use_psk_identity_hint(SSL *s, const char *identity_hint) | ||
2939 | { | ||
2940 | if (s == NULL) | ||
2941 | return (0); | ||
2942 | |||
2943 | if (s->session == NULL) | ||
2944 | return (1); /* session not created yet, ignored */ | ||
2945 | |||
2946 | if (identity_hint != NULL && | ||
2947 | strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) { | ||
2948 | SSLerr(SSL_F_SSL_USE_PSK_IDENTITY_HINT, | ||
2949 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2950 | return (0); | ||
2951 | } | ||
2952 | free(s->session->psk_identity_hint); | ||
2953 | if (identity_hint != NULL) { | ||
2954 | s->session->psk_identity_hint = BUF_strdup(identity_hint); | ||
2955 | if (s->session->psk_identity_hint == NULL) | ||
2956 | return (0); | ||
2957 | } else | ||
2958 | s->session->psk_identity_hint = NULL; | ||
2959 | return (1); | ||
2960 | } | ||
2961 | |||
2962 | const char * | ||
2963 | SSL_get_psk_identity_hint(const SSL *s) | ||
2964 | { | ||
2965 | if (s == NULL || s->session == NULL) | ||
2966 | return (NULL); | ||
2967 | return (s->session->psk_identity_hint); | ||
2968 | } | ||
2969 | |||
2970 | const char * | ||
2971 | SSL_get_psk_identity(const SSL *s) | ||
2972 | { | ||
2973 | if (s == NULL || s->session == NULL) | ||
2974 | return (NULL); | ||
2975 | return (s->session->psk_identity); | ||
2976 | } | ||
2977 | |||
2978 | void | ||
2979 | SSL_set_psk_client_callback(SSL *s, unsigned int (*cb)(SSL *ssl, | ||
2980 | const char *hint, char *identity, unsigned int max_identity_len, | ||
2981 | unsigned char *psk, unsigned int max_psk_len)) | ||
2982 | { | ||
2983 | s->psk_client_callback = cb; | ||
2984 | } | ||
2985 | |||
2986 | void | ||
2987 | SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, unsigned int (*cb)(SSL *ssl, | ||
2988 | const char *hint, char *identity, unsigned int max_identity_len, | ||
2989 | unsigned char *psk, unsigned int max_psk_len)) | ||
2990 | { | ||
2991 | ctx->psk_client_callback = cb; | ||
2992 | } | ||
2993 | |||
2994 | void | ||
2995 | SSL_set_psk_server_callback(SSL *s, unsigned int (*cb)(SSL *ssl, | ||
2996 | const char *identity, unsigned char *psk, unsigned int max_psk_len)) | ||
2997 | { | ||
2998 | s->psk_server_callback = cb; | ||
2999 | } | ||
3000 | |||
3001 | void | ||
3002 | SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, unsigned int (*cb)(SSL *ssl, | ||
3003 | const char *identity, unsigned char *psk, unsigned int max_psk_len)) | ||
3004 | { | ||
3005 | ctx->psk_server_callback = cb; | ||
3006 | } | ||
3007 | #endif | ||
3008 | 2894 | ||
3009 | void | 2895 | void |
3010 | SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, | 2896 | SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, |
diff --git a/src/lib/libssl/src/ssl/ssl_sess.c b/src/lib/libssl/src/ssl/ssl_sess.c index b3dd3e6117..af29cfc7ff 100644 --- a/src/lib/libssl/src/ssl/ssl_sess.c +++ b/src/lib/libssl/src/ssl/ssl_sess.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_sess.c,v 1.35 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_sess.c,v 1.36 2014/07/11 09:24:44 beck 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 | * |
@@ -214,10 +214,6 @@ SSL_SESSION_new(void) | |||
214 | ss->tlsext_ellipticcurvelist_length = 0; | 214 | ss->tlsext_ellipticcurvelist_length = 0; |
215 | ss->tlsext_ellipticcurvelist = NULL; | 215 | ss->tlsext_ellipticcurvelist = NULL; |
216 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); | 216 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); |
217 | #ifndef OPENSSL_NO_PSK | ||
218 | ss->psk_identity_hint = NULL; | ||
219 | ss->psk_identity = NULL; | ||
220 | #endif | ||
221 | return (ss); | 217 | return (ss); |
222 | } | 218 | } |
223 | 219 | ||
@@ -690,10 +686,6 @@ SSL_SESSION_free(SSL_SESSION *ss) | |||
690 | free(ss->tlsext_ecpointformatlist); | 686 | free(ss->tlsext_ecpointformatlist); |
691 | ss->tlsext_ellipticcurvelist_length = 0; | 687 | ss->tlsext_ellipticcurvelist_length = 0; |
692 | free(ss->tlsext_ellipticcurvelist); | 688 | free(ss->tlsext_ellipticcurvelist); |
693 | #ifndef OPENSSL_NO_PSK | ||
694 | free(ss->psk_identity_hint); | ||
695 | free(ss->psk_identity); | ||
696 | #endif | ||
697 | OPENSSL_cleanse(ss, sizeof(*ss)); | 689 | OPENSSL_cleanse(ss, sizeof(*ss)); |
698 | free(ss); | 690 | free(ss); |
699 | } | 691 | } |
diff --git a/src/lib/libssl/src/ssl/ssl_txt.c b/src/lib/libssl/src/ssl/ssl_txt.c index 25f2290290..950620d300 100644 --- a/src/lib/libssl/src/ssl/ssl_txt.c +++ b/src/lib/libssl/src/ssl/ssl_txt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_txt.c,v 1.22 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_txt.c,v 1.23 2014/07/11 09:24:44 beck 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 | * |
@@ -159,16 +159,6 @@ SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) | |||
159 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) | 159 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) |
160 | goto err; | 160 | goto err; |
161 | } | 161 | } |
162 | #ifndef OPENSSL_NO_PSK | ||
163 | if (BIO_puts(bp, "\n PSK identity: ") <= 0) | ||
164 | goto err; | ||
165 | if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0) | ||
166 | goto err; | ||
167 | if (BIO_puts(bp, "\n PSK identity hint: ") <= 0) | ||
168 | goto err; | ||
169 | if (BIO_printf(bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0) | ||
170 | goto err; | ||
171 | #endif | ||
172 | if (x->tlsext_tick_lifetime_hint) { | 162 | if (x->tlsext_tick_lifetime_hint) { |
173 | if (BIO_printf(bp, | 163 | if (BIO_printf(bp, |
174 | "\n TLS session ticket lifetime hint: %ld (seconds)", | 164 | "\n TLS session ticket lifetime hint: %ld (seconds)", |
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h index 0301fd0b96..5ea440231a 100644 --- a/src/lib/libssl/ssl.h +++ b/src/lib/libssl/ssl.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl.h,v 1.60 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl.h,v 1.61 2014/07/11 09:24:44 beck 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 | * |
@@ -460,10 +460,6 @@ struct ssl_session_st { | |||
460 | unsigned int sid_ctx_length; | 460 | unsigned int sid_ctx_length; |
461 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; | 461 | unsigned char sid_ctx[SSL_MAX_SID_CTX_LENGTH]; |
462 | 462 | ||
463 | #ifndef OPENSSL_NO_PSK | ||
464 | char *psk_identity_hint; | ||
465 | char *psk_identity; | ||
466 | #endif | ||
467 | /* Used to indicate that session resumption is not allowed. | 463 | /* Used to indicate that session resumption is not allowed. |
468 | * Applications can also set this bit for a new session via | 464 | * Applications can also set this bit for a new session via |
469 | * not_resumable_session_cb to disable session caching and tickets. */ | 465 | * not_resumable_session_cb to disable session caching and tickets. */ |
@@ -835,14 +831,6 @@ struct ssl_ctx_st { | |||
835 | int (*tlsext_status_cb)(SSL *ssl, void *arg); | 831 | int (*tlsext_status_cb)(SSL *ssl, void *arg); |
836 | void *tlsext_status_arg; | 832 | void *tlsext_status_arg; |
837 | 833 | ||
838 | #ifndef OPENSSL_NO_PSK | ||
839 | char *psk_identity_hint; | ||
840 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
841 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
842 | unsigned int max_psk_len); | ||
843 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
844 | unsigned char *psk, unsigned int max_psk_len); | ||
845 | #endif | ||
846 | 834 | ||
847 | 835 | ||
848 | 836 | ||
@@ -955,30 +943,6 @@ void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, | |||
955 | #define OPENSSL_NPN_NO_OVERLAP 2 | 943 | #define OPENSSL_NPN_NO_OVERLAP 2 |
956 | #endif | 944 | #endif |
957 | 945 | ||
958 | #ifndef OPENSSL_NO_PSK | ||
959 | /* the maximum length of the buffer given to callbacks containing the | ||
960 | * resulting identity/psk */ | ||
961 | #define PSK_MAX_IDENTITY_LEN 128 | ||
962 | #define PSK_MAX_PSK_LEN 256 | ||
963 | void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, | ||
964 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
965 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
966 | unsigned int max_psk_len)); | ||
967 | void SSL_set_psk_client_callback(SSL *ssl, | ||
968 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
969 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
970 | unsigned int max_psk_len)); | ||
971 | void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, | ||
972 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
973 | unsigned char *psk, unsigned int max_psk_len)); | ||
974 | void SSL_set_psk_server_callback(SSL *ssl, | ||
975 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
976 | unsigned char *psk, unsigned int max_psk_len)); | ||
977 | int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); | ||
978 | int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); | ||
979 | const char *SSL_get_psk_identity_hint(const SSL *s); | ||
980 | const char *SSL_get_psk_identity(const SSL *s); | ||
981 | #endif | ||
982 | 946 | ||
983 | #define SSL_NOTHING 1 | 947 | #define SSL_NOTHING 1 |
984 | #define SSL_WRITING 2 | 948 | #define SSL_WRITING 2 |
@@ -1123,13 +1087,6 @@ struct ssl_st { | |||
1123 | int error_code; /* actual code */ | 1087 | int error_code; /* actual code */ |
1124 | 1088 | ||
1125 | 1089 | ||
1126 | #ifndef OPENSSL_NO_PSK | ||
1127 | unsigned int (*psk_client_callback)(SSL *ssl, const char *hint, | ||
1128 | char *identity, unsigned int max_identity_len, unsigned char *psk, | ||
1129 | unsigned int max_psk_len); | ||
1130 | unsigned int (*psk_server_callback)(SSL *ssl, const char *identity, | ||
1131 | unsigned char *psk, unsigned int max_psk_len); | ||
1132 | #endif | ||
1133 | 1090 | ||
1134 | SSL_CTX *ctx; | 1091 | SSL_CTX *ctx; |
1135 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() | 1092 | /* set this flag to 1 and a sleep(1) is put into all SSL_read() |
diff --git a/src/lib/libssl/ssl_asn1.c b/src/lib/libssl/ssl_asn1.c index 43366b33b8..dd958d6570 100644 --- a/src/lib/libssl/ssl_asn1.c +++ b/src/lib/libssl/ssl_asn1.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_asn1.c,v 1.27 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_asn1.c,v 1.28 2014/07/11 09:24:44 beck 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 | * |
@@ -103,17 +103,13 @@ typedef struct ssl_session_asn1_st { | |||
103 | ASN1_OCTET_STRING tlsext_hostname; | 103 | ASN1_OCTET_STRING tlsext_hostname; |
104 | ASN1_INTEGER tlsext_tick_lifetime; | 104 | ASN1_INTEGER tlsext_tick_lifetime; |
105 | ASN1_OCTET_STRING tlsext_tick; | 105 | ASN1_OCTET_STRING tlsext_tick; |
106 | #ifndef OPENSSL_NO_PSK | ||
107 | ASN1_OCTET_STRING psk_identity_hint; | ||
108 | ASN1_OCTET_STRING psk_identity; | ||
109 | #endif /* OPENSSL_NO_PSK */ | ||
110 | } SSL_SESSION_ASN1; | 106 | } SSL_SESSION_ASN1; |
111 | 107 | ||
112 | int | 108 | int |
113 | i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | 109 | i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) |
114 | { | 110 | { |
115 | #define LSIZE2 (sizeof(long)*2) | 111 | #define LSIZE2 (sizeof(long)*2) |
116 | int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v7 = 0, v8 = 0; | 112 | int v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0; |
117 | unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; | 113 | unsigned char buf[4], ibuf1[LSIZE2], ibuf2[LSIZE2]; |
118 | unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; | 114 | unsigned char ibuf3[LSIZE2], ibuf4[LSIZE2], ibuf5[LSIZE2]; |
119 | int v6 = 0, v9 = 0, v10 = 0; | 115 | int v6 = 0, v9 = 0, v10 = 0; |
@@ -202,18 +198,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
202 | a.tlsext_tick_lifetime.data = ibuf6; | 198 | a.tlsext_tick_lifetime.data = ibuf6; |
203 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); | 199 | ASN1_INTEGER_set(&a.tlsext_tick_lifetime, in->tlsext_tick_lifetime_hint); |
204 | } | 200 | } |
205 | #ifndef OPENSSL_NO_PSK | ||
206 | if (in->psk_identity_hint) { | ||
207 | a.psk_identity_hint.length = strlen(in->psk_identity_hint); | ||
208 | a.psk_identity_hint.type = V_ASN1_OCTET_STRING; | ||
209 | a.psk_identity_hint.data = (unsigned char *)(in->psk_identity_hint); | ||
210 | } | ||
211 | if (in->psk_identity) { | ||
212 | a.psk_identity.length = strlen(in->psk_identity); | ||
213 | a.psk_identity.type = V_ASN1_OCTET_STRING; | ||
214 | a.psk_identity.data = (unsigned char *)(in->psk_identity); | ||
215 | } | ||
216 | #endif /* OPENSSL_NO_PSK */ | ||
217 | 201 | ||
218 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); | 202 | M_ASN1_I2D_len(&(a.version), i2d_ASN1_INTEGER); |
219 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); | 203 | M_ASN1_I2D_len(&(a.ssl_version), i2d_ASN1_INTEGER); |
@@ -236,12 +220,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
236 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); | 220 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_tick), i2d_ASN1_OCTET_STRING, 10, v10); |
237 | if (in->tlsext_hostname) | 221 | if (in->tlsext_hostname) |
238 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); | 222 | M_ASN1_I2D_len_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
239 | #ifndef OPENSSL_NO_PSK | ||
240 | if (in->psk_identity_hint) | ||
241 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); | ||
242 | if (in->psk_identity) | ||
243 | M_ASN1_I2D_len_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); | ||
244 | #endif /* OPENSSL_NO_PSK */ | ||
245 | 223 | ||
246 | M_ASN1_I2D_seq_total(); | 224 | M_ASN1_I2D_seq_total(); |
247 | 225 | ||
@@ -262,12 +240,6 @@ i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp) | |||
262 | M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); | 240 | M_ASN1_I2D_put_EXP_opt(&a.verify_result, i2d_ASN1_INTEGER, 5, v5); |
263 | if (in->tlsext_hostname) | 241 | if (in->tlsext_hostname) |
264 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); | 242 | M_ASN1_I2D_put_EXP_opt(&(a.tlsext_hostname), i2d_ASN1_OCTET_STRING, 6, v6); |
265 | #ifndef OPENSSL_NO_PSK | ||
266 | if (in->psk_identity_hint) | ||
267 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity_hint), i2d_ASN1_OCTET_STRING, 7, v7); | ||
268 | if (in->psk_identity) | ||
269 | M_ASN1_I2D_put_EXP_opt(&(a.psk_identity), i2d_ASN1_OCTET_STRING, 8, v8); | ||
270 | #endif /* OPENSSL_NO_PSK */ | ||
271 | if (in->tlsext_tick_lifetime_hint > 0) | 243 | if (in->tlsext_tick_lifetime_hint > 0) |
272 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); | 244 | M_ASN1_I2D_put_EXP_opt(&a.tlsext_tick_lifetime, i2d_ASN1_INTEGER, 9, v9); |
273 | if (in->tlsext_tick) | 245 | if (in->tlsext_tick) |
@@ -415,29 +387,6 @@ d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, long length) | |||
415 | } else | 387 | } else |
416 | ret->tlsext_hostname = NULL; | 388 | ret->tlsext_hostname = NULL; |
417 | 389 | ||
418 | #ifndef OPENSSL_NO_PSK | ||
419 | os.length = 0; | ||
420 | os.data = NULL; | ||
421 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 7); | ||
422 | if (os.data) { | ||
423 | ret->psk_identity_hint = BUF_strndup((char *)os.data, os.length); | ||
424 | free(os.data); | ||
425 | os.data = NULL; | ||
426 | os.length = 0; | ||
427 | } else | ||
428 | ret->psk_identity_hint = NULL; | ||
429 | |||
430 | os.length = 0; | ||
431 | os.data = NULL; | ||
432 | M_ASN1_D2I_get_EXP_opt(osp, d2i_ASN1_OCTET_STRING, 8); | ||
433 | if (os.data) { | ||
434 | ret->psk_identity = BUF_strndup((char *)os.data, os.length); | ||
435 | free(os.data); | ||
436 | os.data = NULL; | ||
437 | os.length = 0; | ||
438 | } else | ||
439 | ret->psk_identity = NULL; | ||
440 | #endif /* OPENSSL_NO_PSK */ | ||
441 | 390 | ||
442 | ai.length = 0; | 391 | ai.length = 0; |
443 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); | 392 | M_ASN1_D2I_get_EXP_opt(aip, d2i_ASN1_INTEGER, 9); |
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index 92d2417cb9..a79eafc9cf 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/lib/libssl/ssl_ciph.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_ciph.c,v 1.62 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_ciph.c,v 1.63 2014/07/11 09:24:44 beck 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 | * |
@@ -883,10 +883,8 @@ ssl_cipher_get_disabled(unsigned long *mkey, unsigned long *auth, unsigned long | |||
883 | *auth |= SSL_aDH; | 883 | *auth |= SSL_aDH; |
884 | *mkey |= SSL_kKRB5; | 884 | *mkey |= SSL_kKRB5; |
885 | *auth |= SSL_aKRB5; | 885 | *auth |= SSL_aKRB5; |
886 | #ifdef OPENSSL_NO_PSK | ||
887 | *mkey |= SSL_kPSK; | 886 | *mkey |= SSL_kPSK; |
888 | *auth |= SSL_aPSK; | 887 | *auth |= SSL_aPSK; |
889 | #endif | ||
890 | *mkey |= SSL_kSRP; | 888 | *mkey |= SSL_kSRP; |
891 | /* Check for presence of GOST 34.10 algorithms, and if they | 889 | /* Check for presence of GOST 34.10 algorithms, and if they |
892 | * do not present, disable appropriate auth and key exchange */ | 890 | * do not present, disable appropriate auth and key exchange */ |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 5473690e09..c3169204f6 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.73 2014/07/10 11:58:08 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.74 2014/07/11 09:24:44 beck 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 | * |
@@ -349,10 +349,6 @@ SSL_new(SSL_CTX *ctx) | |||
349 | 349 | ||
350 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); | 350 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); |
351 | 351 | ||
352 | #ifndef OPENSSL_NO_PSK | ||
353 | s->psk_client_callback = ctx->psk_client_callback; | ||
354 | s->psk_server_callback = ctx->psk_server_callback; | ||
355 | #endif | ||
356 | 352 | ||
357 | return (s); | 353 | return (s); |
358 | err: | 354 | err: |
@@ -1391,13 +1387,6 @@ ssl_cipher_list_to_bytes(SSL *s, STACK_OF(SSL_CIPHER) *sk, unsigned char *p, | |||
1391 | if ((c->algorithm_ssl & SSL_TLSV1_2) && | 1387 | if ((c->algorithm_ssl & SSL_TLSV1_2) && |
1392 | (TLS1_get_client_version(s) < TLS1_2_VERSION)) | 1388 | (TLS1_get_client_version(s) < TLS1_2_VERSION)) |
1393 | continue; | 1389 | continue; |
1394 | #ifndef OPENSSL_NO_PSK | ||
1395 | /* with PSK there must be client callback set */ | ||
1396 | if (((c->algorithm_mkey & SSL_kPSK) || | ||
1397 | (c->algorithm_auth & SSL_aPSK)) && | ||
1398 | s->psk_client_callback == NULL) | ||
1399 | continue; | ||
1400 | #endif /* OPENSSL_NO_PSK */ | ||
1401 | j = put_cb ? put_cb(c, p) : ssl_put_cipher_by_char(s, c, p); | 1390 | j = put_cb ? put_cb(c, p) : ssl_put_cipher_by_char(s, c, p); |
1402 | p += j; | 1391 | p += j; |
1403 | } | 1392 | } |
@@ -1811,11 +1800,6 @@ SSL_CTX_new(const SSL_METHOD *meth) | |||
1811 | ret->next_protos_advertised_cb = 0; | 1800 | ret->next_protos_advertised_cb = 0; |
1812 | ret->next_proto_select_cb = 0; | 1801 | ret->next_proto_select_cb = 0; |
1813 | # endif | 1802 | # endif |
1814 | #ifndef OPENSSL_NO_PSK | ||
1815 | ret->psk_identity_hint = NULL; | ||
1816 | ret->psk_client_callback = NULL; | ||
1817 | ret->psk_server_callback = NULL; | ||
1818 | #endif | ||
1819 | #ifndef OPENSSL_NO_ENGINE | 1803 | #ifndef OPENSSL_NO_ENGINE |
1820 | ret->client_cert_engine = NULL; | 1804 | ret->client_cert_engine = NULL; |
1821 | #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO | 1805 | #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO |
@@ -1902,9 +1886,6 @@ SSL_CTX_free(SSL_CTX *a) | |||
1902 | sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles); | 1886 | sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles); |
1903 | #endif | 1887 | #endif |
1904 | 1888 | ||
1905 | #ifndef OPENSSL_NO_PSK | ||
1906 | free(a->psk_identity_hint); | ||
1907 | #endif | ||
1908 | #ifndef OPENSSL_NO_ENGINE | 1889 | #ifndef OPENSSL_NO_ENGINE |
1909 | if (a->client_cert_engine) | 1890 | if (a->client_cert_engine) |
1910 | ENGINE_finish(a->client_cert_engine); | 1891 | ENGINE_finish(a->client_cert_engine); |
@@ -2048,10 +2029,6 @@ ssl_set_cert_masks(CERT *c, const SSL_CIPHER *cipher) | |||
2048 | mask_k|=SSL_kEECDH; | 2029 | mask_k|=SSL_kEECDH; |
2049 | } | 2030 | } |
2050 | 2031 | ||
2051 | #ifndef OPENSSL_NO_PSK | ||
2052 | mask_k |= SSL_kPSK; | ||
2053 | mask_a |= SSL_aPSK; | ||
2054 | #endif | ||
2055 | 2032 | ||
2056 | c->mask_k = mask_k; | 2033 | c->mask_k = mask_k; |
2057 | c->mask_a = mask_a; | 2034 | c->mask_a = mask_a; |
@@ -2914,97 +2891,6 @@ SSL_set_tmp_ecdh_callback(SSL *ssl, EC_KEY *(*ecdh)(SSL *ssl, int is_export, | |||
2914 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | 2891 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); |
2915 | } | 2892 | } |
2916 | 2893 | ||
2917 | #ifndef OPENSSL_NO_PSK | ||
2918 | int | ||
2919 | SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint) | ||
2920 | { | ||
2921 | if (identity_hint != NULL && strlen(identity_hint) > | ||
2922 | PSK_MAX_IDENTITY_LEN) { | ||
2923 | SSLerr(SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT, | ||
2924 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2925 | return (0); | ||
2926 | } | ||
2927 | free(ctx->psk_identity_hint); | ||
2928 | if (identity_hint != NULL) { | ||
2929 | ctx->psk_identity_hint = BUF_strdup(identity_hint); | ||
2930 | if (ctx->psk_identity_hint == NULL) | ||
2931 | return (0); | ||
2932 | } else | ||
2933 | ctx->psk_identity_hint = NULL; | ||
2934 | return (1); | ||
2935 | } | ||
2936 | |||
2937 | int | ||
2938 | SSL_use_psk_identity_hint(SSL *s, const char *identity_hint) | ||
2939 | { | ||
2940 | if (s == NULL) | ||
2941 | return (0); | ||
2942 | |||
2943 | if (s->session == NULL) | ||
2944 | return (1); /* session not created yet, ignored */ | ||
2945 | |||
2946 | if (identity_hint != NULL && | ||
2947 | strlen(identity_hint) > PSK_MAX_IDENTITY_LEN) { | ||
2948 | SSLerr(SSL_F_SSL_USE_PSK_IDENTITY_HINT, | ||
2949 | SSL_R_DATA_LENGTH_TOO_LONG); | ||
2950 | return (0); | ||
2951 | } | ||
2952 | free(s->session->psk_identity_hint); | ||
2953 | if (identity_hint != NULL) { | ||
2954 | s->session->psk_identity_hint = BUF_strdup(identity_hint); | ||
2955 | if (s->session->psk_identity_hint == NULL) | ||
2956 | return (0); | ||
2957 | } else | ||
2958 | s->session->psk_identity_hint = NULL; | ||
2959 | return (1); | ||
2960 | } | ||
2961 | |||
2962 | const char * | ||
2963 | SSL_get_psk_identity_hint(const SSL *s) | ||
2964 | { | ||
2965 | if (s == NULL || s->session == NULL) | ||
2966 | return (NULL); | ||
2967 | return (s->session->psk_identity_hint); | ||
2968 | } | ||
2969 | |||
2970 | const char * | ||
2971 | SSL_get_psk_identity(const SSL *s) | ||
2972 | { | ||
2973 | if (s == NULL || s->session == NULL) | ||
2974 | return (NULL); | ||
2975 | return (s->session->psk_identity); | ||
2976 | } | ||
2977 | |||
2978 | void | ||
2979 | SSL_set_psk_client_callback(SSL *s, unsigned int (*cb)(SSL *ssl, | ||
2980 | const char *hint, char *identity, unsigned int max_identity_len, | ||
2981 | unsigned char *psk, unsigned int max_psk_len)) | ||
2982 | { | ||
2983 | s->psk_client_callback = cb; | ||
2984 | } | ||
2985 | |||
2986 | void | ||
2987 | SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, unsigned int (*cb)(SSL *ssl, | ||
2988 | const char *hint, char *identity, unsigned int max_identity_len, | ||
2989 | unsigned char *psk, unsigned int max_psk_len)) | ||
2990 | { | ||
2991 | ctx->psk_client_callback = cb; | ||
2992 | } | ||
2993 | |||
2994 | void | ||
2995 | SSL_set_psk_server_callback(SSL *s, unsigned int (*cb)(SSL *ssl, | ||
2996 | const char *identity, unsigned char *psk, unsigned int max_psk_len)) | ||
2997 | { | ||
2998 | s->psk_server_callback = cb; | ||
2999 | } | ||
3000 | |||
3001 | void | ||
3002 | SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, unsigned int (*cb)(SSL *ssl, | ||
3003 | const char *identity, unsigned char *psk, unsigned int max_psk_len)) | ||
3004 | { | ||
3005 | ctx->psk_server_callback = cb; | ||
3006 | } | ||
3007 | #endif | ||
3008 | 2894 | ||
3009 | void | 2895 | void |
3010 | SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, | 2896 | SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, |
diff --git a/src/lib/libssl/ssl_sess.c b/src/lib/libssl/ssl_sess.c index b3dd3e6117..af29cfc7ff 100644 --- a/src/lib/libssl/ssl_sess.c +++ b/src/lib/libssl/ssl_sess.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_sess.c,v 1.35 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_sess.c,v 1.36 2014/07/11 09:24:44 beck 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 | * |
@@ -214,10 +214,6 @@ SSL_SESSION_new(void) | |||
214 | ss->tlsext_ellipticcurvelist_length = 0; | 214 | ss->tlsext_ellipticcurvelist_length = 0; |
215 | ss->tlsext_ellipticcurvelist = NULL; | 215 | ss->tlsext_ellipticcurvelist = NULL; |
216 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); | 216 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, ss, &ss->ex_data); |
217 | #ifndef OPENSSL_NO_PSK | ||
218 | ss->psk_identity_hint = NULL; | ||
219 | ss->psk_identity = NULL; | ||
220 | #endif | ||
221 | return (ss); | 217 | return (ss); |
222 | } | 218 | } |
223 | 219 | ||
@@ -690,10 +686,6 @@ SSL_SESSION_free(SSL_SESSION *ss) | |||
690 | free(ss->tlsext_ecpointformatlist); | 686 | free(ss->tlsext_ecpointformatlist); |
691 | ss->tlsext_ellipticcurvelist_length = 0; | 687 | ss->tlsext_ellipticcurvelist_length = 0; |
692 | free(ss->tlsext_ellipticcurvelist); | 688 | free(ss->tlsext_ellipticcurvelist); |
693 | #ifndef OPENSSL_NO_PSK | ||
694 | free(ss->psk_identity_hint); | ||
695 | free(ss->psk_identity); | ||
696 | #endif | ||
697 | OPENSSL_cleanse(ss, sizeof(*ss)); | 689 | OPENSSL_cleanse(ss, sizeof(*ss)); |
698 | free(ss); | 690 | free(ss); |
699 | } | 691 | } |
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c index 25f2290290..950620d300 100644 --- a/src/lib/libssl/ssl_txt.c +++ b/src/lib/libssl/ssl_txt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_txt.c,v 1.22 2014/07/10 08:51:15 tedu Exp $ */ | 1 | /* $OpenBSD: ssl_txt.c,v 1.23 2014/07/11 09:24:44 beck 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 | * |
@@ -159,16 +159,6 @@ SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) | |||
159 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) | 159 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) |
160 | goto err; | 160 | goto err; |
161 | } | 161 | } |
162 | #ifndef OPENSSL_NO_PSK | ||
163 | if (BIO_puts(bp, "\n PSK identity: ") <= 0) | ||
164 | goto err; | ||
165 | if (BIO_printf(bp, "%s", x->psk_identity ? x->psk_identity : "None") <= 0) | ||
166 | goto err; | ||
167 | if (BIO_puts(bp, "\n PSK identity hint: ") <= 0) | ||
168 | goto err; | ||
169 | if (BIO_printf(bp, "%s", x->psk_identity_hint ? x->psk_identity_hint : "None") <= 0) | ||
170 | goto err; | ||
171 | #endif | ||
172 | if (x->tlsext_tick_lifetime_hint) { | 162 | if (x->tlsext_tick_lifetime_hint) { |
173 | if (BIO_printf(bp, | 163 | if (BIO_printf(bp, |
174 | "\n TLS session ticket lifetime hint: %ld (seconds)", | 164 | "\n TLS session ticket lifetime hint: %ld (seconds)", |