diff options
| author | jsing <> | 2014-06-10 12:56:39 +0000 |
|---|---|---|
| committer | jsing <> | 2014-06-10 12:56:39 +0000 |
| commit | c89ad5d60e5c36f87b2d7d346af77973e9201dd0 (patch) | |
| tree | 3e917b92d4aeaf743dcb53f6a225aebe7c790fb7 /src | |
| parent | b8df1e4e560c0a6617381608d5cdc2cb018ec631 (diff) | |
| download | openbsd-c89ad5d60e5c36f87b2d7d346af77973e9201dd0.tar.gz openbsd-c89ad5d60e5c36f87b2d7d346af77973e9201dd0.tar.bz2 openbsd-c89ad5d60e5c36f87b2d7d346af77973e9201dd0.zip | |
More KNF.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/src/ssl/s3_enc.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c index 13ba633f49..c934e04eea 100644 --- a/src/lib/libssl/src/ssl/s3_enc.c +++ b/src/lib/libssl/src/ssl/s3_enc.c | |||
| @@ -5,21 +5,21 @@ | |||
| 5 | * This package is an SSL implementation written | 5 | * This package is an SSL implementation written |
| 6 | * by Eric Young (eay@cryptsoft.com). | 6 | * by Eric Young (eay@cryptsoft.com). |
| 7 | * The implementation was written so as to conform with Netscapes SSL. | 7 | * The implementation was written so as to conform with Netscapes SSL. |
| 8 | * | 8 | * |
| 9 | * This library is free for commercial and non-commercial use as long as | 9 | * This library is free for commercial and non-commercial use as long as |
| 10 | * the following conditions are aheared to. The following conditions | 10 | * the following conditions are aheared to. The following conditions |
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | 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 | 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 | 13 | * included with this distribution is covered by the same copyright terms |
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). |
| 15 | * | 15 | * |
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | 16 | * Copyright remains Eric Young's, and as such any Copyright notices in |
| 17 | * the code are not to be removed. | 17 | * the code are not to be removed. |
| 18 | * If this package is used in a product, Eric Young should be given attribution | 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. | 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 | 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. | 21 | * in documentation (online or textual) provided with the package. |
| 22 | * | 22 | * |
| 23 | * Redistribution and use in source and binary forms, with or without | 23 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 24 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 25 | * are met: |
| @@ -34,10 +34,10 @@ | |||
| 34 | * Eric Young (eay@cryptsoft.com)" | 34 | * Eric Young (eay@cryptsoft.com)" |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 35 | * The word 'cryptographic' can be left out if the rouines from the library |
| 36 | * being used are not cryptographic related :-). | 36 | * being used are not cryptographic related :-). |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 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: | 38 | * the apps directory (application code) you must include an acknowledgement: |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" |
| 40 | * | 40 | * |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| @@ -49,7 +49,7 @@ | |||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 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 | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | * SUCH DAMAGE. | 51 | * SUCH DAMAGE. |
| 52 | * | 52 | * |
| 53 | * The licence and distribution terms for any publically available version or | 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 | 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be |
| 55 | * copied and put under another distribution licence | 55 | * copied and put under another distribution licence |
| @@ -63,7 +63,7 @@ | |||
| 63 | * are met: | 63 | * are met: |
| 64 | * | 64 | * |
| 65 | * 1. Redistributions of source code must retain the above copyright | 65 | * 1. Redistributions of source code must retain the above copyright |
| 66 | * notice, this list of conditions and the following disclaimer. | 66 | * notice, this list of conditions and the following disclaimer. |
| 67 | * | 67 | * |
| 68 | * 2. Redistributions in binary form must reproduce the above copyright | 68 | * 2. Redistributions in binary form must reproduce the above copyright |
| 69 | * notice, this list of conditions and the following disclaimer in | 69 | * notice, this list of conditions and the following disclaimer in |
| @@ -189,18 +189,18 @@ ssl3_generate_key_block(SSL *s, unsigned char *km, int num) | |||
| 189 | EVP_DigestInit_ex(&s1, EVP_sha1(), NULL); | 189 | EVP_DigestInit_ex(&s1, EVP_sha1(), NULL); |
| 190 | EVP_DigestUpdate(&s1, buf, k); | 190 | EVP_DigestUpdate(&s1, buf, k); |
| 191 | EVP_DigestUpdate(&s1, s->session->master_key, | 191 | EVP_DigestUpdate(&s1, s->session->master_key, |
| 192 | s->session->master_key_length); | 192 | s->session->master_key_length); |
| 193 | EVP_DigestUpdate(&s1, s->s3->server_random, SSL3_RANDOM_SIZE); | 193 | EVP_DigestUpdate(&s1, s->s3->server_random, SSL3_RANDOM_SIZE); |
| 194 | EVP_DigestUpdate(&s1, s->s3->client_random, SSL3_RANDOM_SIZE); | 194 | EVP_DigestUpdate(&s1, s->s3->client_random, SSL3_RANDOM_SIZE); |
| 195 | EVP_DigestFinal_ex(&s1, smd, NULL); | 195 | EVP_DigestFinal_ex(&s1, smd, NULL); |
| 196 | 196 | ||
| 197 | EVP_DigestInit_ex(&m5, EVP_md5(), NULL); | 197 | EVP_DigestInit_ex(&m5, EVP_md5(), NULL); |
| 198 | EVP_DigestUpdate(&m5, s->session->master_key, | 198 | EVP_DigestUpdate(&m5, s->session->master_key, |
| 199 | s->session->master_key_length); | 199 | s->session->master_key_length); |
| 200 | EVP_DigestUpdate(&m5, smd, SHA_DIGEST_LENGTH); | 200 | EVP_DigestUpdate(&m5, smd, SHA_DIGEST_LENGTH); |
| 201 | if ((int)(i + MD5_DIGEST_LENGTH) > num) { | 201 | if ((int)(i + MD5_DIGEST_LENGTH) > num) { |
| 202 | EVP_DigestFinal_ex(&m5, smd, NULL); | 202 | EVP_DigestFinal_ex(&m5, smd, NULL); |
| 203 | memcpy(km, smd,(num - i)); | 203 | memcpy(km, smd, (num - i)); |
| 204 | } else | 204 | } else |
| 205 | EVP_DigestFinal_ex(&m5, km, NULL); | 205 | EVP_DigestFinal_ex(&m5, km, NULL); |
| 206 | 206 | ||
| @@ -367,7 +367,7 @@ ssl3_change_cipher_state(SSL *s, int which) | |||
| 367 | } | 367 | } |
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | EVP_CipherInit_ex(dd, c, NULL, key, iv,(which & SSL3_CC_WRITE)); | 370 | EVP_CipherInit_ex(dd, c, NULL, key, iv, (which & SSL3_CC_WRITE)); |
| 371 | 371 | ||
| 372 | OPENSSL_cleanse(&(exp_key[0]), sizeof(exp_key)); | 372 | OPENSSL_cleanse(&(exp_key[0]), sizeof(exp_key)); |
| 373 | OPENSSL_cleanse(&(exp_iv[0]), sizeof(exp_iv)); | 373 | OPENSSL_cleanse(&(exp_iv[0]), sizeof(exp_iv)); |
| @@ -454,7 +454,7 @@ ssl3_cleanup_key_block(SSL *s) | |||
| 454 | { | 454 | { |
| 455 | if (s->s3->tmp.key_block != NULL) { | 455 | if (s->s3->tmp.key_block != NULL) { |
| 456 | OPENSSL_cleanse(s->s3->tmp.key_block, | 456 | OPENSSL_cleanse(s->s3->tmp.key_block, |
| 457 | s->s3->tmp.key_block_length); | 457 | s->s3->tmp.key_block_length); |
| 458 | free(s->s3->tmp.key_block); | 458 | free(s->s3->tmp.key_block); |
| 459 | s->s3->tmp.key_block = NULL; | 459 | s->s3->tmp.key_block = NULL; |
| 460 | } | 460 | } |
| @@ -495,8 +495,7 @@ ssl3_enc(SSL *s, int send) | |||
| 495 | enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx); | 495 | enc = EVP_CIPHER_CTX_cipher(s->enc_read_ctx); |
| 496 | } | 496 | } |
| 497 | 497 | ||
| 498 | if ((s->session == NULL) || (ds == NULL) || | 498 | if ((s->session == NULL) || (ds == NULL) || (enc == NULL)) { |
| 499 | (enc == NULL)) { | ||
| 500 | memmove(rec->data, rec->input, rec->length); | 499 | memmove(rec->data, rec->input, rec->length); |
| 501 | rec->input = rec->data; | 500 | rec->input = rec->data; |
| 502 | } else { | 501 | } else { |
| @@ -565,7 +564,7 @@ ssl3_finish_mac(SSL *s, const unsigned char *buf, int len) | |||
| 565 | { | 564 | { |
| 566 | if (s->s3->handshake_buffer && | 565 | if (s->s3->handshake_buffer && |
| 567 | !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { | 566 | !(s->s3->flags & TLS1_FLAGS_KEEP_HANDSHAKE)) { |
| 568 | BIO_write (s->s3->handshake_buffer,(void *)buf, len); | 567 | BIO_write(s->s3->handshake_buffer, (void *)buf, len); |
| 569 | } else { | 568 | } else { |
| 570 | int i; | 569 | int i; |
| 571 | for (i = 0; i < SSL_MAX_DIGEST; i++) { | 570 | for (i = 0; i < SSL_MAX_DIGEST; i++) { |
| @@ -678,13 +677,13 @@ ssl3_handshake_mac(SSL *s, int md_nid, const char *sender, int len, | |||
| 678 | if (sender != NULL) | 677 | if (sender != NULL) |
| 679 | EVP_DigestUpdate(&ctx, sender, len); | 678 | EVP_DigestUpdate(&ctx, sender, len); |
| 680 | EVP_DigestUpdate(&ctx, s->session->master_key, | 679 | EVP_DigestUpdate(&ctx, s->session->master_key, |
| 681 | s->session->master_key_length); | 680 | s->session->master_key_length); |
| 682 | EVP_DigestUpdate(&ctx, ssl3_pad_1, npad); | 681 | EVP_DigestUpdate(&ctx, ssl3_pad_1, npad); |
| 683 | EVP_DigestFinal_ex(&ctx, md_buf, &i); | 682 | EVP_DigestFinal_ex(&ctx, md_buf, &i); |
| 684 | 683 | ||
| 685 | EVP_DigestInit_ex(&ctx, EVP_MD_CTX_md(&ctx), NULL); | 684 | EVP_DigestInit_ex(&ctx, EVP_MD_CTX_md(&ctx), NULL); |
| 686 | EVP_DigestUpdate(&ctx, s->session->master_key, | 685 | EVP_DigestUpdate(&ctx, s->session->master_key, |
| 687 | s->session->master_key_length); | 686 | s->session->master_key_length); |
| 688 | EVP_DigestUpdate(&ctx, ssl3_pad_2, npad); | 687 | EVP_DigestUpdate(&ctx, ssl3_pad_2, npad); |
| 689 | EVP_DigestUpdate(&ctx, md_buf, i); | 688 | EVP_DigestUpdate(&ctx, md_buf, i); |
| 690 | EVP_DigestFinal_ex(&ctx, p, &ret); | 689 | EVP_DigestFinal_ex(&ctx, p, &ret); |
| @@ -822,9 +821,9 @@ ssl3_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, | |||
| 822 | EVP_DigestUpdate(&ctx, salt[i], strlen((const char *)salt[i])); | 821 | EVP_DigestUpdate(&ctx, salt[i], strlen((const char *)salt[i])); |
| 823 | EVP_DigestUpdate(&ctx, p, len); | 822 | EVP_DigestUpdate(&ctx, p, len); |
| 824 | EVP_DigestUpdate(&ctx, &(s->s3->client_random[0]), | 823 | EVP_DigestUpdate(&ctx, &(s->s3->client_random[0]), |
| 825 | SSL3_RANDOM_SIZE); | 824 | SSL3_RANDOM_SIZE); |
| 826 | EVP_DigestUpdate(&ctx, &(s->s3->server_random[0]), | 825 | EVP_DigestUpdate(&ctx, &(s->s3->server_random[0]), |
| 827 | SSL3_RANDOM_SIZE); | 826 | SSL3_RANDOM_SIZE); |
| 828 | EVP_DigestFinal_ex(&ctx, buf, &n); | 827 | EVP_DigestFinal_ex(&ctx, buf, &n); |
| 829 | 828 | ||
| 830 | EVP_DigestInit_ex(&ctx, s->ctx->md5, NULL); | 829 | EVP_DigestInit_ex(&ctx, s->ctx->md5, NULL); |
