diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/src/ssl/s3_enc.c | 265 | ||||
| -rw-r--r-- | src/lib/libssl/src/ssl/t1_enc.c | 124 | ||||
| -rw-r--r-- | src/lib/libssl/ssl/Makefile | 4 | ||||
| -rw-r--r-- | src/lib/libssl/t1_enc.c | 124 |
4 files changed, 248 insertions, 269 deletions
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c deleted file mode 100644 index 2717d24398..0000000000 --- a/src/lib/libssl/src/ssl/s3_enc.c +++ /dev/null | |||
| @@ -1,265 +0,0 @@ | |||
| 1 | /* $OpenBSD: s3_enc.c,v 1.70 2015/09/11 17:11:53 jsing Exp $ */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | /* ==================================================================== | ||
| 59 | * Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved. | ||
| 60 | * | ||
| 61 | * Redistribution and use in source and binary forms, with or without | ||
| 62 | * modification, are permitted provided that the following conditions | ||
| 63 | * are met: | ||
| 64 | * | ||
| 65 | * 1. Redistributions of source code must retain the above copyright | ||
| 66 | * notice, this list of conditions and the following disclaimer. | ||
| 67 | * | ||
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 69 | * notice, this list of conditions and the following disclaimer in | ||
| 70 | * the documentation and/or other materials provided with the | ||
| 71 | * distribution. | ||
| 72 | * | ||
| 73 | * 3. All advertising materials mentioning features or use of this | ||
| 74 | * software must display the following acknowledgment: | ||
| 75 | * "This product includes software developed by the OpenSSL Project | ||
| 76 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 77 | * | ||
| 78 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 79 | * endorse or promote products derived from this software without | ||
| 80 | * prior written permission. For written permission, please contact | ||
| 81 | * openssl-core@openssl.org. | ||
| 82 | * | ||
| 83 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 84 | * nor may "OpenSSL" appear in their names without prior written | ||
| 85 | * permission of the OpenSSL Project. | ||
| 86 | * | ||
| 87 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 88 | * acknowledgment: | ||
| 89 | * "This product includes software developed by the OpenSSL Project | ||
| 90 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 91 | * | ||
| 92 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 93 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 94 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 95 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 96 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 97 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 98 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 99 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 101 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 102 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 103 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 104 | * ==================================================================== | ||
| 105 | * | ||
| 106 | * This product includes cryptographic software written by Eric Young | ||
| 107 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 108 | * Hudson (tjh@cryptsoft.com). | ||
| 109 | * | ||
| 110 | */ | ||
| 111 | /* ==================================================================== | ||
| 112 | * Copyright 2005 Nokia. All rights reserved. | ||
| 113 | * | ||
| 114 | * The portions of the attached software ("Contribution") is developed by | ||
| 115 | * Nokia Corporation and is licensed pursuant to the OpenSSL open source | ||
| 116 | * license. | ||
| 117 | * | ||
| 118 | * The Contribution, originally written by Mika Kousa and Pasi Eronen of | ||
| 119 | * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites | ||
| 120 | * support (see RFC 4279) to OpenSSL. | ||
| 121 | * | ||
| 122 | * No patent licenses or other rights except those expressly stated in | ||
| 123 | * the OpenSSL open source license shall be deemed granted or received | ||
| 124 | * expressly, by implication, estoppel, or otherwise. | ||
| 125 | * | ||
| 126 | * No assurances are provided by Nokia that the Contribution does not | ||
| 127 | * infringe the patent or other intellectual property rights of any third | ||
| 128 | * party or that the license provides you with all the necessary rights | ||
| 129 | * to make use of the Contribution. | ||
| 130 | * | ||
| 131 | * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN | ||
| 132 | * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA | ||
| 133 | * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY | ||
| 134 | * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR | ||
| 135 | * OTHERWISE. | ||
| 136 | */ | ||
| 137 | |||
| 138 | #include <stdio.h> | ||
| 139 | |||
| 140 | #include "ssl_locl.h" | ||
| 141 | |||
| 142 | #include <openssl/evp.h> | ||
| 143 | #include <openssl/md5.h> | ||
| 144 | |||
| 145 | void | ||
| 146 | ssl3_cleanup_key_block(SSL *s) | ||
| 147 | { | ||
| 148 | if (s->s3->tmp.key_block != NULL) { | ||
| 149 | explicit_bzero(s->s3->tmp.key_block, | ||
| 150 | s->s3->tmp.key_block_length); | ||
| 151 | free(s->s3->tmp.key_block); | ||
| 152 | s->s3->tmp.key_block = NULL; | ||
| 153 | } | ||
| 154 | s->s3->tmp.key_block_length = 0; | ||
| 155 | } | ||
| 156 | |||
| 157 | int | ||
| 158 | ssl3_init_finished_mac(SSL *s) | ||
| 159 | { | ||
| 160 | BIO_free(s->s3->handshake_buffer); | ||
| 161 | ssl3_free_digest_list(s); | ||
| 162 | |||
| 163 | s->s3->handshake_buffer = BIO_new(BIO_s_mem()); | ||
| 164 | if (s->s3->handshake_buffer == NULL) | ||
| 165 | return (0); | ||
| 166 | |||
| 167 | (void)BIO_set_close(s->s3->handshake_buffer, BIO_CLOSE); | ||
| 168 | |||
| 169 | return (1); | ||
| 170 | } | ||
| 171 | |||
| 172 | void | ||
| 173 | ssl3_free_digest_list(SSL *s) | ||
| 174 | { | ||
| 175 | int i; | ||
| 176 | |||
| 177 | if (s == NULL) | ||
| 178 | return; | ||
| 179 | |||
| 180 | if (s->s3->handshake_dgst == NULL) | ||
| 181 | return; | ||
| 182 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 183 | if (s->s3->handshake_dgst[i]) | ||
| 184 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 185 | } | ||
| 186 | free(s->s3->handshake_dgst); | ||
| 187 | s->s3->handshake_dgst = NULL; | ||
| 188 | } | ||
| 189 | |||
| 190 | void | ||
| 191 | ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) | ||
| 192 | { | ||
| 193 | if (s->s3->handshake_buffer && | ||
| 194 | !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 195 | BIO_write(s->s3->handshake_buffer, (void *)buf, len); | ||
| 196 | } else { | ||
| 197 | int i; | ||
| 198 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 199 | if (s->s3->handshake_dgst[i]!= NULL) | ||
| 200 | EVP_DigestUpdate(s->s3->handshake_dgst[i], buf, len); | ||
| 201 | } | ||
| 202 | } | ||
| 203 | } | ||
| 204 | |||
| 205 | int | ||
| 206 | ssl3_digest_cached_records(SSL *s) | ||
| 207 | { | ||
| 208 | int i; | ||
| 209 | long mask; | ||
| 210 | const EVP_MD *md; | ||
| 211 | long hdatalen; | ||
| 212 | void *hdata; | ||
| 213 | |||
| 214 | ssl3_free_digest_list(s); | ||
| 215 | |||
| 216 | s->s3->handshake_dgst = calloc(SSL_MAX_DIGEST, sizeof(EVP_MD_CTX *)); | ||
| 217 | if (s->s3->handshake_dgst == NULL) { | ||
| 218 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE); | ||
| 219 | return 0; | ||
| 220 | } | ||
| 221 | hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); | ||
| 222 | if (hdatalen <= 0) { | ||
| 223 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 224 | SSL_R_BAD_HANDSHAKE_LENGTH); | ||
| 225 | return 0; | ||
| 226 | } | ||
| 227 | |||
| 228 | /* Loop through bits of the algorithm2 field and create MD contexts. */ | ||
| 229 | for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { | ||
| 230 | if ((mask & ssl_get_algorithm2(s)) && md) { | ||
| 231 | s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); | ||
| 232 | if (s->s3->handshake_dgst[i] == NULL) { | ||
| 233 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 234 | ERR_R_MALLOC_FAILURE); | ||
| 235 | return 0; | ||
| 236 | } | ||
| 237 | if (!EVP_DigestInit_ex(s->s3->handshake_dgst[i], | ||
| 238 | md, NULL)) { | ||
| 239 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 240 | return 0; | ||
| 241 | } | ||
| 242 | if (!EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, | ||
| 243 | hdatalen)) | ||
| 244 | return 0; | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | if (!(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 249 | BIO_free(s->s3->handshake_buffer); | ||
| 250 | s->s3->handshake_buffer = NULL; | ||
| 251 | } | ||
| 252 | |||
| 253 | return 1; | ||
| 254 | } | ||
| 255 | |||
| 256 | void | ||
| 257 | ssl3_record_sequence_increment(unsigned char *seq) | ||
| 258 | { | ||
| 259 | int i; | ||
| 260 | |||
| 261 | for (i = SSL3_SEQUENCE_SIZE - 1; i >= 0; i--) { | ||
| 262 | if (++seq[i] != 0) | ||
| 263 | break; | ||
| 264 | } | ||
| 265 | } | ||
diff --git a/src/lib/libssl/src/ssl/t1_enc.c b/src/lib/libssl/src/ssl/t1_enc.c index 5d2b8eaf89..892fc31796 100644 --- a/src/lib/libssl/src/ssl/t1_enc.c +++ b/src/lib/libssl/src/ssl/t1_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: t1_enc.c,v 1.81 2015/09/10 15:56:26 jsing Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.82 2015/09/11 17:54:23 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -143,6 +143,128 @@ | |||
| 143 | #include <openssl/hmac.h> | 143 | #include <openssl/hmac.h> |
| 144 | #include <openssl/md5.h> | 144 | #include <openssl/md5.h> |
| 145 | 145 | ||
| 146 | void | ||
| 147 | ssl3_cleanup_key_block(SSL *s) | ||
| 148 | { | ||
| 149 | if (s->s3->tmp.key_block != NULL) { | ||
| 150 | explicit_bzero(s->s3->tmp.key_block, | ||
| 151 | s->s3->tmp.key_block_length); | ||
| 152 | free(s->s3->tmp.key_block); | ||
| 153 | s->s3->tmp.key_block = NULL; | ||
| 154 | } | ||
| 155 | s->s3->tmp.key_block_length = 0; | ||
| 156 | } | ||
| 157 | |||
| 158 | int | ||
| 159 | ssl3_init_finished_mac(SSL *s) | ||
| 160 | { | ||
| 161 | BIO_free(s->s3->handshake_buffer); | ||
| 162 | ssl3_free_digest_list(s); | ||
| 163 | |||
| 164 | s->s3->handshake_buffer = BIO_new(BIO_s_mem()); | ||
| 165 | if (s->s3->handshake_buffer == NULL) | ||
| 166 | return (0); | ||
| 167 | |||
| 168 | (void)BIO_set_close(s->s3->handshake_buffer, BIO_CLOSE); | ||
| 169 | |||
| 170 | return (1); | ||
| 171 | } | ||
| 172 | |||
| 173 | void | ||
| 174 | ssl3_free_digest_list(SSL *s) | ||
| 175 | { | ||
| 176 | int i; | ||
| 177 | |||
| 178 | if (s == NULL) | ||
| 179 | return; | ||
| 180 | |||
| 181 | if (s->s3->handshake_dgst == NULL) | ||
| 182 | return; | ||
| 183 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 184 | if (s->s3->handshake_dgst[i]) | ||
| 185 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 186 | } | ||
| 187 | free(s->s3->handshake_dgst); | ||
| 188 | s->s3->handshake_dgst = NULL; | ||
| 189 | } | ||
| 190 | |||
| 191 | void | ||
| 192 | ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) | ||
| 193 | { | ||
| 194 | if (s->s3->handshake_buffer && | ||
| 195 | !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 196 | BIO_write(s->s3->handshake_buffer, (void *)buf, len); | ||
| 197 | } else { | ||
| 198 | int i; | ||
| 199 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 200 | if (s->s3->handshake_dgst[i]!= NULL) | ||
| 201 | EVP_DigestUpdate(s->s3->handshake_dgst[i], buf, len); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | int | ||
| 207 | ssl3_digest_cached_records(SSL *s) | ||
| 208 | { | ||
| 209 | int i; | ||
| 210 | long mask; | ||
| 211 | const EVP_MD *md; | ||
| 212 | long hdatalen; | ||
| 213 | void *hdata; | ||
| 214 | |||
| 215 | ssl3_free_digest_list(s); | ||
| 216 | |||
| 217 | s->s3->handshake_dgst = calloc(SSL_MAX_DIGEST, sizeof(EVP_MD_CTX *)); | ||
| 218 | if (s->s3->handshake_dgst == NULL) { | ||
| 219 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE); | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); | ||
| 223 | if (hdatalen <= 0) { | ||
| 224 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 225 | SSL_R_BAD_HANDSHAKE_LENGTH); | ||
| 226 | return 0; | ||
| 227 | } | ||
| 228 | |||
| 229 | /* Loop through bits of the algorithm2 field and create MD contexts. */ | ||
| 230 | for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { | ||
| 231 | if ((mask & ssl_get_algorithm2(s)) && md) { | ||
| 232 | s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); | ||
| 233 | if (s->s3->handshake_dgst[i] == NULL) { | ||
| 234 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 235 | ERR_R_MALLOC_FAILURE); | ||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | if (!EVP_DigestInit_ex(s->s3->handshake_dgst[i], | ||
| 239 | md, NULL)) { | ||
| 240 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 241 | return 0; | ||
| 242 | } | ||
| 243 | if (!EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, | ||
| 244 | hdatalen)) | ||
| 245 | return 0; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | if (!(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 250 | BIO_free(s->s3->handshake_buffer); | ||
| 251 | s->s3->handshake_buffer = NULL; | ||
| 252 | } | ||
| 253 | |||
| 254 | return 1; | ||
| 255 | } | ||
| 256 | |||
| 257 | void | ||
| 258 | ssl3_record_sequence_increment(unsigned char *seq) | ||
| 259 | { | ||
| 260 | int i; | ||
| 261 | |||
| 262 | for (i = SSL3_SEQUENCE_SIZE - 1; i >= 0; i--) { | ||
| 263 | if (++seq[i] != 0) | ||
| 264 | break; | ||
| 265 | } | ||
| 266 | } | ||
| 267 | |||
| 146 | /* seed1 through seed5 are virtually concatenated */ | 268 | /* seed1 through seed5 are virtually concatenated */ |
| 147 | static int | 269 | static int |
| 148 | tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, | 270 | tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, |
diff --git a/src/lib/libssl/ssl/Makefile b/src/lib/libssl/ssl/Makefile index a9f1870c4e..e7303be03b 100644 --- a/src/lib/libssl/ssl/Makefile +++ b/src/lib/libssl/ssl/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.55 2015/09/11 14:52:17 jsing Exp $ | 1 | # $OpenBSD: Makefile,v 1.56 2015/09/11 17:54:23 jsing Exp $ |
| 2 | 2 | ||
| 3 | LIB= ssl | 3 | LIB= ssl |
| 4 | 4 | ||
| @@ -16,7 +16,7 @@ CFLAGS+= -I${SSL_SRC} | |||
| 16 | LDADD+= -L${BSDOBJDIR}/lib/libcrypto/crypto -lcrypto | 16 | LDADD+= -L${BSDOBJDIR}/lib/libcrypto/crypto -lcrypto |
| 17 | 17 | ||
| 18 | SRCS=\ | 18 | SRCS=\ |
| 19 | s3_srvr.c s3_clnt.c s3_lib.c s3_enc.c s3_pkt.c s3_both.c \ | 19 | s3_srvr.c s3_clnt.c s3_lib.c s3_pkt.c s3_both.c \ |
| 20 | s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \ | 20 | s23_srvr.c s23_clnt.c s23_lib.c s23_pkt.c \ |
| 21 | t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \ | 21 | t1_meth.c t1_srvr.c t1_clnt.c t1_lib.c t1_enc.c \ |
| 22 | d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \ | 22 | d1_meth.c d1_srvr.c d1_clnt.c d1_lib.c d1_pkt.c \ |
diff --git a/src/lib/libssl/t1_enc.c b/src/lib/libssl/t1_enc.c index 5d2b8eaf89..892fc31796 100644 --- a/src/lib/libssl/t1_enc.c +++ b/src/lib/libssl/t1_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: t1_enc.c,v 1.81 2015/09/10 15:56:26 jsing Exp $ */ | 1 | /* $OpenBSD: t1_enc.c,v 1.82 2015/09/11 17:54:23 jsing Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -143,6 +143,128 @@ | |||
| 143 | #include <openssl/hmac.h> | 143 | #include <openssl/hmac.h> |
| 144 | #include <openssl/md5.h> | 144 | #include <openssl/md5.h> |
| 145 | 145 | ||
| 146 | void | ||
| 147 | ssl3_cleanup_key_block(SSL *s) | ||
| 148 | { | ||
| 149 | if (s->s3->tmp.key_block != NULL) { | ||
| 150 | explicit_bzero(s->s3->tmp.key_block, | ||
| 151 | s->s3->tmp.key_block_length); | ||
| 152 | free(s->s3->tmp.key_block); | ||
| 153 | s->s3->tmp.key_block = NULL; | ||
| 154 | } | ||
| 155 | s->s3->tmp.key_block_length = 0; | ||
| 156 | } | ||
| 157 | |||
| 158 | int | ||
| 159 | ssl3_init_finished_mac(SSL *s) | ||
| 160 | { | ||
| 161 | BIO_free(s->s3->handshake_buffer); | ||
| 162 | ssl3_free_digest_list(s); | ||
| 163 | |||
| 164 | s->s3->handshake_buffer = BIO_new(BIO_s_mem()); | ||
| 165 | if (s->s3->handshake_buffer == NULL) | ||
| 166 | return (0); | ||
| 167 | |||
| 168 | (void)BIO_set_close(s->s3->handshake_buffer, BIO_CLOSE); | ||
| 169 | |||
| 170 | return (1); | ||
| 171 | } | ||
| 172 | |||
| 173 | void | ||
| 174 | ssl3_free_digest_list(SSL *s) | ||
| 175 | { | ||
| 176 | int i; | ||
| 177 | |||
| 178 | if (s == NULL) | ||
| 179 | return; | ||
| 180 | |||
| 181 | if (s->s3->handshake_dgst == NULL) | ||
| 182 | return; | ||
| 183 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 184 | if (s->s3->handshake_dgst[i]) | ||
| 185 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 186 | } | ||
| 187 | free(s->s3->handshake_dgst); | ||
| 188 | s->s3->handshake_dgst = NULL; | ||
| 189 | } | ||
| 190 | |||
| 191 | void | ||
| 192 | ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) | ||
| 193 | { | ||
| 194 | if (s->s3->handshake_buffer && | ||
| 195 | !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 196 | BIO_write(s->s3->handshake_buffer, (void *)buf, len); | ||
| 197 | } else { | ||
| 198 | int i; | ||
| 199 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | ||
| 200 | if (s->s3->handshake_dgst[i]!= NULL) | ||
| 201 | EVP_DigestUpdate(s->s3->handshake_dgst[i], buf, len); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | } | ||
| 205 | |||
| 206 | int | ||
| 207 | ssl3_digest_cached_records(SSL *s) | ||
| 208 | { | ||
| 209 | int i; | ||
| 210 | long mask; | ||
| 211 | const EVP_MD *md; | ||
| 212 | long hdatalen; | ||
| 213 | void *hdata; | ||
| 214 | |||
| 215 | ssl3_free_digest_list(s); | ||
| 216 | |||
| 217 | s->s3->handshake_dgst = calloc(SSL_MAX_DIGEST, sizeof(EVP_MD_CTX *)); | ||
| 218 | if (s->s3->handshake_dgst == NULL) { | ||
| 219 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE); | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | hdatalen = BIO_get_mem_data(s->s3->handshake_buffer, &hdata); | ||
| 223 | if (hdatalen <= 0) { | ||
| 224 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 225 | SSL_R_BAD_HANDSHAKE_LENGTH); | ||
| 226 | return 0; | ||
| 227 | } | ||
| 228 | |||
| 229 | /* Loop through bits of the algorithm2 field and create MD contexts. */ | ||
| 230 | for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { | ||
| 231 | if ((mask & ssl_get_algorithm2(s)) && md) { | ||
| 232 | s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); | ||
| 233 | if (s->s3->handshake_dgst[i] == NULL) { | ||
| 234 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
| 235 | ERR_R_MALLOC_FAILURE); | ||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | if (!EVP_DigestInit_ex(s->s3->handshake_dgst[i], | ||
| 239 | md, NULL)) { | ||
| 240 | EVP_MD_CTX_destroy(s->s3->handshake_dgst[i]); | ||
| 241 | return 0; | ||
| 242 | } | ||
| 243 | if (!EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, | ||
| 244 | hdatalen)) | ||
| 245 | return 0; | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | if (!(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | ||
| 250 | BIO_free(s->s3->handshake_buffer); | ||
| 251 | s->s3->handshake_buffer = NULL; | ||
| 252 | } | ||
| 253 | |||
| 254 | return 1; | ||
| 255 | } | ||
| 256 | |||
| 257 | void | ||
| 258 | ssl3_record_sequence_increment(unsigned char *seq) | ||
| 259 | { | ||
| 260 | int i; | ||
| 261 | |||
| 262 | for (i = SSL3_SEQUENCE_SIZE - 1; i >= 0; i--) { | ||
| 263 | if (++seq[i] != 0) | ||
| 264 | break; | ||
| 265 | } | ||
| 266 | } | ||
| 267 | |||
| 146 | /* seed1 through seed5 are virtually concatenated */ | 268 | /* seed1 through seed5 are virtually concatenated */ |
| 147 | static int | 269 | static int |
| 148 | tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, | 270 | tls1_P_hash(const EVP_MD *md, const unsigned char *sec, int sec_len, |
