Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
src/keys.c@15:117db924cf7c, 2018-08-18 (annotated)
- Committer:
- wolfSSL
- Date:
- Sat Aug 18 22:20:43 2018 +0000
- Revision:
- 15:117db924cf7c
- Child:
- 17:ff9d1e86ad5f
wolfSSL 3.15.3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 15:117db924cf7c | 1 | /* keys.c |
wolfSSL | 15:117db924cf7c | 2 | * |
wolfSSL | 15:117db924cf7c | 3 | * Copyright (C) 2006-2017 wolfSSL Inc. |
wolfSSL | 15:117db924cf7c | 4 | * |
wolfSSL | 15:117db924cf7c | 5 | * This file is part of wolfSSL. |
wolfSSL | 15:117db924cf7c | 6 | * |
wolfSSL | 15:117db924cf7c | 7 | * wolfSSL is free software; you can redistribute it and/or modify |
wolfSSL | 15:117db924cf7c | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 15:117db924cf7c | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 15:117db924cf7c | 10 | * (at your option) any later version. |
wolfSSL | 15:117db924cf7c | 11 | * |
wolfSSL | 15:117db924cf7c | 12 | * wolfSSL is distributed in the hope that it will be useful, |
wolfSSL | 15:117db924cf7c | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 15:117db924cf7c | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 15:117db924cf7c | 15 | * GNU General Public License for more details. |
wolfSSL | 15:117db924cf7c | 16 | * |
wolfSSL | 15:117db924cf7c | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 15:117db924cf7c | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 15:117db924cf7c | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
wolfSSL | 15:117db924cf7c | 20 | */ |
wolfSSL | 15:117db924cf7c | 21 | |
wolfSSL | 15:117db924cf7c | 22 | |
wolfSSL | 15:117db924cf7c | 23 | /* Name change compatibility layer no longer needs to be included here */ |
wolfSSL | 15:117db924cf7c | 24 | |
wolfSSL | 15:117db924cf7c | 25 | #ifdef HAVE_CONFIG_H |
wolfSSL | 15:117db924cf7c | 26 | #include <config.h> |
wolfSSL | 15:117db924cf7c | 27 | #endif |
wolfSSL | 15:117db924cf7c | 28 | |
wolfSSL | 15:117db924cf7c | 29 | #include <wolfssl/wolfcrypt/settings.h> |
wolfSSL | 15:117db924cf7c | 30 | |
wolfSSL | 15:117db924cf7c | 31 | #ifndef WOLFCRYPT_ONLY |
wolfSSL | 15:117db924cf7c | 32 | |
wolfSSL | 15:117db924cf7c | 33 | #include <wolfssl/internal.h> |
wolfSSL | 15:117db924cf7c | 34 | #include <wolfssl/error-ssl.h> |
wolfSSL | 15:117db924cf7c | 35 | #if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) |
wolfSSL | 15:117db924cf7c | 36 | #if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) |
wolfSSL | 15:117db924cf7c | 37 | #if MQX_USE_IO_OLD |
wolfSSL | 15:117db924cf7c | 38 | #include <fio.h> |
wolfSSL | 15:117db924cf7c | 39 | #else |
wolfSSL | 15:117db924cf7c | 40 | #include <nio.h> |
wolfSSL | 15:117db924cf7c | 41 | #endif |
wolfSSL | 15:117db924cf7c | 42 | #else |
wolfSSL | 15:117db924cf7c | 43 | #include <stdio.h> |
wolfSSL | 15:117db924cf7c | 44 | #endif |
wolfSSL | 15:117db924cf7c | 45 | #endif |
wolfSSL | 15:117db924cf7c | 46 | |
wolfSSL | 15:117db924cf7c | 47 | |
wolfSSL | 15:117db924cf7c | 48 | int SetCipherSpecs(WOLFSSL* ssl) |
wolfSSL | 15:117db924cf7c | 49 | { |
wolfSSL | 15:117db924cf7c | 50 | #ifndef NO_WOLFSSL_CLIENT |
wolfSSL | 15:117db924cf7c | 51 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 52 | /* server side verified before SetCipherSpecs call */ |
wolfSSL | 15:117db924cf7c | 53 | if (VerifyClientSuite(ssl) != 1) { |
wolfSSL | 15:117db924cf7c | 54 | WOLFSSL_MSG("SetCipherSpecs() client has an unusuable suite"); |
wolfSSL | 15:117db924cf7c | 55 | return UNSUPPORTED_SUITE; |
wolfSSL | 15:117db924cf7c | 56 | } |
wolfSSL | 15:117db924cf7c | 57 | } |
wolfSSL | 15:117db924cf7c | 58 | #endif /* NO_WOLFSSL_CLIENT */ |
wolfSSL | 15:117db924cf7c | 59 | |
wolfSSL | 15:117db924cf7c | 60 | /* Chacha extensions, 0xcc */ |
wolfSSL | 15:117db924cf7c | 61 | if (ssl->options.cipherSuite0 == CHACHA_BYTE) { |
wolfSSL | 15:117db924cf7c | 62 | |
wolfSSL | 15:117db924cf7c | 63 | switch (ssl->options.cipherSuite) { |
wolfSSL | 15:117db924cf7c | 64 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 65 | case TLS_ECDHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 66 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 67 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 68 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 69 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 70 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 71 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 72 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 73 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 74 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 75 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 76 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 77 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 78 | ssl->options.oldPoly = 1; /* use old poly1305 padding */ |
wolfSSL | 15:117db924cf7c | 79 | |
wolfSSL | 15:117db924cf7c | 80 | break; |
wolfSSL | 15:117db924cf7c | 81 | #endif |
wolfSSL | 15:117db924cf7c | 82 | |
wolfSSL | 15:117db924cf7c | 83 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_OLD_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 84 | case TLS_ECDHE_ECDSA_WITH_CHACHA20_OLD_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 85 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 86 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 87 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 88 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 89 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 90 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 91 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 92 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 93 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 94 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 95 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 96 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 97 | ssl->options.oldPoly = 1; /* use old poly1305 padding */ |
wolfSSL | 15:117db924cf7c | 98 | |
wolfSSL | 15:117db924cf7c | 99 | break; |
wolfSSL | 15:117db924cf7c | 100 | #endif |
wolfSSL | 15:117db924cf7c | 101 | |
wolfSSL | 15:117db924cf7c | 102 | #ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 103 | case TLS_DHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 104 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 105 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 106 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 107 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 108 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 109 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 110 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 111 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 112 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 113 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 114 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 115 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 116 | ssl->options.oldPoly = 1; /* use old poly1305 padding */ |
wolfSSL | 15:117db924cf7c | 117 | |
wolfSSL | 15:117db924cf7c | 118 | break; |
wolfSSL | 15:117db924cf7c | 119 | #endif |
wolfSSL | 15:117db924cf7c | 120 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 121 | case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 122 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 123 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 124 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 125 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 126 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 127 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 128 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 129 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 130 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 131 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 132 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 133 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 134 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 135 | |
wolfSSL | 15:117db924cf7c | 136 | break; |
wolfSSL | 15:117db924cf7c | 137 | #endif |
wolfSSL | 15:117db924cf7c | 138 | |
wolfSSL | 15:117db924cf7c | 139 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 140 | case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 141 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 142 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 143 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 144 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 145 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 146 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 147 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 148 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 149 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 150 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 151 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 152 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 153 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 154 | |
wolfSSL | 15:117db924cf7c | 155 | break; |
wolfSSL | 15:117db924cf7c | 156 | #endif |
wolfSSL | 15:117db924cf7c | 157 | |
wolfSSL | 15:117db924cf7c | 158 | #ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 159 | case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 160 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 161 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 162 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 163 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 164 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 165 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 166 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 167 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 168 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 169 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 170 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 171 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 172 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 173 | |
wolfSSL | 15:117db924cf7c | 174 | break; |
wolfSSL | 15:117db924cf7c | 175 | #endif |
wolfSSL | 15:117db924cf7c | 176 | |
wolfSSL | 15:117db924cf7c | 177 | #ifdef BUILD_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 178 | case TLS_PSK_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 179 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 180 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 181 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 182 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 183 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 184 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 185 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 186 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 187 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 188 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 189 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 190 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 191 | |
wolfSSL | 15:117db924cf7c | 192 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 193 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 194 | break; |
wolfSSL | 15:117db924cf7c | 195 | #endif |
wolfSSL | 15:117db924cf7c | 196 | |
wolfSSL | 15:117db924cf7c | 197 | #ifdef BUILD_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 198 | case TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 199 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 200 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 201 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 202 | ssl->specs.kea = ecdhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 203 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 204 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 205 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 206 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 207 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 208 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 209 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 210 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 211 | |
wolfSSL | 15:117db924cf7c | 212 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 213 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 214 | break; |
wolfSSL | 15:117db924cf7c | 215 | #endif |
wolfSSL | 15:117db924cf7c | 216 | |
wolfSSL | 15:117db924cf7c | 217 | #ifdef BUILD_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 218 | case TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256: |
wolfSSL | 15:117db924cf7c | 219 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 220 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 221 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 222 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 223 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 224 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 225 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 226 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 227 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 228 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 229 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 230 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 231 | |
wolfSSL | 15:117db924cf7c | 232 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 233 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 234 | break; |
wolfSSL | 15:117db924cf7c | 235 | #endif |
wolfSSL | 15:117db924cf7c | 236 | default: |
wolfSSL | 15:117db924cf7c | 237 | WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ChaCha"); |
wolfSSL | 15:117db924cf7c | 238 | return UNSUPPORTED_SUITE; |
wolfSSL | 15:117db924cf7c | 239 | } |
wolfSSL | 15:117db924cf7c | 240 | } |
wolfSSL | 15:117db924cf7c | 241 | |
wolfSSL | 15:117db924cf7c | 242 | /* ECC extensions, or AES-CCM */ |
wolfSSL | 15:117db924cf7c | 243 | if (ssl->options.cipherSuite0 == ECC_BYTE) { |
wolfSSL | 15:117db924cf7c | 244 | |
wolfSSL | 15:117db924cf7c | 245 | switch (ssl->options.cipherSuite) { |
wolfSSL | 15:117db924cf7c | 246 | |
wolfSSL | 15:117db924cf7c | 247 | #if defined(HAVE_ECC) || defined(HAVE_CURVE25519) |
wolfSSL | 15:117db924cf7c | 248 | |
wolfSSL | 15:117db924cf7c | 249 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 250 | case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 251 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 252 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 253 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 254 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 255 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 256 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 257 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 258 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 259 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 260 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 261 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 262 | |
wolfSSL | 15:117db924cf7c | 263 | break; |
wolfSSL | 15:117db924cf7c | 264 | #endif |
wolfSSL | 15:117db924cf7c | 265 | |
wolfSSL | 15:117db924cf7c | 266 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 267 | case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 268 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 269 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 270 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 271 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 272 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 273 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 274 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 275 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 276 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 277 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 278 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 279 | |
wolfSSL | 15:117db924cf7c | 280 | break; |
wolfSSL | 15:117db924cf7c | 281 | #endif |
wolfSSL | 15:117db924cf7c | 282 | |
wolfSSL | 15:117db924cf7c | 283 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 284 | case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 285 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 286 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 287 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 288 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 289 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 290 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 291 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 292 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 293 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 294 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 295 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 296 | |
wolfSSL | 15:117db924cf7c | 297 | break; |
wolfSSL | 15:117db924cf7c | 298 | #endif |
wolfSSL | 15:117db924cf7c | 299 | |
wolfSSL | 15:117db924cf7c | 300 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 301 | case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 302 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 303 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 304 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 305 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 306 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 307 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 308 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 309 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 310 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 311 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 312 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 313 | |
wolfSSL | 15:117db924cf7c | 314 | break; |
wolfSSL | 15:117db924cf7c | 315 | #endif |
wolfSSL | 15:117db924cf7c | 316 | |
wolfSSL | 15:117db924cf7c | 317 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 318 | case TLS_ECDHE_RSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 319 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 320 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 321 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 322 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 323 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 324 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 325 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 326 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 327 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 328 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 329 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 330 | |
wolfSSL | 15:117db924cf7c | 331 | break; |
wolfSSL | 15:117db924cf7c | 332 | #endif |
wolfSSL | 15:117db924cf7c | 333 | |
wolfSSL | 15:117db924cf7c | 334 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 335 | case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 336 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 337 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 338 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 339 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 340 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 341 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 342 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 343 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 344 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 345 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 346 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 347 | |
wolfSSL | 15:117db924cf7c | 348 | break; |
wolfSSL | 15:117db924cf7c | 349 | #endif |
wolfSSL | 15:117db924cf7c | 350 | |
wolfSSL | 15:117db924cf7c | 351 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 352 | case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 353 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 354 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 355 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 356 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 357 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 358 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 359 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 360 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 361 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 362 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 363 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 364 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 365 | |
wolfSSL | 15:117db924cf7c | 366 | break; |
wolfSSL | 15:117db924cf7c | 367 | #endif |
wolfSSL | 15:117db924cf7c | 368 | |
wolfSSL | 15:117db924cf7c | 369 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 370 | case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 371 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 372 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 373 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 374 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 375 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 376 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 377 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 378 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 379 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 380 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 381 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 382 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 383 | |
wolfSSL | 15:117db924cf7c | 384 | break; |
wolfSSL | 15:117db924cf7c | 385 | #endif |
wolfSSL | 15:117db924cf7c | 386 | |
wolfSSL | 15:117db924cf7c | 387 | #ifdef BUILD_TLS_ECDHE_PSK_WITH_NULL_SHA256 |
wolfSSL | 15:117db924cf7c | 388 | case TLS_ECDHE_PSK_WITH_NULL_SHA256 : |
wolfSSL | 15:117db924cf7c | 389 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 390 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 391 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 392 | ssl->specs.kea = ecdhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 393 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 394 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 395 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 396 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 397 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 398 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 399 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 400 | |
wolfSSL | 15:117db924cf7c | 401 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 402 | break; |
wolfSSL | 15:117db924cf7c | 403 | #endif |
wolfSSL | 15:117db924cf7c | 404 | |
wolfSSL | 15:117db924cf7c | 405 | #ifdef BUILD_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 406 | case TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 407 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 408 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 409 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 410 | ssl->specs.kea = ecdhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 411 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 412 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 413 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 414 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 415 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 416 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 417 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 418 | |
wolfSSL | 15:117db924cf7c | 419 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 420 | break; |
wolfSSL | 15:117db924cf7c | 421 | #endif |
wolfSSL | 15:117db924cf7c | 422 | |
wolfSSL | 15:117db924cf7c | 423 | #endif /* HAVE_ECC || HAVE_CURVE25519 */ |
wolfSSL | 15:117db924cf7c | 424 | |
wolfSSL | 15:117db924cf7c | 425 | #if defined(HAVE_ECC) || (defined(HAVE_CURVE25519) && defined(HAVE_ED25519)) |
wolfSSL | 15:117db924cf7c | 426 | |
wolfSSL | 15:117db924cf7c | 427 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 428 | case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 429 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 430 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 431 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 432 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 433 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 434 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 435 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 436 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 437 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 438 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 439 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 440 | |
wolfSSL | 15:117db924cf7c | 441 | break; |
wolfSSL | 15:117db924cf7c | 442 | #endif |
wolfSSL | 15:117db924cf7c | 443 | |
wolfSSL | 15:117db924cf7c | 444 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 445 | case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 446 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 447 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 448 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 449 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 450 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 451 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 452 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 453 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 454 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 455 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 456 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 457 | |
wolfSSL | 15:117db924cf7c | 458 | break; |
wolfSSL | 15:117db924cf7c | 459 | #endif |
wolfSSL | 15:117db924cf7c | 460 | |
wolfSSL | 15:117db924cf7c | 461 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 462 | case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 463 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 464 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 465 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 466 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 467 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 468 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 469 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 470 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 471 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 472 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 473 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 474 | |
wolfSSL | 15:117db924cf7c | 475 | break; |
wolfSSL | 15:117db924cf7c | 476 | #endif |
wolfSSL | 15:117db924cf7c | 477 | |
wolfSSL | 15:117db924cf7c | 478 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 479 | case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 480 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 481 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 482 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 483 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 484 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 485 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 486 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 487 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 488 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 489 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 490 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 491 | |
wolfSSL | 15:117db924cf7c | 492 | break; |
wolfSSL | 15:117db924cf7c | 493 | #endif |
wolfSSL | 15:117db924cf7c | 494 | |
wolfSSL | 15:117db924cf7c | 495 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 496 | case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 497 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 498 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 499 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 500 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 501 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 502 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 503 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 504 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 505 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 506 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 507 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 508 | |
wolfSSL | 15:117db924cf7c | 509 | break; |
wolfSSL | 15:117db924cf7c | 510 | #endif |
wolfSSL | 15:117db924cf7c | 511 | |
wolfSSL | 15:117db924cf7c | 512 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 513 | case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 514 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 515 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 516 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 517 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 518 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 519 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 520 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 521 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 522 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 523 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 524 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 525 | |
wolfSSL | 15:117db924cf7c | 526 | break; |
wolfSSL | 15:117db924cf7c | 527 | #endif |
wolfSSL | 15:117db924cf7c | 528 | |
wolfSSL | 15:117db924cf7c | 529 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 530 | case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 531 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 532 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 533 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 534 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 535 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 536 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 537 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 538 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 539 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 540 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 541 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 542 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 543 | |
wolfSSL | 15:117db924cf7c | 544 | break; |
wolfSSL | 15:117db924cf7c | 545 | #endif |
wolfSSL | 15:117db924cf7c | 546 | |
wolfSSL | 15:117db924cf7c | 547 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 548 | case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 549 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 550 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 551 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 552 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 553 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 554 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 555 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 556 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 557 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 558 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 559 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 560 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 561 | |
wolfSSL | 15:117db924cf7c | 562 | break; |
wolfSSL | 15:117db924cf7c | 563 | #endif |
wolfSSL | 15:117db924cf7c | 564 | |
wolfSSL | 15:117db924cf7c | 565 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM |
wolfSSL | 15:117db924cf7c | 566 | case TLS_ECDHE_ECDSA_WITH_AES_128_CCM : |
wolfSSL | 15:117db924cf7c | 567 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 568 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 569 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 570 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 571 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 572 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 573 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 574 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 575 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 576 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 577 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 578 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 579 | |
wolfSSL | 15:117db924cf7c | 580 | break; |
wolfSSL | 15:117db924cf7c | 581 | #endif |
wolfSSL | 15:117db924cf7c | 582 | |
wolfSSL | 15:117db924cf7c | 583 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 |
wolfSSL | 15:117db924cf7c | 584 | case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 : |
wolfSSL | 15:117db924cf7c | 585 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 586 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 587 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 588 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 589 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 590 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 591 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 592 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 593 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 594 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 595 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 596 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 597 | |
wolfSSL | 15:117db924cf7c | 598 | break; |
wolfSSL | 15:117db924cf7c | 599 | #endif |
wolfSSL | 15:117db924cf7c | 600 | |
wolfSSL | 15:117db924cf7c | 601 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 |
wolfSSL | 15:117db924cf7c | 602 | case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 : |
wolfSSL | 15:117db924cf7c | 603 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 604 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 605 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 606 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 607 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 608 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 609 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 610 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 611 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 612 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 613 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 614 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 615 | |
wolfSSL | 15:117db924cf7c | 616 | break; |
wolfSSL | 15:117db924cf7c | 617 | #endif |
wolfSSL | 15:117db924cf7c | 618 | |
wolfSSL | 15:117db924cf7c | 619 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_NULL_SHA |
wolfSSL | 15:117db924cf7c | 620 | case TLS_ECDHE_ECDSA_WITH_NULL_SHA : |
wolfSSL | 15:117db924cf7c | 621 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 622 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 623 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 624 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 625 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 626 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 627 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 628 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 629 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 630 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 631 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 632 | |
wolfSSL | 15:117db924cf7c | 633 | break; |
wolfSSL | 15:117db924cf7c | 634 | #endif |
wolfSSL | 15:117db924cf7c | 635 | |
wolfSSL | 15:117db924cf7c | 636 | #endif /* HAVE_ECC || (HAVE_CURVE25519 && HAVE_ED25519) */ |
wolfSSL | 15:117db924cf7c | 637 | |
wolfSSL | 15:117db924cf7c | 638 | #if defined(HAVE_ECC) |
wolfSSL | 15:117db924cf7c | 639 | |
wolfSSL | 15:117db924cf7c | 640 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 641 | case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 642 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 643 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 644 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 645 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 646 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 647 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 648 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 649 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 650 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 651 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 652 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 653 | |
wolfSSL | 15:117db924cf7c | 654 | break; |
wolfSSL | 15:117db924cf7c | 655 | #endif |
wolfSSL | 15:117db924cf7c | 656 | |
wolfSSL | 15:117db924cf7c | 657 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 658 | case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 659 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 660 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 661 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 662 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 663 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 664 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 665 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 666 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 667 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 668 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 669 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 670 | |
wolfSSL | 15:117db924cf7c | 671 | break; |
wolfSSL | 15:117db924cf7c | 672 | #endif |
wolfSSL | 15:117db924cf7c | 673 | |
wolfSSL | 15:117db924cf7c | 674 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 675 | case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 676 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 677 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 678 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 679 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 680 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 681 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 682 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 683 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 684 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 685 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 686 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 687 | |
wolfSSL | 15:117db924cf7c | 688 | break; |
wolfSSL | 15:117db924cf7c | 689 | #endif |
wolfSSL | 15:117db924cf7c | 690 | |
wolfSSL | 15:117db924cf7c | 691 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 692 | case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 693 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 694 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 695 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 696 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 697 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 698 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 699 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 700 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 701 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 702 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 703 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 704 | |
wolfSSL | 15:117db924cf7c | 705 | break; |
wolfSSL | 15:117db924cf7c | 706 | #endif |
wolfSSL | 15:117db924cf7c | 707 | |
wolfSSL | 15:117db924cf7c | 708 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 709 | case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 710 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 711 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 712 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 713 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 714 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 715 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 716 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 717 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 718 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 719 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 720 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 721 | |
wolfSSL | 15:117db924cf7c | 722 | break; |
wolfSSL | 15:117db924cf7c | 723 | #endif |
wolfSSL | 15:117db924cf7c | 724 | |
wolfSSL | 15:117db924cf7c | 725 | #ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 726 | case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 727 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 728 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 729 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 730 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 731 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 732 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 733 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 734 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 735 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 736 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 737 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 738 | |
wolfSSL | 15:117db924cf7c | 739 | break; |
wolfSSL | 15:117db924cf7c | 740 | #endif |
wolfSSL | 15:117db924cf7c | 741 | |
wolfSSL | 15:117db924cf7c | 742 | #ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 743 | case TLS_ECDH_RSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 744 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 745 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 746 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 747 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 748 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 749 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 750 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 751 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 752 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 753 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 754 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 755 | |
wolfSSL | 15:117db924cf7c | 756 | break; |
wolfSSL | 15:117db924cf7c | 757 | #endif |
wolfSSL | 15:117db924cf7c | 758 | |
wolfSSL | 15:117db924cf7c | 759 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 760 | case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 761 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 762 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 763 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 764 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 765 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 766 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 767 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 768 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 769 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 770 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 771 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 772 | |
wolfSSL | 15:117db924cf7c | 773 | break; |
wolfSSL | 15:117db924cf7c | 774 | #endif |
wolfSSL | 15:117db924cf7c | 775 | |
wolfSSL | 15:117db924cf7c | 776 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 777 | case TLS_ECDH_ECDSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 778 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 779 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 780 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 781 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 782 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 783 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 784 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 785 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 786 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 787 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 788 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 789 | |
wolfSSL | 15:117db924cf7c | 790 | break; |
wolfSSL | 15:117db924cf7c | 791 | #endif |
wolfSSL | 15:117db924cf7c | 792 | |
wolfSSL | 15:117db924cf7c | 793 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 794 | case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 795 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 796 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 797 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 798 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 799 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 800 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 801 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 802 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 803 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 804 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 805 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 806 | |
wolfSSL | 15:117db924cf7c | 807 | break; |
wolfSSL | 15:117db924cf7c | 808 | #endif |
wolfSSL | 15:117db924cf7c | 809 | |
wolfSSL | 15:117db924cf7c | 810 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 811 | case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 812 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 813 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 814 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 815 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 816 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 817 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 818 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 819 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 820 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 821 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 822 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 823 | |
wolfSSL | 15:117db924cf7c | 824 | break; |
wolfSSL | 15:117db924cf7c | 825 | #endif |
wolfSSL | 15:117db924cf7c | 826 | |
wolfSSL | 15:117db924cf7c | 827 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 828 | case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 829 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 830 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 831 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 832 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 833 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 834 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 835 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 836 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 837 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 838 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 839 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 840 | |
wolfSSL | 15:117db924cf7c | 841 | break; |
wolfSSL | 15:117db924cf7c | 842 | #endif |
wolfSSL | 15:117db924cf7c | 843 | |
wolfSSL | 15:117db924cf7c | 844 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 845 | case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 846 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 847 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 848 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 849 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 850 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 851 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 852 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 853 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 854 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 855 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 856 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 857 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 858 | |
wolfSSL | 15:117db924cf7c | 859 | break; |
wolfSSL | 15:117db924cf7c | 860 | #endif |
wolfSSL | 15:117db924cf7c | 861 | |
wolfSSL | 15:117db924cf7c | 862 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 863 | case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 864 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 865 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 866 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 867 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 868 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 869 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 870 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 871 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 872 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 873 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 874 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 875 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 876 | |
wolfSSL | 15:117db924cf7c | 877 | break; |
wolfSSL | 15:117db924cf7c | 878 | #endif |
wolfSSL | 15:117db924cf7c | 879 | |
wolfSSL | 15:117db924cf7c | 880 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 881 | case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 882 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 883 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 884 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 885 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 886 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 887 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 888 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 889 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 890 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 891 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 892 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 893 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 894 | |
wolfSSL | 15:117db924cf7c | 895 | break; |
wolfSSL | 15:117db924cf7c | 896 | #endif |
wolfSSL | 15:117db924cf7c | 897 | |
wolfSSL | 15:117db924cf7c | 898 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 899 | case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 900 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 901 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 902 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 903 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 904 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 905 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 906 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 907 | ssl->specs.static_ecdh = 1; |
wolfSSL | 15:117db924cf7c | 908 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 909 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 910 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 911 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 912 | |
wolfSSL | 15:117db924cf7c | 913 | break; |
wolfSSL | 15:117db924cf7c | 914 | #endif |
wolfSSL | 15:117db924cf7c | 915 | |
wolfSSL | 15:117db924cf7c | 916 | #endif /* HAVE_ECC */ |
wolfSSL | 15:117db924cf7c | 917 | |
wolfSSL | 15:117db924cf7c | 918 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8 |
wolfSSL | 15:117db924cf7c | 919 | case TLS_RSA_WITH_AES_128_CCM_8 : |
wolfSSL | 15:117db924cf7c | 920 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 921 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 922 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 923 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 924 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 925 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 926 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 927 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 928 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 929 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 930 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 931 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 932 | |
wolfSSL | 15:117db924cf7c | 933 | break; |
wolfSSL | 15:117db924cf7c | 934 | #endif |
wolfSSL | 15:117db924cf7c | 935 | |
wolfSSL | 15:117db924cf7c | 936 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8 |
wolfSSL | 15:117db924cf7c | 937 | case TLS_RSA_WITH_AES_256_CCM_8 : |
wolfSSL | 15:117db924cf7c | 938 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 939 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 940 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 941 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 942 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 943 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 944 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 945 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 946 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 947 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 948 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 949 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 950 | |
wolfSSL | 15:117db924cf7c | 951 | break; |
wolfSSL | 15:117db924cf7c | 952 | #endif |
wolfSSL | 15:117db924cf7c | 953 | |
wolfSSL | 15:117db924cf7c | 954 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8 |
wolfSSL | 15:117db924cf7c | 955 | case TLS_PSK_WITH_AES_128_CCM_8 : |
wolfSSL | 15:117db924cf7c | 956 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 957 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 958 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 959 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 960 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 961 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 962 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 963 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 964 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 965 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 966 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 967 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 968 | |
wolfSSL | 15:117db924cf7c | 969 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 970 | break; |
wolfSSL | 15:117db924cf7c | 971 | #endif |
wolfSSL | 15:117db924cf7c | 972 | |
wolfSSL | 15:117db924cf7c | 973 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8 |
wolfSSL | 15:117db924cf7c | 974 | case TLS_PSK_WITH_AES_256_CCM_8 : |
wolfSSL | 15:117db924cf7c | 975 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 976 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 977 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 978 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 979 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 980 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 981 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 982 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 983 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 984 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 985 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 986 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 987 | |
wolfSSL | 15:117db924cf7c | 988 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 989 | break; |
wolfSSL | 15:117db924cf7c | 990 | #endif |
wolfSSL | 15:117db924cf7c | 991 | |
wolfSSL | 15:117db924cf7c | 992 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CCM |
wolfSSL | 15:117db924cf7c | 993 | case TLS_PSK_WITH_AES_128_CCM : |
wolfSSL | 15:117db924cf7c | 994 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 995 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 996 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 997 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 998 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 999 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1000 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1001 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1002 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1003 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1004 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1005 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1006 | |
wolfSSL | 15:117db924cf7c | 1007 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1008 | break; |
wolfSSL | 15:117db924cf7c | 1009 | #endif |
wolfSSL | 15:117db924cf7c | 1010 | |
wolfSSL | 15:117db924cf7c | 1011 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CCM |
wolfSSL | 15:117db924cf7c | 1012 | case TLS_PSK_WITH_AES_256_CCM : |
wolfSSL | 15:117db924cf7c | 1013 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 1014 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1015 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1016 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1017 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1018 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1019 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1020 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1021 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1022 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1023 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1024 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1025 | |
wolfSSL | 15:117db924cf7c | 1026 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1027 | break; |
wolfSSL | 15:117db924cf7c | 1028 | #endif |
wolfSSL | 15:117db924cf7c | 1029 | |
wolfSSL | 15:117db924cf7c | 1030 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM |
wolfSSL | 15:117db924cf7c | 1031 | case TLS_DHE_PSK_WITH_AES_128_CCM : |
wolfSSL | 15:117db924cf7c | 1032 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 1033 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1034 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1035 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1036 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1037 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1038 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1039 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1040 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1041 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1042 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1043 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1044 | |
wolfSSL | 15:117db924cf7c | 1045 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1046 | break; |
wolfSSL | 15:117db924cf7c | 1047 | #endif |
wolfSSL | 15:117db924cf7c | 1048 | |
wolfSSL | 15:117db924cf7c | 1049 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM |
wolfSSL | 15:117db924cf7c | 1050 | case TLS_DHE_PSK_WITH_AES_256_CCM : |
wolfSSL | 15:117db924cf7c | 1051 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 1052 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1053 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1054 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1055 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1056 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1057 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1058 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1059 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1060 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1061 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1062 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1063 | |
wolfSSL | 15:117db924cf7c | 1064 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1065 | break; |
wolfSSL | 15:117db924cf7c | 1066 | #endif |
wolfSSL | 15:117db924cf7c | 1067 | |
wolfSSL | 15:117db924cf7c | 1068 | default: |
wolfSSL | 15:117db924cf7c | 1069 | WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC"); |
wolfSSL | 15:117db924cf7c | 1070 | return UNSUPPORTED_SUITE; |
wolfSSL | 15:117db924cf7c | 1071 | } /* switch */ |
wolfSSL | 15:117db924cf7c | 1072 | } /* if */ |
wolfSSL | 15:117db924cf7c | 1073 | |
wolfSSL | 15:117db924cf7c | 1074 | /* TLSi v1.3 cipher suites, 0x13 */ |
wolfSSL | 15:117db924cf7c | 1075 | if (ssl->options.cipherSuite0 == TLS13_BYTE) { |
wolfSSL | 15:117db924cf7c | 1076 | switch (ssl->options.cipherSuite) { |
wolfSSL | 15:117db924cf7c | 1077 | |
wolfSSL | 15:117db924cf7c | 1078 | #ifdef WOLFSSL_TLS13 |
wolfSSL | 15:117db924cf7c | 1079 | #ifdef BUILD_TLS_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1080 | case TLS_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1081 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1082 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1083 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1084 | ssl->specs.kea = 0; |
wolfSSL | 15:117db924cf7c | 1085 | ssl->specs.sig_algo = 0; |
wolfSSL | 15:117db924cf7c | 1086 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1087 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1088 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1089 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1090 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1091 | ssl->specs.iv_size = AESGCM_NONCE_SZ; |
wolfSSL | 15:117db924cf7c | 1092 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1093 | |
wolfSSL | 15:117db924cf7c | 1094 | break; |
wolfSSL | 15:117db924cf7c | 1095 | #endif |
wolfSSL | 15:117db924cf7c | 1096 | |
wolfSSL | 15:117db924cf7c | 1097 | #ifdef BUILD_TLS_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1098 | case TLS_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 1099 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1100 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1101 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1102 | ssl->specs.kea = 0; |
wolfSSL | 15:117db924cf7c | 1103 | ssl->specs.sig_algo = 0; |
wolfSSL | 15:117db924cf7c | 1104 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1105 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1106 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1107 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1108 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1109 | ssl->specs.iv_size = AESGCM_NONCE_SZ; |
wolfSSL | 15:117db924cf7c | 1110 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1111 | |
wolfSSL | 15:117db924cf7c | 1112 | break; |
wolfSSL | 15:117db924cf7c | 1113 | #endif |
wolfSSL | 15:117db924cf7c | 1114 | |
wolfSSL | 15:117db924cf7c | 1115 | #ifdef BUILD_TLS_CHACHA20_POLY1305_SHA256 |
wolfSSL | 15:117db924cf7c | 1116 | case TLS_CHACHA20_POLY1305_SHA256 : |
wolfSSL | 15:117db924cf7c | 1117 | ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; |
wolfSSL | 15:117db924cf7c | 1118 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1119 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1120 | ssl->specs.kea = 0; |
wolfSSL | 15:117db924cf7c | 1121 | ssl->specs.sig_algo = 0; |
wolfSSL | 15:117db924cf7c | 1122 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1123 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1124 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1125 | ssl->specs.key_size = CHACHA20_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1126 | ssl->specs.block_size = CHACHA20_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1127 | ssl->specs.iv_size = CHACHA20_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1128 | ssl->specs.aead_mac_size = POLY1305_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1129 | ssl->options.oldPoly = 0; /* use recent padding RFC */ |
wolfSSL | 15:117db924cf7c | 1130 | |
wolfSSL | 15:117db924cf7c | 1131 | break; |
wolfSSL | 15:117db924cf7c | 1132 | #endif |
wolfSSL | 15:117db924cf7c | 1133 | |
wolfSSL | 15:117db924cf7c | 1134 | #ifdef BUILD_TLS_AES_128_CCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1135 | case TLS_AES_128_CCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1136 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 1137 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1138 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1139 | ssl->specs.kea = 0; |
wolfSSL | 15:117db924cf7c | 1140 | ssl->specs.sig_algo = 0; |
wolfSSL | 15:117db924cf7c | 1141 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1142 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1143 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1144 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1145 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1146 | ssl->specs.iv_size = AESGCM_NONCE_SZ; |
wolfSSL | 15:117db924cf7c | 1147 | ssl->specs.aead_mac_size = AES_CCM_16_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1148 | |
wolfSSL | 15:117db924cf7c | 1149 | break; |
wolfSSL | 15:117db924cf7c | 1150 | #endif |
wolfSSL | 15:117db924cf7c | 1151 | |
wolfSSL | 15:117db924cf7c | 1152 | #ifdef BUILD_TLS_AES_128_CCM_8_SHA256 |
wolfSSL | 15:117db924cf7c | 1153 | case TLS_AES_128_CCM_8_SHA256 : |
wolfSSL | 15:117db924cf7c | 1154 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; |
wolfSSL | 15:117db924cf7c | 1155 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1156 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1157 | ssl->specs.kea = 0; |
wolfSSL | 15:117db924cf7c | 1158 | ssl->specs.sig_algo = 0; |
wolfSSL | 15:117db924cf7c | 1159 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1160 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1161 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1162 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1163 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1164 | ssl->specs.iv_size = AESGCM_NONCE_SZ; |
wolfSSL | 15:117db924cf7c | 1165 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1166 | |
wolfSSL | 15:117db924cf7c | 1167 | break; |
wolfSSL | 15:117db924cf7c | 1168 | #endif |
wolfSSL | 15:117db924cf7c | 1169 | #endif /* WOLFSSL_TLS13 */ |
wolfSSL | 15:117db924cf7c | 1170 | } |
wolfSSL | 15:117db924cf7c | 1171 | } |
wolfSSL | 15:117db924cf7c | 1172 | |
wolfSSL | 15:117db924cf7c | 1173 | if (ssl->options.cipherSuite0 != ECC_BYTE && |
wolfSSL | 15:117db924cf7c | 1174 | ssl->options.cipherSuite0 != CHACHA_BYTE && |
wolfSSL | 15:117db924cf7c | 1175 | ssl->options.cipherSuite0 != TLS13_BYTE) { /* normal suites */ |
wolfSSL | 15:117db924cf7c | 1176 | switch (ssl->options.cipherSuite) { |
wolfSSL | 15:117db924cf7c | 1177 | |
wolfSSL | 15:117db924cf7c | 1178 | #ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 1179 | case SSL_RSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 1180 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 1181 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1182 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1183 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1184 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1185 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1186 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1187 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1188 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1189 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1190 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1191 | |
wolfSSL | 15:117db924cf7c | 1192 | break; |
wolfSSL | 15:117db924cf7c | 1193 | #endif |
wolfSSL | 15:117db924cf7c | 1194 | |
wolfSSL | 15:117db924cf7c | 1195 | #ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA |
wolfSSL | 15:117db924cf7c | 1196 | case TLS_NTRU_RSA_WITH_RC4_128_SHA : |
wolfSSL | 15:117db924cf7c | 1197 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 1198 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1199 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1200 | ssl->specs.kea = ntru_kea; |
wolfSSL | 15:117db924cf7c | 1201 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1202 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1203 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1204 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1205 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1206 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1207 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1208 | |
wolfSSL | 15:117db924cf7c | 1209 | break; |
wolfSSL | 15:117db924cf7c | 1210 | #endif |
wolfSSL | 15:117db924cf7c | 1211 | |
wolfSSL | 15:117db924cf7c | 1212 | #ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5 |
wolfSSL | 15:117db924cf7c | 1213 | case SSL_RSA_WITH_RC4_128_MD5 : |
wolfSSL | 15:117db924cf7c | 1214 | ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; |
wolfSSL | 15:117db924cf7c | 1215 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1216 | ssl->specs.mac_algorithm = md5_mac; |
wolfSSL | 15:117db924cf7c | 1217 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1218 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1219 | ssl->specs.hash_size = WC_MD5_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1220 | ssl->specs.pad_size = PAD_MD5; |
wolfSSL | 15:117db924cf7c | 1221 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1222 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1223 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1224 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1225 | |
wolfSSL | 15:117db924cf7c | 1226 | break; |
wolfSSL | 15:117db924cf7c | 1227 | #endif |
wolfSSL | 15:117db924cf7c | 1228 | |
wolfSSL | 15:117db924cf7c | 1229 | #ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1230 | case SSL_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1231 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 1232 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1233 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1234 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1235 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1236 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1237 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1238 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1239 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1240 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1241 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1242 | |
wolfSSL | 15:117db924cf7c | 1243 | break; |
wolfSSL | 15:117db924cf7c | 1244 | #endif |
wolfSSL | 15:117db924cf7c | 1245 | |
wolfSSL | 15:117db924cf7c | 1246 | #ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1247 | case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1248 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 1249 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1250 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1251 | ssl->specs.kea = ntru_kea; |
wolfSSL | 15:117db924cf7c | 1252 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1253 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1254 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1255 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1256 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1257 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1258 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1259 | |
wolfSSL | 15:117db924cf7c | 1260 | break; |
wolfSSL | 15:117db924cf7c | 1261 | #endif |
wolfSSL | 15:117db924cf7c | 1262 | |
wolfSSL | 15:117db924cf7c | 1263 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1264 | case TLS_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1265 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1266 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1267 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1268 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1269 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1270 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1271 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1272 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1273 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1274 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1275 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1276 | |
wolfSSL | 15:117db924cf7c | 1277 | break; |
wolfSSL | 15:117db924cf7c | 1278 | #endif |
wolfSSL | 15:117db924cf7c | 1279 | |
wolfSSL | 15:117db924cf7c | 1280 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1281 | case TLS_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1282 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1283 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1284 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1285 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1286 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1287 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1288 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1289 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1290 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1291 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1292 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1293 | |
wolfSSL | 15:117db924cf7c | 1294 | break; |
wolfSSL | 15:117db924cf7c | 1295 | #endif |
wolfSSL | 15:117db924cf7c | 1296 | |
wolfSSL | 15:117db924cf7c | 1297 | #ifdef BUILD_TLS_RSA_WITH_NULL_SHA |
wolfSSL | 15:117db924cf7c | 1298 | case TLS_RSA_WITH_NULL_SHA : |
wolfSSL | 15:117db924cf7c | 1299 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1300 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1301 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1302 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1303 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1304 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1305 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1306 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1307 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1308 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1309 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1310 | |
wolfSSL | 15:117db924cf7c | 1311 | break; |
wolfSSL | 15:117db924cf7c | 1312 | #endif |
wolfSSL | 15:117db924cf7c | 1313 | |
wolfSSL | 15:117db924cf7c | 1314 | #ifdef BUILD_TLS_RSA_WITH_NULL_SHA256 |
wolfSSL | 15:117db924cf7c | 1315 | case TLS_RSA_WITH_NULL_SHA256 : |
wolfSSL | 15:117db924cf7c | 1316 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1317 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1318 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1319 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1320 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1321 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1322 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1323 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1324 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1325 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1326 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1327 | |
wolfSSL | 15:117db924cf7c | 1328 | break; |
wolfSSL | 15:117db924cf7c | 1329 | #endif |
wolfSSL | 15:117db924cf7c | 1330 | |
wolfSSL | 15:117db924cf7c | 1331 | #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1332 | case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1333 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1334 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1335 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1336 | ssl->specs.kea = ntru_kea; |
wolfSSL | 15:117db924cf7c | 1337 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1338 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1339 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1340 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1341 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1342 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1343 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1344 | |
wolfSSL | 15:117db924cf7c | 1345 | break; |
wolfSSL | 15:117db924cf7c | 1346 | #endif |
wolfSSL | 15:117db924cf7c | 1347 | |
wolfSSL | 15:117db924cf7c | 1348 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1349 | case TLS_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1350 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1351 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1352 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1353 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1354 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1355 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1356 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1357 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1358 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1359 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1360 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1361 | |
wolfSSL | 15:117db924cf7c | 1362 | break; |
wolfSSL | 15:117db924cf7c | 1363 | #endif |
wolfSSL | 15:117db924cf7c | 1364 | |
wolfSSL | 15:117db924cf7c | 1365 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1366 | case TLS_RSA_WITH_AES_256_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1367 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1368 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1369 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1370 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1371 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1372 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1373 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1374 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1375 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1376 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1377 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1378 | |
wolfSSL | 15:117db924cf7c | 1379 | break; |
wolfSSL | 15:117db924cf7c | 1380 | #endif |
wolfSSL | 15:117db924cf7c | 1381 | |
wolfSSL | 15:117db924cf7c | 1382 | #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1383 | case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1384 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1385 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1386 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1387 | ssl->specs.kea = ntru_kea; |
wolfSSL | 15:117db924cf7c | 1388 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1389 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1390 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1391 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1392 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1393 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1394 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1395 | |
wolfSSL | 15:117db924cf7c | 1396 | break; |
wolfSSL | 15:117db924cf7c | 1397 | #endif |
wolfSSL | 15:117db924cf7c | 1398 | |
wolfSSL | 15:117db924cf7c | 1399 | #ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1400 | case TLS_PSK_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1401 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1402 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1403 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1404 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1405 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1406 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1407 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1408 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1409 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1410 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1411 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1412 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1413 | |
wolfSSL | 15:117db924cf7c | 1414 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1415 | break; |
wolfSSL | 15:117db924cf7c | 1416 | #endif |
wolfSSL | 15:117db924cf7c | 1417 | |
wolfSSL | 15:117db924cf7c | 1418 | #ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1419 | case TLS_PSK_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 1420 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1421 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1422 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1423 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1424 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1425 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1426 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1427 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1428 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1429 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1430 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1431 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1432 | |
wolfSSL | 15:117db924cf7c | 1433 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1434 | break; |
wolfSSL | 15:117db924cf7c | 1435 | #endif |
wolfSSL | 15:117db924cf7c | 1436 | |
wolfSSL | 15:117db924cf7c | 1437 | #ifdef BUILD_TLS_DH_anon_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1438 | case TLS_DH_anon_WITH_AES_256_GCM_SHA384: |
wolfSSL | 15:117db924cf7c | 1439 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1440 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1441 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1442 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1443 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1444 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1445 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1446 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1447 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1448 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1449 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1450 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1451 | |
wolfSSL | 15:117db924cf7c | 1452 | ssl->options.usingAnon_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1453 | break; |
wolfSSL | 15:117db924cf7c | 1454 | #endif |
wolfSSL | 15:117db924cf7c | 1455 | |
wolfSSL | 15:117db924cf7c | 1456 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1457 | case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1458 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1459 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1460 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1461 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1462 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1463 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1464 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1465 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1466 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1467 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1468 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1469 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1470 | |
wolfSSL | 15:117db924cf7c | 1471 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1472 | break; |
wolfSSL | 15:117db924cf7c | 1473 | #endif |
wolfSSL | 15:117db924cf7c | 1474 | |
wolfSSL | 15:117db924cf7c | 1475 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1476 | case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 1477 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1478 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1479 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1480 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1481 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1482 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1483 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1484 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1485 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1486 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1487 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1488 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1489 | |
wolfSSL | 15:117db924cf7c | 1490 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1491 | break; |
wolfSSL | 15:117db924cf7c | 1492 | #endif |
wolfSSL | 15:117db924cf7c | 1493 | |
wolfSSL | 15:117db924cf7c | 1494 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1495 | case TLS_PSK_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1496 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1497 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1498 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1499 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1500 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1501 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1502 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1503 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1504 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1505 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1506 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1507 | |
wolfSSL | 15:117db924cf7c | 1508 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1509 | break; |
wolfSSL | 15:117db924cf7c | 1510 | #endif |
wolfSSL | 15:117db924cf7c | 1511 | |
wolfSSL | 15:117db924cf7c | 1512 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 1513 | case TLS_PSK_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 1514 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1515 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1516 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1517 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1518 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1519 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1520 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1521 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1522 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1523 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1524 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1525 | |
wolfSSL | 15:117db924cf7c | 1526 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1527 | break; |
wolfSSL | 15:117db924cf7c | 1528 | #endif |
wolfSSL | 15:117db924cf7c | 1529 | |
wolfSSL | 15:117db924cf7c | 1530 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1531 | case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1532 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1533 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1534 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1535 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1536 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1537 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1538 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1539 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1540 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1541 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1542 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1543 | |
wolfSSL | 15:117db924cf7c | 1544 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1545 | break; |
wolfSSL | 15:117db924cf7c | 1546 | #endif |
wolfSSL | 15:117db924cf7c | 1547 | |
wolfSSL | 15:117db924cf7c | 1548 | #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 |
wolfSSL | 15:117db924cf7c | 1549 | case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 15:117db924cf7c | 1550 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1551 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1552 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1553 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1554 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1555 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1556 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1557 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1558 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1559 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1560 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1561 | |
wolfSSL | 15:117db924cf7c | 1562 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1563 | break; |
wolfSSL | 15:117db924cf7c | 1564 | #endif |
wolfSSL | 15:117db924cf7c | 1565 | |
wolfSSL | 15:117db924cf7c | 1566 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1567 | case TLS_PSK_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1568 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1569 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1570 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1571 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1572 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1573 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1574 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1575 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1576 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1577 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1578 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1579 | |
wolfSSL | 15:117db924cf7c | 1580 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1581 | break; |
wolfSSL | 15:117db924cf7c | 1582 | #endif |
wolfSSL | 15:117db924cf7c | 1583 | |
wolfSSL | 15:117db924cf7c | 1584 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1585 | case TLS_PSK_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1586 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1587 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1588 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1589 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1590 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1591 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1592 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1593 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1594 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1595 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1596 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1597 | |
wolfSSL | 15:117db924cf7c | 1598 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1599 | break; |
wolfSSL | 15:117db924cf7c | 1600 | #endif |
wolfSSL | 15:117db924cf7c | 1601 | |
wolfSSL | 15:117db924cf7c | 1602 | #ifdef BUILD_TLS_PSK_WITH_NULL_SHA256 |
wolfSSL | 15:117db924cf7c | 1603 | case TLS_PSK_WITH_NULL_SHA256 : |
wolfSSL | 15:117db924cf7c | 1604 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1605 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1606 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1607 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1608 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1609 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1610 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1611 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1612 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1613 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1614 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1615 | |
wolfSSL | 15:117db924cf7c | 1616 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1617 | break; |
wolfSSL | 15:117db924cf7c | 1618 | #endif |
wolfSSL | 15:117db924cf7c | 1619 | |
wolfSSL | 15:117db924cf7c | 1620 | #ifdef BUILD_TLS_PSK_WITH_NULL_SHA384 |
wolfSSL | 15:117db924cf7c | 1621 | case TLS_PSK_WITH_NULL_SHA384 : |
wolfSSL | 15:117db924cf7c | 1622 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1623 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1624 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1625 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1626 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1627 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1628 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1629 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1630 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1631 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1632 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1633 | |
wolfSSL | 15:117db924cf7c | 1634 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1635 | break; |
wolfSSL | 15:117db924cf7c | 1636 | #endif |
wolfSSL | 15:117db924cf7c | 1637 | |
wolfSSL | 15:117db924cf7c | 1638 | #ifdef BUILD_TLS_PSK_WITH_NULL_SHA |
wolfSSL | 15:117db924cf7c | 1639 | case TLS_PSK_WITH_NULL_SHA : |
wolfSSL | 15:117db924cf7c | 1640 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1641 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1642 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1643 | ssl->specs.kea = psk_kea; |
wolfSSL | 15:117db924cf7c | 1644 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1645 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1646 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1647 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1648 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1649 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1650 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1651 | |
wolfSSL | 15:117db924cf7c | 1652 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1653 | break; |
wolfSSL | 15:117db924cf7c | 1654 | #endif |
wolfSSL | 15:117db924cf7c | 1655 | |
wolfSSL | 15:117db924cf7c | 1656 | #ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256 |
wolfSSL | 15:117db924cf7c | 1657 | case TLS_DHE_PSK_WITH_NULL_SHA256 : |
wolfSSL | 15:117db924cf7c | 1658 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1659 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1660 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1661 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1662 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1663 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1664 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1665 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1666 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1667 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1668 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1669 | |
wolfSSL | 15:117db924cf7c | 1670 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1671 | break; |
wolfSSL | 15:117db924cf7c | 1672 | #endif |
wolfSSL | 15:117db924cf7c | 1673 | |
wolfSSL | 15:117db924cf7c | 1674 | #ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384 |
wolfSSL | 15:117db924cf7c | 1675 | case TLS_DHE_PSK_WITH_NULL_SHA384 : |
wolfSSL | 15:117db924cf7c | 1676 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 1677 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1678 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1679 | ssl->specs.kea = dhe_psk_kea; |
wolfSSL | 15:117db924cf7c | 1680 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 1681 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1682 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1683 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1684 | ssl->specs.key_size = 0; |
wolfSSL | 15:117db924cf7c | 1685 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1686 | ssl->specs.iv_size = 0; |
wolfSSL | 15:117db924cf7c | 1687 | |
wolfSSL | 15:117db924cf7c | 1688 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 15:117db924cf7c | 1689 | break; |
wolfSSL | 15:117db924cf7c | 1690 | #endif |
wolfSSL | 15:117db924cf7c | 1691 | |
wolfSSL | 15:117db924cf7c | 1692 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1693 | case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1694 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1695 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1696 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1697 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1698 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1699 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1700 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1701 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1702 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1703 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1704 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1705 | |
wolfSSL | 15:117db924cf7c | 1706 | break; |
wolfSSL | 15:117db924cf7c | 1707 | #endif |
wolfSSL | 15:117db924cf7c | 1708 | |
wolfSSL | 15:117db924cf7c | 1709 | #ifdef BUILD_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1710 | case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1711 | ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; |
wolfSSL | 15:117db924cf7c | 1712 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1713 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1714 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1715 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1716 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1717 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1718 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1719 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1720 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1721 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1722 | |
wolfSSL | 15:117db924cf7c | 1723 | break; |
wolfSSL | 15:117db924cf7c | 1724 | #endif |
wolfSSL | 15:117db924cf7c | 1725 | |
wolfSSL | 15:117db924cf7c | 1726 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1727 | case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1728 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1729 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1730 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1731 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1732 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1733 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1734 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1735 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1736 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1737 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1738 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1739 | |
wolfSSL | 15:117db924cf7c | 1740 | break; |
wolfSSL | 15:117db924cf7c | 1741 | #endif |
wolfSSL | 15:117db924cf7c | 1742 | |
wolfSSL | 15:117db924cf7c | 1743 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1744 | case TLS_DHE_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1745 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1746 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1747 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1748 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1749 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1750 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1751 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1752 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1753 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1754 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1755 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1756 | |
wolfSSL | 15:117db924cf7c | 1757 | break; |
wolfSSL | 15:117db924cf7c | 1758 | #endif |
wolfSSL | 15:117db924cf7c | 1759 | |
wolfSSL | 15:117db924cf7c | 1760 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1761 | case TLS_DHE_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1762 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1763 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1764 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1765 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1766 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1767 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1768 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1769 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1770 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1771 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1772 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1773 | |
wolfSSL | 15:117db924cf7c | 1774 | break; |
wolfSSL | 15:117db924cf7c | 1775 | #endif |
wolfSSL | 15:117db924cf7c | 1776 | |
wolfSSL | 15:117db924cf7c | 1777 | #ifdef BUILD_TLS_RSA_WITH_HC_128_MD5 |
wolfSSL | 15:117db924cf7c | 1778 | case TLS_RSA_WITH_HC_128_MD5 : |
wolfSSL | 15:117db924cf7c | 1779 | ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; |
wolfSSL | 15:117db924cf7c | 1780 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1781 | ssl->specs.mac_algorithm = md5_mac; |
wolfSSL | 15:117db924cf7c | 1782 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1783 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1784 | ssl->specs.hash_size = WC_MD5_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1785 | ssl->specs.pad_size = PAD_MD5; |
wolfSSL | 15:117db924cf7c | 1786 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1787 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1788 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1789 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1790 | |
wolfSSL | 15:117db924cf7c | 1791 | break; |
wolfSSL | 15:117db924cf7c | 1792 | #endif |
wolfSSL | 15:117db924cf7c | 1793 | |
wolfSSL | 15:117db924cf7c | 1794 | #ifdef BUILD_TLS_RSA_WITH_HC_128_SHA |
wolfSSL | 15:117db924cf7c | 1795 | case TLS_RSA_WITH_HC_128_SHA : |
wolfSSL | 15:117db924cf7c | 1796 | ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; |
wolfSSL | 15:117db924cf7c | 1797 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1798 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1799 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1800 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1801 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1802 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1803 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1804 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1805 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1806 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1807 | |
wolfSSL | 15:117db924cf7c | 1808 | break; |
wolfSSL | 15:117db924cf7c | 1809 | #endif |
wolfSSL | 15:117db924cf7c | 1810 | |
wolfSSL | 15:117db924cf7c | 1811 | #ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256 |
wolfSSL | 15:117db924cf7c | 1812 | case TLS_RSA_WITH_HC_128_B2B256: |
wolfSSL | 15:117db924cf7c | 1813 | ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; |
wolfSSL | 15:117db924cf7c | 1814 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1815 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 15:117db924cf7c | 1816 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1817 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1818 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 15:117db924cf7c | 1819 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1820 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1821 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1822 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1823 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1824 | |
wolfSSL | 15:117db924cf7c | 1825 | break; |
wolfSSL | 15:117db924cf7c | 1826 | #endif |
wolfSSL | 15:117db924cf7c | 1827 | |
wolfSSL | 15:117db924cf7c | 1828 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256 |
wolfSSL | 15:117db924cf7c | 1829 | case TLS_RSA_WITH_AES_128_CBC_B2B256: |
wolfSSL | 15:117db924cf7c | 1830 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1831 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1832 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 15:117db924cf7c | 1833 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1834 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1835 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 15:117db924cf7c | 1836 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1837 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1838 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1839 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1840 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1841 | |
wolfSSL | 15:117db924cf7c | 1842 | break; |
wolfSSL | 15:117db924cf7c | 1843 | #endif |
wolfSSL | 15:117db924cf7c | 1844 | |
wolfSSL | 15:117db924cf7c | 1845 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256 |
wolfSSL | 15:117db924cf7c | 1846 | case TLS_RSA_WITH_AES_256_CBC_B2B256: |
wolfSSL | 15:117db924cf7c | 1847 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 1848 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1849 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 15:117db924cf7c | 1850 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1851 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1852 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 15:117db924cf7c | 1853 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1854 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1855 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1856 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1857 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1858 | |
wolfSSL | 15:117db924cf7c | 1859 | break; |
wolfSSL | 15:117db924cf7c | 1860 | #endif |
wolfSSL | 15:117db924cf7c | 1861 | |
wolfSSL | 15:117db924cf7c | 1862 | #ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA |
wolfSSL | 15:117db924cf7c | 1863 | case TLS_RSA_WITH_RABBIT_SHA : |
wolfSSL | 15:117db924cf7c | 1864 | ssl->specs.bulk_cipher_algorithm = wolfssl_rabbit; |
wolfSSL | 15:117db924cf7c | 1865 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 1866 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1867 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1868 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1869 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1870 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1871 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1872 | ssl->specs.key_size = RABBIT_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1873 | ssl->specs.block_size = 0; |
wolfSSL | 15:117db924cf7c | 1874 | ssl->specs.iv_size = RABBIT_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1875 | |
wolfSSL | 15:117db924cf7c | 1876 | break; |
wolfSSL | 15:117db924cf7c | 1877 | #endif |
wolfSSL | 15:117db924cf7c | 1878 | |
wolfSSL | 15:117db924cf7c | 1879 | #ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1880 | case TLS_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1881 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1882 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1883 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1884 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1885 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1886 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1887 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1888 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1889 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1890 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1891 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1892 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1893 | |
wolfSSL | 15:117db924cf7c | 1894 | break; |
wolfSSL | 15:117db924cf7c | 1895 | #endif |
wolfSSL | 15:117db924cf7c | 1896 | |
wolfSSL | 15:117db924cf7c | 1897 | #ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1898 | case TLS_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 1899 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1900 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1901 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1902 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1903 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1904 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1905 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1906 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1907 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1908 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1909 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1910 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1911 | |
wolfSSL | 15:117db924cf7c | 1912 | break; |
wolfSSL | 15:117db924cf7c | 1913 | #endif |
wolfSSL | 15:117db924cf7c | 1914 | |
wolfSSL | 15:117db924cf7c | 1915 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 15:117db924cf7c | 1916 | case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 15:117db924cf7c | 1917 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1918 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1919 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1920 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1921 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1922 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1923 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1924 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1925 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1926 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1927 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1928 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1929 | |
wolfSSL | 15:117db924cf7c | 1930 | break; |
wolfSSL | 15:117db924cf7c | 1931 | #endif |
wolfSSL | 15:117db924cf7c | 1932 | |
wolfSSL | 15:117db924cf7c | 1933 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 15:117db924cf7c | 1934 | case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 15:117db924cf7c | 1935 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; |
wolfSSL | 15:117db924cf7c | 1936 | ssl->specs.cipher_type = aead; |
wolfSSL | 15:117db924cf7c | 1937 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 15:117db924cf7c | 1938 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 1939 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1940 | ssl->specs.hash_size = WC_SHA384_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1941 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1942 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1943 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1944 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1945 | ssl->specs.iv_size = AESGCM_IMP_IV_SZ; |
wolfSSL | 15:117db924cf7c | 1946 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 15:117db924cf7c | 1947 | |
wolfSSL | 15:117db924cf7c | 1948 | break; |
wolfSSL | 15:117db924cf7c | 1949 | #endif |
wolfSSL | 15:117db924cf7c | 1950 | |
wolfSSL | 15:117db924cf7c | 1951 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1952 | case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1953 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 1954 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1955 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1956 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1957 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1958 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1959 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1960 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1961 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1962 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1963 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1964 | |
wolfSSL | 15:117db924cf7c | 1965 | break; |
wolfSSL | 15:117db924cf7c | 1966 | #endif |
wolfSSL | 15:117db924cf7c | 1967 | |
wolfSSL | 15:117db924cf7c | 1968 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 1969 | case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 1970 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 1971 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1972 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 1973 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1974 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1975 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1976 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1977 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1978 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1979 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1980 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1981 | |
wolfSSL | 15:117db924cf7c | 1982 | break; |
wolfSSL | 15:117db924cf7c | 1983 | #endif |
wolfSSL | 15:117db924cf7c | 1984 | |
wolfSSL | 15:117db924cf7c | 1985 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 1986 | case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 1987 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 1988 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 1989 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 1990 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 1991 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 1992 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 1993 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 1994 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 1995 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 1996 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 1997 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 1998 | |
wolfSSL | 15:117db924cf7c | 1999 | break; |
wolfSSL | 15:117db924cf7c | 2000 | #endif |
wolfSSL | 15:117db924cf7c | 2001 | |
wolfSSL | 15:117db924cf7c | 2002 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 2003 | case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 2004 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 2005 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2006 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 2007 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 2008 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2009 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2010 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2011 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2012 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2013 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2014 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2015 | |
wolfSSL | 15:117db924cf7c | 2016 | break; |
wolfSSL | 15:117db924cf7c | 2017 | #endif |
wolfSSL | 15:117db924cf7c | 2018 | |
wolfSSL | 15:117db924cf7c | 2019 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 2020 | case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 2021 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 2022 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2023 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 2024 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 2025 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2026 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2027 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2028 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2029 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2030 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2031 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2032 | |
wolfSSL | 15:117db924cf7c | 2033 | break; |
wolfSSL | 15:117db924cf7c | 2034 | #endif |
wolfSSL | 15:117db924cf7c | 2035 | |
wolfSSL | 15:117db924cf7c | 2036 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA |
wolfSSL | 15:117db924cf7c | 2037 | case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 2038 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 2039 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2040 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 2041 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 2042 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2043 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2044 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2045 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2046 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2047 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2048 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2049 | |
wolfSSL | 15:117db924cf7c | 2050 | break; |
wolfSSL | 15:117db924cf7c | 2051 | #endif |
wolfSSL | 15:117db924cf7c | 2052 | |
wolfSSL | 15:117db924cf7c | 2053 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 2054 | case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 2055 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 2056 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2057 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 2058 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 2059 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2060 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2061 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2062 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2063 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2064 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2065 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2066 | |
wolfSSL | 15:117db924cf7c | 2067 | break; |
wolfSSL | 15:117db924cf7c | 2068 | #endif |
wolfSSL | 15:117db924cf7c | 2069 | |
wolfSSL | 15:117db924cf7c | 2070 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 |
wolfSSL | 15:117db924cf7c | 2071 | case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 : |
wolfSSL | 15:117db924cf7c | 2072 | ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; |
wolfSSL | 15:117db924cf7c | 2073 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2074 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 2075 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 2076 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2077 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2078 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2079 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2080 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2081 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2082 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2083 | |
wolfSSL | 15:117db924cf7c | 2084 | break; |
wolfSSL | 15:117db924cf7c | 2085 | #endif |
wolfSSL | 15:117db924cf7c | 2086 | |
wolfSSL | 15:117db924cf7c | 2087 | #ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA |
wolfSSL | 15:117db924cf7c | 2088 | case TLS_DH_anon_WITH_AES_128_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 2089 | ssl->specs.bulk_cipher_algorithm = wolfssl_aes; |
wolfSSL | 15:117db924cf7c | 2090 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2091 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 2092 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 15:117db924cf7c | 2093 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 2094 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2095 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2096 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2097 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2098 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2099 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2100 | |
wolfSSL | 15:117db924cf7c | 2101 | ssl->options.usingAnon_cipher = 1; |
wolfSSL | 15:117db924cf7c | 2102 | break; |
wolfSSL | 15:117db924cf7c | 2103 | #endif |
wolfSSL | 15:117db924cf7c | 2104 | |
wolfSSL | 15:117db924cf7c | 2105 | #ifdef BUILD_SSL_RSA_WITH_IDEA_CBC_SHA |
wolfSSL | 15:117db924cf7c | 2106 | case SSL_RSA_WITH_IDEA_CBC_SHA : |
wolfSSL | 15:117db924cf7c | 2107 | ssl->specs.bulk_cipher_algorithm = wolfssl_idea; |
wolfSSL | 15:117db924cf7c | 2108 | ssl->specs.cipher_type = block; |
wolfSSL | 15:117db924cf7c | 2109 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 15:117db924cf7c | 2110 | ssl->specs.kea = rsa_kea; |
wolfSSL | 15:117db924cf7c | 2111 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 15:117db924cf7c | 2112 | ssl->specs.hash_size = WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2113 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2114 | ssl->specs.static_ecdh = 0; |
wolfSSL | 15:117db924cf7c | 2115 | ssl->specs.key_size = IDEA_KEY_SIZE; |
wolfSSL | 15:117db924cf7c | 2116 | ssl->specs.block_size = IDEA_BLOCK_SIZE; |
wolfSSL | 15:117db924cf7c | 2117 | ssl->specs.iv_size = IDEA_IV_SIZE; |
wolfSSL | 15:117db924cf7c | 2118 | |
wolfSSL | 15:117db924cf7c | 2119 | break; |
wolfSSL | 15:117db924cf7c | 2120 | #endif |
wolfSSL | 15:117db924cf7c | 2121 | |
wolfSSL | 15:117db924cf7c | 2122 | #ifdef BUILD_WDM_WITH_NULL_SHA256 |
wolfSSL | 15:117db924cf7c | 2123 | case WDM_WITH_NULL_SHA256 : |
wolfSSL | 15:117db924cf7c | 2124 | ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; |
wolfSSL | 15:117db924cf7c | 2125 | ssl->specs.cipher_type = stream; |
wolfSSL | 15:117db924cf7c | 2126 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 15:117db924cf7c | 2127 | ssl->specs.kea = no_kea; |
wolfSSL | 15:117db924cf7c | 2128 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 15:117db924cf7c | 2129 | ssl->specs.hash_size = WC_SHA256_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 2130 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 15:117db924cf7c | 2131 | |
wolfSSL | 15:117db924cf7c | 2132 | break; |
wolfSSL | 15:117db924cf7c | 2133 | #endif |
wolfSSL | 15:117db924cf7c | 2134 | |
wolfSSL | 15:117db924cf7c | 2135 | default: |
wolfSSL | 15:117db924cf7c | 2136 | WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs"); |
wolfSSL | 15:117db924cf7c | 2137 | return UNSUPPORTED_SUITE; |
wolfSSL | 15:117db924cf7c | 2138 | } /* switch */ |
wolfSSL | 15:117db924cf7c | 2139 | } /* if ECC / Normal suites else */ |
wolfSSL | 15:117db924cf7c | 2140 | |
wolfSSL | 15:117db924cf7c | 2141 | /* set TLS if it hasn't been turned off */ |
wolfSSL | 15:117db924cf7c | 2142 | if (ssl->version.major == 3 && ssl->version.minor >= 1) { |
wolfSSL | 15:117db924cf7c | 2143 | #ifndef NO_TLS |
wolfSSL | 15:117db924cf7c | 2144 | ssl->options.tls = 1; |
wolfSSL | 15:117db924cf7c | 2145 | #ifndef WOLFSSL_NO_TLS12 |
wolfSSL | 15:117db924cf7c | 2146 | ssl->hmac = TLS_hmac; |
wolfSSL | 15:117db924cf7c | 2147 | #endif |
wolfSSL | 15:117db924cf7c | 2148 | if (ssl->version.minor >= 2) { |
wolfSSL | 15:117db924cf7c | 2149 | ssl->options.tls1_1 = 1; |
wolfSSL | 15:117db924cf7c | 2150 | if (ssl->version.minor >= 4) |
wolfSSL | 15:117db924cf7c | 2151 | ssl->options.tls1_3 = 1; |
wolfSSL | 15:117db924cf7c | 2152 | } |
wolfSSL | 15:117db924cf7c | 2153 | #endif |
wolfSSL | 15:117db924cf7c | 2154 | } |
wolfSSL | 15:117db924cf7c | 2155 | |
wolfSSL | 15:117db924cf7c | 2156 | #ifdef WOLFSSL_DTLS |
wolfSSL | 15:117db924cf7c | 2157 | if (ssl->options.dtls) |
wolfSSL | 15:117db924cf7c | 2158 | ssl->hmac = TLS_hmac; |
wolfSSL | 15:117db924cf7c | 2159 | #endif |
wolfSSL | 15:117db924cf7c | 2160 | |
wolfSSL | 15:117db924cf7c | 2161 | return 0; |
wolfSSL | 15:117db924cf7c | 2162 | } |
wolfSSL | 15:117db924cf7c | 2163 | |
wolfSSL | 15:117db924cf7c | 2164 | |
wolfSSL | 15:117db924cf7c | 2165 | enum KeyStuff { |
wolfSSL | 15:117db924cf7c | 2166 | MASTER_ROUNDS = 3, |
wolfSSL | 15:117db924cf7c | 2167 | PREFIX = 3, /* up to three letters for master prefix */ |
wolfSSL | 15:117db924cf7c | 2168 | KEY_PREFIX = 9 /* up to 9 prefix letters for key rounds */ |
wolfSSL | 15:117db924cf7c | 2169 | |
wolfSSL | 15:117db924cf7c | 2170 | |
wolfSSL | 15:117db924cf7c | 2171 | }; |
wolfSSL | 15:117db924cf7c | 2172 | |
wolfSSL | 15:117db924cf7c | 2173 | #ifndef NO_OLD_TLS |
wolfSSL | 15:117db924cf7c | 2174 | /* true or false, zero for error */ |
wolfSSL | 15:117db924cf7c | 2175 | static int SetPrefix(byte* sha_input, int idx) |
wolfSSL | 15:117db924cf7c | 2176 | { |
wolfSSL | 15:117db924cf7c | 2177 | switch (idx) { |
wolfSSL | 15:117db924cf7c | 2178 | case 0: |
wolfSSL | 15:117db924cf7c | 2179 | XMEMCPY(sha_input, "A", 1); |
wolfSSL | 15:117db924cf7c | 2180 | break; |
wolfSSL | 15:117db924cf7c | 2181 | case 1: |
wolfSSL | 15:117db924cf7c | 2182 | XMEMCPY(sha_input, "BB", 2); |
wolfSSL | 15:117db924cf7c | 2183 | break; |
wolfSSL | 15:117db924cf7c | 2184 | case 2: |
wolfSSL | 15:117db924cf7c | 2185 | XMEMCPY(sha_input, "CCC", 3); |
wolfSSL | 15:117db924cf7c | 2186 | break; |
wolfSSL | 15:117db924cf7c | 2187 | case 3: |
wolfSSL | 15:117db924cf7c | 2188 | XMEMCPY(sha_input, "DDDD", 4); |
wolfSSL | 15:117db924cf7c | 2189 | break; |
wolfSSL | 15:117db924cf7c | 2190 | case 4: |
wolfSSL | 15:117db924cf7c | 2191 | XMEMCPY(sha_input, "EEEEE", 5); |
wolfSSL | 15:117db924cf7c | 2192 | break; |
wolfSSL | 15:117db924cf7c | 2193 | case 5: |
wolfSSL | 15:117db924cf7c | 2194 | XMEMCPY(sha_input, "FFFFFF", 6); |
wolfSSL | 15:117db924cf7c | 2195 | break; |
wolfSSL | 15:117db924cf7c | 2196 | case 6: |
wolfSSL | 15:117db924cf7c | 2197 | XMEMCPY(sha_input, "GGGGGGG", 7); |
wolfSSL | 15:117db924cf7c | 2198 | break; |
wolfSSL | 15:117db924cf7c | 2199 | case 7: |
wolfSSL | 15:117db924cf7c | 2200 | XMEMCPY(sha_input, "HHHHHHHH", 8); |
wolfSSL | 15:117db924cf7c | 2201 | break; |
wolfSSL | 15:117db924cf7c | 2202 | case 8: |
wolfSSL | 15:117db924cf7c | 2203 | XMEMCPY(sha_input, "IIIIIIIII", 9); |
wolfSSL | 15:117db924cf7c | 2204 | break; |
wolfSSL | 15:117db924cf7c | 2205 | default: |
wolfSSL | 15:117db924cf7c | 2206 | WOLFSSL_MSG("Set Prefix error, bad input"); |
wolfSSL | 15:117db924cf7c | 2207 | return 0; |
wolfSSL | 15:117db924cf7c | 2208 | } |
wolfSSL | 15:117db924cf7c | 2209 | return 1; |
wolfSSL | 15:117db924cf7c | 2210 | } |
wolfSSL | 15:117db924cf7c | 2211 | #endif |
wolfSSL | 15:117db924cf7c | 2212 | |
wolfSSL | 15:117db924cf7c | 2213 | |
wolfSSL | 15:117db924cf7c | 2214 | static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, |
wolfSSL | 15:117db924cf7c | 2215 | int side, void* heap, int devId) |
wolfSSL | 15:117db924cf7c | 2216 | { |
wolfSSL | 15:117db924cf7c | 2217 | #ifdef BUILD_ARC4 |
wolfSSL | 15:117db924cf7c | 2218 | word32 sz = specs->key_size; |
wolfSSL | 15:117db924cf7c | 2219 | if (specs->bulk_cipher_algorithm == wolfssl_rc4) { |
wolfSSL | 15:117db924cf7c | 2220 | if (enc && enc->arc4 == NULL) |
wolfSSL | 15:117db924cf7c | 2221 | enc->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2222 | if (enc && enc->arc4 == NULL) |
wolfSSL | 15:117db924cf7c | 2223 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2224 | if (dec && dec->arc4 == NULL) |
wolfSSL | 15:117db924cf7c | 2225 | dec->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2226 | if (dec && dec->arc4 == NULL) |
wolfSSL | 15:117db924cf7c | 2227 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2228 | |
wolfSSL | 15:117db924cf7c | 2229 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2230 | if (wc_Arc4Init(enc->arc4, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2231 | WOLFSSL_MSG("Arc4Init failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2232 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2233 | } |
wolfSSL | 15:117db924cf7c | 2234 | } |
wolfSSL | 15:117db924cf7c | 2235 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2236 | if (wc_Arc4Init(dec->arc4, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2237 | WOLFSSL_MSG("Arc4Init failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2238 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2239 | } |
wolfSSL | 15:117db924cf7c | 2240 | } |
wolfSSL | 15:117db924cf7c | 2241 | |
wolfSSL | 15:117db924cf7c | 2242 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2243 | if (enc) |
wolfSSL | 15:117db924cf7c | 2244 | wc_Arc4SetKey(enc->arc4, keys->client_write_key, sz); |
wolfSSL | 15:117db924cf7c | 2245 | if (dec) |
wolfSSL | 15:117db924cf7c | 2246 | wc_Arc4SetKey(dec->arc4, keys->server_write_key, sz); |
wolfSSL | 15:117db924cf7c | 2247 | } |
wolfSSL | 15:117db924cf7c | 2248 | else { |
wolfSSL | 15:117db924cf7c | 2249 | if (enc) |
wolfSSL | 15:117db924cf7c | 2250 | wc_Arc4SetKey(enc->arc4, keys->server_write_key, sz); |
wolfSSL | 15:117db924cf7c | 2251 | if (dec) |
wolfSSL | 15:117db924cf7c | 2252 | wc_Arc4SetKey(dec->arc4, keys->client_write_key, sz); |
wolfSSL | 15:117db924cf7c | 2253 | } |
wolfSSL | 15:117db924cf7c | 2254 | if (enc) |
wolfSSL | 15:117db924cf7c | 2255 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2256 | if (dec) |
wolfSSL | 15:117db924cf7c | 2257 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2258 | } |
wolfSSL | 15:117db924cf7c | 2259 | #endif /* BUILD_ARC4 */ |
wolfSSL | 15:117db924cf7c | 2260 | |
wolfSSL | 15:117db924cf7c | 2261 | |
wolfSSL | 15:117db924cf7c | 2262 | #if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) |
wolfSSL | 15:117db924cf7c | 2263 | /* Check that the max implicit iv size is suffecient */ |
wolfSSL | 15:117db924cf7c | 2264 | #if (AEAD_MAX_IMP_SZ < 12) /* CHACHA20_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2265 | #error AEAD_MAX_IMP_SZ is too small for ChaCha20 |
wolfSSL | 15:117db924cf7c | 2266 | #endif |
wolfSSL | 15:117db924cf7c | 2267 | #if (MAX_WRITE_IV_SZ < 12) /* CHACHA20_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2268 | #error MAX_WRITE_IV_SZ is too small for ChaCha20 |
wolfSSL | 15:117db924cf7c | 2269 | #endif |
wolfSSL | 15:117db924cf7c | 2270 | |
wolfSSL | 15:117db924cf7c | 2271 | if (specs->bulk_cipher_algorithm == wolfssl_chacha) { |
wolfSSL | 15:117db924cf7c | 2272 | int chachaRet; |
wolfSSL | 15:117db924cf7c | 2273 | if (enc && enc->chacha == NULL) |
wolfSSL | 15:117db924cf7c | 2274 | enc->chacha = |
wolfSSL | 15:117db924cf7c | 2275 | (ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2276 | if (enc && enc->chacha == NULL) |
wolfSSL | 15:117db924cf7c | 2277 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2278 | if (dec && dec->chacha == NULL) |
wolfSSL | 15:117db924cf7c | 2279 | dec->chacha = |
wolfSSL | 15:117db924cf7c | 2280 | (ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2281 | if (dec && dec->chacha == NULL) |
wolfSSL | 15:117db924cf7c | 2282 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2283 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2284 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2285 | chachaRet = wc_Chacha_SetKey(enc->chacha, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2286 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2287 | XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2288 | CHACHA20_IMP_IV_SZ); |
wolfSSL | 15:117db924cf7c | 2289 | if (chachaRet != 0) return chachaRet; |
wolfSSL | 15:117db924cf7c | 2290 | } |
wolfSSL | 15:117db924cf7c | 2291 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2292 | chachaRet = wc_Chacha_SetKey(dec->chacha, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2293 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2294 | XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2295 | CHACHA20_IMP_IV_SZ); |
wolfSSL | 15:117db924cf7c | 2296 | if (chachaRet != 0) return chachaRet; |
wolfSSL | 15:117db924cf7c | 2297 | } |
wolfSSL | 15:117db924cf7c | 2298 | } |
wolfSSL | 15:117db924cf7c | 2299 | else { |
wolfSSL | 15:117db924cf7c | 2300 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2301 | chachaRet = wc_Chacha_SetKey(enc->chacha, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2302 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2303 | XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2304 | CHACHA20_IMP_IV_SZ); |
wolfSSL | 15:117db924cf7c | 2305 | if (chachaRet != 0) return chachaRet; |
wolfSSL | 15:117db924cf7c | 2306 | } |
wolfSSL | 15:117db924cf7c | 2307 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2308 | chachaRet = wc_Chacha_SetKey(dec->chacha, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2309 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2310 | XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2311 | CHACHA20_IMP_IV_SZ); |
wolfSSL | 15:117db924cf7c | 2312 | if (chachaRet != 0) return chachaRet; |
wolfSSL | 15:117db924cf7c | 2313 | } |
wolfSSL | 15:117db924cf7c | 2314 | } |
wolfSSL | 15:117db924cf7c | 2315 | |
wolfSSL | 15:117db924cf7c | 2316 | if (enc) |
wolfSSL | 15:117db924cf7c | 2317 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2318 | if (dec) |
wolfSSL | 15:117db924cf7c | 2319 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2320 | } |
wolfSSL | 15:117db924cf7c | 2321 | #endif /* HAVE_CHACHA && HAVE_POLY1305 */ |
wolfSSL | 15:117db924cf7c | 2322 | |
wolfSSL | 15:117db924cf7c | 2323 | |
wolfSSL | 15:117db924cf7c | 2324 | #ifdef HAVE_HC128 |
wolfSSL | 15:117db924cf7c | 2325 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2326 | #if (MAX_WRITE_IV_SZ < 16) /* HC_128_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2327 | #error MAX_WRITE_IV_SZ too small for HC128 |
wolfSSL | 15:117db924cf7c | 2328 | #endif |
wolfSSL | 15:117db924cf7c | 2329 | |
wolfSSL | 15:117db924cf7c | 2330 | if (specs->bulk_cipher_algorithm == wolfssl_hc128) { |
wolfSSL | 15:117db924cf7c | 2331 | int hcRet; |
wolfSSL | 15:117db924cf7c | 2332 | if (enc && enc->hc128 == NULL) |
wolfSSL | 15:117db924cf7c | 2333 | enc->hc128 = |
wolfSSL | 15:117db924cf7c | 2334 | (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2335 | if (enc && enc->hc128 == NULL) |
wolfSSL | 15:117db924cf7c | 2336 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2337 | if (dec && dec->hc128 == NULL) |
wolfSSL | 15:117db924cf7c | 2338 | dec->hc128 = |
wolfSSL | 15:117db924cf7c | 2339 | (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2340 | if (dec && dec->hc128 == NULL) |
wolfSSL | 15:117db924cf7c | 2341 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2342 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2343 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2344 | hcRet = wc_Hc128_SetKey(enc->hc128, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2345 | keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2346 | if (hcRet != 0) return hcRet; |
wolfSSL | 15:117db924cf7c | 2347 | } |
wolfSSL | 15:117db924cf7c | 2348 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2349 | hcRet = wc_Hc128_SetKey(dec->hc128, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2350 | keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2351 | if (hcRet != 0) return hcRet; |
wolfSSL | 15:117db924cf7c | 2352 | } |
wolfSSL | 15:117db924cf7c | 2353 | } |
wolfSSL | 15:117db924cf7c | 2354 | else { |
wolfSSL | 15:117db924cf7c | 2355 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2356 | hcRet = wc_Hc128_SetKey(enc->hc128, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2357 | keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2358 | if (hcRet != 0) return hcRet; |
wolfSSL | 15:117db924cf7c | 2359 | } |
wolfSSL | 15:117db924cf7c | 2360 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2361 | hcRet = wc_Hc128_SetKey(dec->hc128, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2362 | keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2363 | if (hcRet != 0) return hcRet; |
wolfSSL | 15:117db924cf7c | 2364 | } |
wolfSSL | 15:117db924cf7c | 2365 | } |
wolfSSL | 15:117db924cf7c | 2366 | if (enc) |
wolfSSL | 15:117db924cf7c | 2367 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2368 | if (dec) |
wolfSSL | 15:117db924cf7c | 2369 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2370 | } |
wolfSSL | 15:117db924cf7c | 2371 | #endif /* HAVE_HC128 */ |
wolfSSL | 15:117db924cf7c | 2372 | |
wolfSSL | 15:117db924cf7c | 2373 | #ifdef BUILD_RABBIT |
wolfSSL | 15:117db924cf7c | 2374 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2375 | #if (MAX_WRITE_IV_SZ < 8) /* RABBIT_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2376 | #error MAX_WRITE_IV_SZ too small for RABBIT |
wolfSSL | 15:117db924cf7c | 2377 | #endif |
wolfSSL | 15:117db924cf7c | 2378 | |
wolfSSL | 15:117db924cf7c | 2379 | if (specs->bulk_cipher_algorithm == wolfssl_rabbit) { |
wolfSSL | 15:117db924cf7c | 2380 | int rabRet; |
wolfSSL | 15:117db924cf7c | 2381 | if (enc && enc->rabbit == NULL) |
wolfSSL | 15:117db924cf7c | 2382 | enc->rabbit = |
wolfSSL | 15:117db924cf7c | 2383 | (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2384 | if (enc && enc->rabbit == NULL) |
wolfSSL | 15:117db924cf7c | 2385 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2386 | if (dec && dec->rabbit == NULL) |
wolfSSL | 15:117db924cf7c | 2387 | dec->rabbit = |
wolfSSL | 15:117db924cf7c | 2388 | (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2389 | if (dec && dec->rabbit == NULL) |
wolfSSL | 15:117db924cf7c | 2390 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2391 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2392 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2393 | rabRet = wc_RabbitSetKey(enc->rabbit, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2394 | keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2395 | if (rabRet != 0) return rabRet; |
wolfSSL | 15:117db924cf7c | 2396 | } |
wolfSSL | 15:117db924cf7c | 2397 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2398 | rabRet = wc_RabbitSetKey(dec->rabbit, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2399 | keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2400 | if (rabRet != 0) return rabRet; |
wolfSSL | 15:117db924cf7c | 2401 | } |
wolfSSL | 15:117db924cf7c | 2402 | } |
wolfSSL | 15:117db924cf7c | 2403 | else { |
wolfSSL | 15:117db924cf7c | 2404 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2405 | rabRet = wc_RabbitSetKey(enc->rabbit, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2406 | keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2407 | if (rabRet != 0) return rabRet; |
wolfSSL | 15:117db924cf7c | 2408 | } |
wolfSSL | 15:117db924cf7c | 2409 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2410 | rabRet = wc_RabbitSetKey(dec->rabbit, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2411 | keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2412 | if (rabRet != 0) return rabRet; |
wolfSSL | 15:117db924cf7c | 2413 | } |
wolfSSL | 15:117db924cf7c | 2414 | } |
wolfSSL | 15:117db924cf7c | 2415 | if (enc) |
wolfSSL | 15:117db924cf7c | 2416 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2417 | if (dec) |
wolfSSL | 15:117db924cf7c | 2418 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2419 | } |
wolfSSL | 15:117db924cf7c | 2420 | #endif /* BUILD_RABBIT */ |
wolfSSL | 15:117db924cf7c | 2421 | |
wolfSSL | 15:117db924cf7c | 2422 | #ifdef BUILD_DES3 |
wolfSSL | 15:117db924cf7c | 2423 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2424 | #if (MAX_WRITE_IV_SZ < 8) /* DES_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2425 | #error MAX_WRITE_IV_SZ too small for 3DES |
wolfSSL | 15:117db924cf7c | 2426 | #endif |
wolfSSL | 15:117db924cf7c | 2427 | |
wolfSSL | 15:117db924cf7c | 2428 | if (specs->bulk_cipher_algorithm == wolfssl_triple_des) { |
wolfSSL | 15:117db924cf7c | 2429 | int desRet = 0; |
wolfSSL | 15:117db924cf7c | 2430 | |
wolfSSL | 15:117db924cf7c | 2431 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2432 | if (enc->des3 == NULL) |
wolfSSL | 15:117db924cf7c | 2433 | enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2434 | if (enc->des3 == NULL) |
wolfSSL | 15:117db924cf7c | 2435 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2436 | XMEMSET(enc->des3, 0, sizeof(Des3)); |
wolfSSL | 15:117db924cf7c | 2437 | } |
wolfSSL | 15:117db924cf7c | 2438 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2439 | if (dec->des3 == NULL) |
wolfSSL | 15:117db924cf7c | 2440 | dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2441 | if (dec->des3 == NULL) |
wolfSSL | 15:117db924cf7c | 2442 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2443 | XMEMSET(dec->des3, 0, sizeof(Des3)); |
wolfSSL | 15:117db924cf7c | 2444 | } |
wolfSSL | 15:117db924cf7c | 2445 | |
wolfSSL | 15:117db924cf7c | 2446 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2447 | if (wc_Des3Init(enc->des3, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2448 | WOLFSSL_MSG("Des3Init failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2449 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2450 | } |
wolfSSL | 15:117db924cf7c | 2451 | } |
wolfSSL | 15:117db924cf7c | 2452 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2453 | if (wc_Des3Init(dec->des3, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2454 | WOLFSSL_MSG("Des3Init failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2455 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2456 | } |
wolfSSL | 15:117db924cf7c | 2457 | } |
wolfSSL | 15:117db924cf7c | 2458 | |
wolfSSL | 15:117db924cf7c | 2459 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2460 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2461 | desRet = wc_Des3_SetKey(enc->des3, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2462 | keys->client_write_IV, DES_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2463 | if (desRet != 0) return desRet; |
wolfSSL | 15:117db924cf7c | 2464 | } |
wolfSSL | 15:117db924cf7c | 2465 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2466 | desRet = wc_Des3_SetKey(dec->des3, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2467 | keys->server_write_IV, DES_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2468 | if (desRet != 0) return desRet; |
wolfSSL | 15:117db924cf7c | 2469 | } |
wolfSSL | 15:117db924cf7c | 2470 | } |
wolfSSL | 15:117db924cf7c | 2471 | else { |
wolfSSL | 15:117db924cf7c | 2472 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2473 | desRet = wc_Des3_SetKey(enc->des3, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2474 | keys->server_write_IV, DES_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2475 | if (desRet != 0) return desRet; |
wolfSSL | 15:117db924cf7c | 2476 | } |
wolfSSL | 15:117db924cf7c | 2477 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2478 | desRet = wc_Des3_SetKey(dec->des3, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2479 | keys->client_write_IV, DES_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2480 | if (desRet != 0) return desRet; |
wolfSSL | 15:117db924cf7c | 2481 | } |
wolfSSL | 15:117db924cf7c | 2482 | } |
wolfSSL | 15:117db924cf7c | 2483 | if (enc) |
wolfSSL | 15:117db924cf7c | 2484 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2485 | if (dec) |
wolfSSL | 15:117db924cf7c | 2486 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2487 | } |
wolfSSL | 15:117db924cf7c | 2488 | #endif /* BUILD_DES3 */ |
wolfSSL | 15:117db924cf7c | 2489 | |
wolfSSL | 15:117db924cf7c | 2490 | #ifdef BUILD_AES |
wolfSSL | 15:117db924cf7c | 2491 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2492 | #if (MAX_WRITE_IV_SZ < 16) /* AES_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2493 | #error MAX_WRITE_IV_SZ too small for AES |
wolfSSL | 15:117db924cf7c | 2494 | #endif |
wolfSSL | 15:117db924cf7c | 2495 | |
wolfSSL | 15:117db924cf7c | 2496 | if (specs->bulk_cipher_algorithm == wolfssl_aes) { |
wolfSSL | 15:117db924cf7c | 2497 | int aesRet = 0; |
wolfSSL | 15:117db924cf7c | 2498 | |
wolfSSL | 15:117db924cf7c | 2499 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2500 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2501 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2502 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2503 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2504 | XMEMSET(enc->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2505 | } |
wolfSSL | 15:117db924cf7c | 2506 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2507 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2508 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2509 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2510 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2511 | XMEMSET(dec->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2512 | } |
wolfSSL | 15:117db924cf7c | 2513 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2514 | if (wc_AesInit(enc->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2515 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2516 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2517 | } |
wolfSSL | 15:117db924cf7c | 2518 | } |
wolfSSL | 15:117db924cf7c | 2519 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2520 | if (wc_AesInit(dec->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2521 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2522 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2523 | } |
wolfSSL | 15:117db924cf7c | 2524 | } |
wolfSSL | 15:117db924cf7c | 2525 | |
wolfSSL | 15:117db924cf7c | 2526 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2527 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2528 | aesRet = wc_AesSetKey(enc->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2529 | specs->key_size, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2530 | AES_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2531 | if (aesRet != 0) return aesRet; |
wolfSSL | 15:117db924cf7c | 2532 | } |
wolfSSL | 15:117db924cf7c | 2533 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2534 | aesRet = wc_AesSetKey(dec->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2535 | specs->key_size, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2536 | AES_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2537 | if (aesRet != 0) return aesRet; |
wolfSSL | 15:117db924cf7c | 2538 | } |
wolfSSL | 15:117db924cf7c | 2539 | } |
wolfSSL | 15:117db924cf7c | 2540 | else { |
wolfSSL | 15:117db924cf7c | 2541 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2542 | aesRet = wc_AesSetKey(enc->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2543 | specs->key_size, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2544 | AES_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2545 | if (aesRet != 0) return aesRet; |
wolfSSL | 15:117db924cf7c | 2546 | } |
wolfSSL | 15:117db924cf7c | 2547 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2548 | aesRet = wc_AesSetKey(dec->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2549 | specs->key_size, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2550 | AES_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2551 | if (aesRet != 0) return aesRet; |
wolfSSL | 15:117db924cf7c | 2552 | } |
wolfSSL | 15:117db924cf7c | 2553 | } |
wolfSSL | 15:117db924cf7c | 2554 | if (enc) |
wolfSSL | 15:117db924cf7c | 2555 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2556 | if (dec) |
wolfSSL | 15:117db924cf7c | 2557 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2558 | } |
wolfSSL | 15:117db924cf7c | 2559 | #endif /* BUILD_AES */ |
wolfSSL | 15:117db924cf7c | 2560 | |
wolfSSL | 15:117db924cf7c | 2561 | #ifdef BUILD_AESGCM |
wolfSSL | 15:117db924cf7c | 2562 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2563 | #if (AEAD_MAX_IMP_SZ < 4) /* AESGCM_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2564 | #error AEAD_MAX_IMP_SZ too small for AESGCM |
wolfSSL | 15:117db924cf7c | 2565 | #endif |
wolfSSL | 15:117db924cf7c | 2566 | #if (AEAD_MAX_EXP_SZ < 8) /* AESGCM_EXP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2567 | #error AEAD_MAX_EXP_SZ too small for AESGCM |
wolfSSL | 15:117db924cf7c | 2568 | #endif |
wolfSSL | 15:117db924cf7c | 2569 | #if (MAX_WRITE_IV_SZ < 4) /* AESGCM_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2570 | #error MAX_WRITE_IV_SZ too small for AESGCM |
wolfSSL | 15:117db924cf7c | 2571 | #endif |
wolfSSL | 15:117db924cf7c | 2572 | |
wolfSSL | 15:117db924cf7c | 2573 | if (specs->bulk_cipher_algorithm == wolfssl_aes_gcm) { |
wolfSSL | 15:117db924cf7c | 2574 | int gcmRet; |
wolfSSL | 15:117db924cf7c | 2575 | |
wolfSSL | 15:117db924cf7c | 2576 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2577 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2578 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2579 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2580 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2581 | XMEMSET(enc->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2582 | } |
wolfSSL | 15:117db924cf7c | 2583 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2584 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2585 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2586 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2587 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2588 | XMEMSET(dec->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2589 | } |
wolfSSL | 15:117db924cf7c | 2590 | |
wolfSSL | 15:117db924cf7c | 2591 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2592 | if (wc_AesInit(enc->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2593 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2594 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2595 | } |
wolfSSL | 15:117db924cf7c | 2596 | } |
wolfSSL | 15:117db924cf7c | 2597 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2598 | if (wc_AesInit(dec->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2599 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2600 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2601 | } |
wolfSSL | 15:117db924cf7c | 2602 | } |
wolfSSL | 15:117db924cf7c | 2603 | |
wolfSSL | 15:117db924cf7c | 2604 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2605 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2606 | gcmRet = wc_AesGcmSetKey(enc->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2607 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2608 | if (gcmRet != 0) return gcmRet; |
wolfSSL | 15:117db924cf7c | 2609 | XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2610 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2611 | } |
wolfSSL | 15:117db924cf7c | 2612 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2613 | gcmRet = wc_AesGcmSetKey(dec->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2614 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2615 | if (gcmRet != 0) return gcmRet; |
wolfSSL | 15:117db924cf7c | 2616 | XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2617 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2618 | } |
wolfSSL | 15:117db924cf7c | 2619 | } |
wolfSSL | 15:117db924cf7c | 2620 | else { |
wolfSSL | 15:117db924cf7c | 2621 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2622 | gcmRet = wc_AesGcmSetKey(enc->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2623 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2624 | if (gcmRet != 0) return gcmRet; |
wolfSSL | 15:117db924cf7c | 2625 | XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2626 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2627 | } |
wolfSSL | 15:117db924cf7c | 2628 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2629 | gcmRet = wc_AesGcmSetKey(dec->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2630 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2631 | if (gcmRet != 0) return gcmRet; |
wolfSSL | 15:117db924cf7c | 2632 | XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2633 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2634 | } |
wolfSSL | 15:117db924cf7c | 2635 | } |
wolfSSL | 15:117db924cf7c | 2636 | if (enc) |
wolfSSL | 15:117db924cf7c | 2637 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2638 | if (dec) |
wolfSSL | 15:117db924cf7c | 2639 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2640 | } |
wolfSSL | 15:117db924cf7c | 2641 | #endif /* BUILD_AESGCM */ |
wolfSSL | 15:117db924cf7c | 2642 | |
wolfSSL | 15:117db924cf7c | 2643 | #ifdef HAVE_AESCCM |
wolfSSL | 15:117db924cf7c | 2644 | /* check that buffer sizes are sufficient (CCM is same size as GCM) */ |
wolfSSL | 15:117db924cf7c | 2645 | #if (AEAD_MAX_IMP_SZ < 4) /* AESGCM_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2646 | #error AEAD_MAX_IMP_SZ too small for AESCCM |
wolfSSL | 15:117db924cf7c | 2647 | #endif |
wolfSSL | 15:117db924cf7c | 2648 | #if (AEAD_MAX_EXP_SZ < 8) /* AESGCM_EXP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2649 | #error AEAD_MAX_EXP_SZ too small for AESCCM |
wolfSSL | 15:117db924cf7c | 2650 | #endif |
wolfSSL | 15:117db924cf7c | 2651 | #if (MAX_WRITE_IV_SZ < 4) /* AESGCM_IMP_IV_SZ */ |
wolfSSL | 15:117db924cf7c | 2652 | #error MAX_WRITE_IV_SZ too small for AESCCM |
wolfSSL | 15:117db924cf7c | 2653 | #endif |
wolfSSL | 15:117db924cf7c | 2654 | |
wolfSSL | 15:117db924cf7c | 2655 | if (specs->bulk_cipher_algorithm == wolfssl_aes_ccm) { |
wolfSSL | 15:117db924cf7c | 2656 | int CcmRet; |
wolfSSL | 15:117db924cf7c | 2657 | |
wolfSSL | 15:117db924cf7c | 2658 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2659 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2660 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2661 | if (enc->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2662 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2663 | XMEMSET(enc->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2664 | } |
wolfSSL | 15:117db924cf7c | 2665 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2666 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2667 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2668 | if (dec->aes == NULL) |
wolfSSL | 15:117db924cf7c | 2669 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2670 | XMEMSET(dec->aes, 0, sizeof(Aes)); |
wolfSSL | 15:117db924cf7c | 2671 | } |
wolfSSL | 15:117db924cf7c | 2672 | |
wolfSSL | 15:117db924cf7c | 2673 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2674 | if (wc_AesInit(enc->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2675 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2676 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2677 | } |
wolfSSL | 15:117db924cf7c | 2678 | } |
wolfSSL | 15:117db924cf7c | 2679 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2680 | if (wc_AesInit(dec->aes, heap, devId) != 0) { |
wolfSSL | 15:117db924cf7c | 2681 | WOLFSSL_MSG("AesInit failed in SetKeys"); |
wolfSSL | 15:117db924cf7c | 2682 | return ASYNC_INIT_E; |
wolfSSL | 15:117db924cf7c | 2683 | } |
wolfSSL | 15:117db924cf7c | 2684 | } |
wolfSSL | 15:117db924cf7c | 2685 | |
wolfSSL | 15:117db924cf7c | 2686 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2687 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2688 | CcmRet = wc_AesCcmSetKey(enc->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2689 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2690 | if (CcmRet != 0) { |
wolfSSL | 15:117db924cf7c | 2691 | return CcmRet; |
wolfSSL | 15:117db924cf7c | 2692 | } |
wolfSSL | 15:117db924cf7c | 2693 | XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2694 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2695 | } |
wolfSSL | 15:117db924cf7c | 2696 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2697 | CcmRet = wc_AesCcmSetKey(dec->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2698 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2699 | if (CcmRet != 0) { |
wolfSSL | 15:117db924cf7c | 2700 | return CcmRet; |
wolfSSL | 15:117db924cf7c | 2701 | } |
wolfSSL | 15:117db924cf7c | 2702 | XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2703 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2704 | } |
wolfSSL | 15:117db924cf7c | 2705 | } |
wolfSSL | 15:117db924cf7c | 2706 | else { |
wolfSSL | 15:117db924cf7c | 2707 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2708 | CcmRet = wc_AesCcmSetKey(enc->aes, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2709 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2710 | if (CcmRet != 0) { |
wolfSSL | 15:117db924cf7c | 2711 | return CcmRet; |
wolfSSL | 15:117db924cf7c | 2712 | } |
wolfSSL | 15:117db924cf7c | 2713 | XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2714 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2715 | } |
wolfSSL | 15:117db924cf7c | 2716 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2717 | CcmRet = wc_AesCcmSetKey(dec->aes, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2718 | specs->key_size); |
wolfSSL | 15:117db924cf7c | 2719 | if (CcmRet != 0) { |
wolfSSL | 15:117db924cf7c | 2720 | return CcmRet; |
wolfSSL | 15:117db924cf7c | 2721 | } |
wolfSSL | 15:117db924cf7c | 2722 | XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2723 | AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 2724 | } |
wolfSSL | 15:117db924cf7c | 2725 | } |
wolfSSL | 15:117db924cf7c | 2726 | if (enc) |
wolfSSL | 15:117db924cf7c | 2727 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2728 | if (dec) |
wolfSSL | 15:117db924cf7c | 2729 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2730 | } |
wolfSSL | 15:117db924cf7c | 2731 | #endif /* HAVE_AESCCM */ |
wolfSSL | 15:117db924cf7c | 2732 | |
wolfSSL | 15:117db924cf7c | 2733 | #ifdef HAVE_CAMELLIA |
wolfSSL | 15:117db924cf7c | 2734 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2735 | #if (MAX_WRITE_IV_SZ < 16) /* CAMELLIA_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2736 | #error MAX_WRITE_IV_SZ too small for CAMELLIA |
wolfSSL | 15:117db924cf7c | 2737 | #endif |
wolfSSL | 15:117db924cf7c | 2738 | |
wolfSSL | 15:117db924cf7c | 2739 | if (specs->bulk_cipher_algorithm == wolfssl_camellia) { |
wolfSSL | 15:117db924cf7c | 2740 | int camRet; |
wolfSSL | 15:117db924cf7c | 2741 | |
wolfSSL | 15:117db924cf7c | 2742 | if (enc && enc->cam == NULL) |
wolfSSL | 15:117db924cf7c | 2743 | enc->cam = |
wolfSSL | 15:117db924cf7c | 2744 | (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2745 | if (enc && enc->cam == NULL) |
wolfSSL | 15:117db924cf7c | 2746 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2747 | |
wolfSSL | 15:117db924cf7c | 2748 | if (dec && dec->cam == NULL) |
wolfSSL | 15:117db924cf7c | 2749 | dec->cam = |
wolfSSL | 15:117db924cf7c | 2750 | (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2751 | if (dec && dec->cam == NULL) |
wolfSSL | 15:117db924cf7c | 2752 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2753 | |
wolfSSL | 15:117db924cf7c | 2754 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2755 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2756 | camRet = wc_CamelliaSetKey(enc->cam, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2757 | specs->key_size, keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2758 | if (camRet != 0) return camRet; |
wolfSSL | 15:117db924cf7c | 2759 | } |
wolfSSL | 15:117db924cf7c | 2760 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2761 | camRet = wc_CamelliaSetKey(dec->cam, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2762 | specs->key_size, keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2763 | if (camRet != 0) return camRet; |
wolfSSL | 15:117db924cf7c | 2764 | } |
wolfSSL | 15:117db924cf7c | 2765 | } |
wolfSSL | 15:117db924cf7c | 2766 | else { |
wolfSSL | 15:117db924cf7c | 2767 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2768 | camRet = wc_CamelliaSetKey(enc->cam, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2769 | specs->key_size, keys->server_write_IV); |
wolfSSL | 15:117db924cf7c | 2770 | if (camRet != 0) return camRet; |
wolfSSL | 15:117db924cf7c | 2771 | } |
wolfSSL | 15:117db924cf7c | 2772 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2773 | camRet = wc_CamelliaSetKey(dec->cam, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2774 | specs->key_size, keys->client_write_IV); |
wolfSSL | 15:117db924cf7c | 2775 | if (camRet != 0) return camRet; |
wolfSSL | 15:117db924cf7c | 2776 | } |
wolfSSL | 15:117db924cf7c | 2777 | } |
wolfSSL | 15:117db924cf7c | 2778 | if (enc) |
wolfSSL | 15:117db924cf7c | 2779 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2780 | if (dec) |
wolfSSL | 15:117db924cf7c | 2781 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2782 | } |
wolfSSL | 15:117db924cf7c | 2783 | #endif /* HAVE_CAMELLIA */ |
wolfSSL | 15:117db924cf7c | 2784 | |
wolfSSL | 15:117db924cf7c | 2785 | #ifdef HAVE_IDEA |
wolfSSL | 15:117db924cf7c | 2786 | /* check that buffer sizes are sufficient */ |
wolfSSL | 15:117db924cf7c | 2787 | #if (MAX_WRITE_IV_SZ < 8) /* IDEA_IV_SIZE */ |
wolfSSL | 15:117db924cf7c | 2788 | #error MAX_WRITE_IV_SZ too small for IDEA |
wolfSSL | 15:117db924cf7c | 2789 | #endif |
wolfSSL | 15:117db924cf7c | 2790 | |
wolfSSL | 15:117db924cf7c | 2791 | if (specs->bulk_cipher_algorithm == wolfssl_idea) { |
wolfSSL | 15:117db924cf7c | 2792 | int ideaRet; |
wolfSSL | 15:117db924cf7c | 2793 | |
wolfSSL | 15:117db924cf7c | 2794 | if (enc && enc->idea == NULL) |
wolfSSL | 15:117db924cf7c | 2795 | enc->idea = (Idea*)XMALLOC(sizeof(Idea), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2796 | if (enc && enc->idea == NULL) |
wolfSSL | 15:117db924cf7c | 2797 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2798 | |
wolfSSL | 15:117db924cf7c | 2799 | if (dec && dec->idea == NULL) |
wolfSSL | 15:117db924cf7c | 2800 | dec->idea = (Idea*)XMALLOC(sizeof(Idea), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2801 | if (dec && dec->idea == NULL) |
wolfSSL | 15:117db924cf7c | 2802 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2803 | |
wolfSSL | 15:117db924cf7c | 2804 | if (side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2805 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2806 | ideaRet = wc_IdeaSetKey(enc->idea, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2807 | specs->key_size, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2808 | IDEA_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2809 | if (ideaRet != 0) return ideaRet; |
wolfSSL | 15:117db924cf7c | 2810 | } |
wolfSSL | 15:117db924cf7c | 2811 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2812 | ideaRet = wc_IdeaSetKey(dec->idea, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2813 | specs->key_size, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2814 | IDEA_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2815 | if (ideaRet != 0) return ideaRet; |
wolfSSL | 15:117db924cf7c | 2816 | } |
wolfSSL | 15:117db924cf7c | 2817 | } |
wolfSSL | 15:117db924cf7c | 2818 | else { |
wolfSSL | 15:117db924cf7c | 2819 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2820 | ideaRet = wc_IdeaSetKey(enc->idea, keys->server_write_key, |
wolfSSL | 15:117db924cf7c | 2821 | specs->key_size, keys->server_write_IV, |
wolfSSL | 15:117db924cf7c | 2822 | IDEA_ENCRYPTION); |
wolfSSL | 15:117db924cf7c | 2823 | if (ideaRet != 0) return ideaRet; |
wolfSSL | 15:117db924cf7c | 2824 | } |
wolfSSL | 15:117db924cf7c | 2825 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2826 | ideaRet = wc_IdeaSetKey(dec->idea, keys->client_write_key, |
wolfSSL | 15:117db924cf7c | 2827 | specs->key_size, keys->client_write_IV, |
wolfSSL | 15:117db924cf7c | 2828 | IDEA_DECRYPTION); |
wolfSSL | 15:117db924cf7c | 2829 | if (ideaRet != 0) return ideaRet; |
wolfSSL | 15:117db924cf7c | 2830 | } |
wolfSSL | 15:117db924cf7c | 2831 | } |
wolfSSL | 15:117db924cf7c | 2832 | if (enc) |
wolfSSL | 15:117db924cf7c | 2833 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2834 | if (dec) |
wolfSSL | 15:117db924cf7c | 2835 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2836 | } |
wolfSSL | 15:117db924cf7c | 2837 | #endif /* HAVE_IDEA */ |
wolfSSL | 15:117db924cf7c | 2838 | |
wolfSSL | 15:117db924cf7c | 2839 | #ifdef HAVE_NULL_CIPHER |
wolfSSL | 15:117db924cf7c | 2840 | if (specs->bulk_cipher_algorithm == wolfssl_cipher_null) { |
wolfSSL | 15:117db924cf7c | 2841 | if (enc) |
wolfSSL | 15:117db924cf7c | 2842 | enc->setup = 1; |
wolfSSL | 15:117db924cf7c | 2843 | if (dec) |
wolfSSL | 15:117db924cf7c | 2844 | dec->setup = 1; |
wolfSSL | 15:117db924cf7c | 2845 | } |
wolfSSL | 15:117db924cf7c | 2846 | #endif |
wolfSSL | 15:117db924cf7c | 2847 | |
wolfSSL | 15:117db924cf7c | 2848 | if (enc) { |
wolfSSL | 15:117db924cf7c | 2849 | keys->sequence_number_hi = 0; |
wolfSSL | 15:117db924cf7c | 2850 | keys->sequence_number_lo = 0; |
wolfSSL | 15:117db924cf7c | 2851 | } |
wolfSSL | 15:117db924cf7c | 2852 | if (dec) { |
wolfSSL | 15:117db924cf7c | 2853 | keys->peer_sequence_number_hi = 0; |
wolfSSL | 15:117db924cf7c | 2854 | keys->peer_sequence_number_lo = 0; |
wolfSSL | 15:117db924cf7c | 2855 | } |
wolfSSL | 15:117db924cf7c | 2856 | (void)side; |
wolfSSL | 15:117db924cf7c | 2857 | (void)heap; |
wolfSSL | 15:117db924cf7c | 2858 | (void)enc; |
wolfSSL | 15:117db924cf7c | 2859 | (void)dec; |
wolfSSL | 15:117db924cf7c | 2860 | (void)specs; |
wolfSSL | 15:117db924cf7c | 2861 | (void)devId; |
wolfSSL | 15:117db924cf7c | 2862 | |
wolfSSL | 15:117db924cf7c | 2863 | return 0; |
wolfSSL | 15:117db924cf7c | 2864 | } |
wolfSSL | 15:117db924cf7c | 2865 | |
wolfSSL | 15:117db924cf7c | 2866 | |
wolfSSL | 15:117db924cf7c | 2867 | #ifdef HAVE_ONE_TIME_AUTH |
wolfSSL | 15:117db924cf7c | 2868 | /* set one time authentication keys */ |
wolfSSL | 15:117db924cf7c | 2869 | static int SetAuthKeys(OneTimeAuth* authentication, Keys* keys, |
wolfSSL | 15:117db924cf7c | 2870 | CipherSpecs* specs, void* heap, int devId) |
wolfSSL | 15:117db924cf7c | 2871 | { |
wolfSSL | 15:117db924cf7c | 2872 | |
wolfSSL | 15:117db924cf7c | 2873 | #ifdef HAVE_POLY1305 |
wolfSSL | 15:117db924cf7c | 2874 | /* set up memory space for poly1305 */ |
wolfSSL | 15:117db924cf7c | 2875 | if (authentication && authentication->poly1305 == NULL) |
wolfSSL | 15:117db924cf7c | 2876 | authentication->poly1305 = |
wolfSSL | 15:117db924cf7c | 2877 | (Poly1305*)XMALLOC(sizeof(Poly1305), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 15:117db924cf7c | 2878 | if (authentication && authentication->poly1305 == NULL) |
wolfSSL | 15:117db924cf7c | 2879 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 2880 | if (authentication) |
wolfSSL | 15:117db924cf7c | 2881 | authentication->setup = 1; |
wolfSSL | 15:117db924cf7c | 2882 | #endif |
wolfSSL | 15:117db924cf7c | 2883 | (void)authentication; |
wolfSSL | 15:117db924cf7c | 2884 | (void)heap; |
wolfSSL | 15:117db924cf7c | 2885 | (void)keys; |
wolfSSL | 15:117db924cf7c | 2886 | (void)specs; |
wolfSSL | 15:117db924cf7c | 2887 | (void)devId; |
wolfSSL | 15:117db924cf7c | 2888 | |
wolfSSL | 15:117db924cf7c | 2889 | return 0; |
wolfSSL | 15:117db924cf7c | 2890 | } |
wolfSSL | 15:117db924cf7c | 2891 | #endif /* HAVE_ONE_TIME_AUTH */ |
wolfSSL | 15:117db924cf7c | 2892 | |
wolfSSL | 15:117db924cf7c | 2893 | #ifdef HAVE_SECURE_RENEGOTIATION |
wolfSSL | 15:117db924cf7c | 2894 | /* function name is for cache_status++ |
wolfSSL | 15:117db924cf7c | 2895 | * This function was added because of error incrementing enum type when |
wolfSSL | 15:117db924cf7c | 2896 | * compiling with a C++ compiler. |
wolfSSL | 15:117db924cf7c | 2897 | */ |
wolfSSL | 15:117db924cf7c | 2898 | static void CacheStatusPP(SecureRenegotiation* cache) |
wolfSSL | 15:117db924cf7c | 2899 | { |
wolfSSL | 15:117db924cf7c | 2900 | switch (cache->cache_status) { |
wolfSSL | 15:117db924cf7c | 2901 | case SCR_CACHE_NULL: |
wolfSSL | 15:117db924cf7c | 2902 | cache->cache_status = SCR_CACHE_NEEDED; |
wolfSSL | 15:117db924cf7c | 2903 | break; |
wolfSSL | 15:117db924cf7c | 2904 | |
wolfSSL | 15:117db924cf7c | 2905 | case SCR_CACHE_NEEDED: |
wolfSSL | 15:117db924cf7c | 2906 | cache->cache_status = SCR_CACHE_COPY; |
wolfSSL | 15:117db924cf7c | 2907 | break; |
wolfSSL | 15:117db924cf7c | 2908 | |
wolfSSL | 15:117db924cf7c | 2909 | case SCR_CACHE_COPY: |
wolfSSL | 15:117db924cf7c | 2910 | cache->cache_status = SCR_CACHE_PARTIAL; |
wolfSSL | 15:117db924cf7c | 2911 | break; |
wolfSSL | 15:117db924cf7c | 2912 | |
wolfSSL | 15:117db924cf7c | 2913 | case SCR_CACHE_PARTIAL: |
wolfSSL | 15:117db924cf7c | 2914 | cache->cache_status = SCR_CACHE_COMPLETE; |
wolfSSL | 15:117db924cf7c | 2915 | break; |
wolfSSL | 15:117db924cf7c | 2916 | |
wolfSSL | 15:117db924cf7c | 2917 | case SCR_CACHE_COMPLETE: |
wolfSSL | 15:117db924cf7c | 2918 | WOLFSSL_MSG("SCR Cache state Complete"); |
wolfSSL | 15:117db924cf7c | 2919 | break; |
wolfSSL | 15:117db924cf7c | 2920 | |
wolfSSL | 15:117db924cf7c | 2921 | default: |
wolfSSL | 15:117db924cf7c | 2922 | WOLFSSL_MSG("Unknown cache state!!"); |
wolfSSL | 15:117db924cf7c | 2923 | } |
wolfSSL | 15:117db924cf7c | 2924 | } |
wolfSSL | 15:117db924cf7c | 2925 | #endif /* HAVE_SECURE_RENEGOTIATION */ |
wolfSSL | 15:117db924cf7c | 2926 | |
wolfSSL | 15:117db924cf7c | 2927 | |
wolfSSL | 15:117db924cf7c | 2928 | /* Set wc_encrypt/wc_decrypt or both sides of key setup |
wolfSSL | 15:117db924cf7c | 2929 | * note: use wc_encrypt to avoid shadowing global encrypt |
wolfSSL | 15:117db924cf7c | 2930 | * declared in unistd.h |
wolfSSL | 15:117db924cf7c | 2931 | */ |
wolfSSL | 15:117db924cf7c | 2932 | int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side) |
wolfSSL | 15:117db924cf7c | 2933 | { |
wolfSSL | 15:117db924cf7c | 2934 | int devId = INVALID_DEVID, ret, copy = 0; |
wolfSSL | 15:117db924cf7c | 2935 | Ciphers* wc_encrypt = NULL; |
wolfSSL | 15:117db924cf7c | 2936 | Ciphers* wc_decrypt = NULL; |
wolfSSL | 15:117db924cf7c | 2937 | Keys* keys = &ssl->keys; |
wolfSSL | 15:117db924cf7c | 2938 | |
wolfSSL | 15:117db924cf7c | 2939 | (void)copy; |
wolfSSL | 15:117db924cf7c | 2940 | |
wolfSSL | 15:117db924cf7c | 2941 | #ifdef WOLFSSL_ASYNC_CRYPT |
wolfSSL | 15:117db924cf7c | 2942 | devId = ssl->devId; |
wolfSSL | 15:117db924cf7c | 2943 | #endif |
wolfSSL | 15:117db924cf7c | 2944 | |
wolfSSL | 15:117db924cf7c | 2945 | #ifdef HAVE_SECURE_RENEGOTIATION |
wolfSSL | 15:117db924cf7c | 2946 | if (ssl->secure_renegotiation && ssl->secure_renegotiation->cache_status) { |
wolfSSL | 15:117db924cf7c | 2947 | keys = &ssl->secure_renegotiation->tmp_keys; |
wolfSSL | 15:117db924cf7c | 2948 | copy = 1; |
wolfSSL | 15:117db924cf7c | 2949 | } |
wolfSSL | 15:117db924cf7c | 2950 | #endif /* HAVE_SECURE_RENEGOTIATION */ |
wolfSSL | 15:117db924cf7c | 2951 | |
wolfSSL | 15:117db924cf7c | 2952 | switch (side) { |
wolfSSL | 15:117db924cf7c | 2953 | case ENCRYPT_SIDE_ONLY: |
wolfSSL | 15:117db924cf7c | 2954 | #ifdef WOLFSSL_DEBUG_TLS |
wolfSSL | 15:117db924cf7c | 2955 | WOLFSSL_MSG("Provisioning ENCRYPT key"); |
wolfSSL | 15:117db924cf7c | 2956 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2957 | WOLFSSL_BUFFER(ssl->keys.client_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2958 | } |
wolfSSL | 15:117db924cf7c | 2959 | else { |
wolfSSL | 15:117db924cf7c | 2960 | WOLFSSL_BUFFER(ssl->keys.server_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2961 | } |
wolfSSL | 15:117db924cf7c | 2962 | #endif |
wolfSSL | 15:117db924cf7c | 2963 | wc_encrypt = &ssl->encrypt; |
wolfSSL | 15:117db924cf7c | 2964 | break; |
wolfSSL | 15:117db924cf7c | 2965 | |
wolfSSL | 15:117db924cf7c | 2966 | case DECRYPT_SIDE_ONLY: |
wolfSSL | 15:117db924cf7c | 2967 | #ifdef WOLFSSL_DEBUG_TLS |
wolfSSL | 15:117db924cf7c | 2968 | WOLFSSL_MSG("Provisioning DECRYPT key"); |
wolfSSL | 15:117db924cf7c | 2969 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2970 | WOLFSSL_BUFFER(ssl->keys.server_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2971 | } |
wolfSSL | 15:117db924cf7c | 2972 | else { |
wolfSSL | 15:117db924cf7c | 2973 | WOLFSSL_BUFFER(ssl->keys.client_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2974 | } |
wolfSSL | 15:117db924cf7c | 2975 | #endif |
wolfSSL | 15:117db924cf7c | 2976 | wc_decrypt = &ssl->decrypt; |
wolfSSL | 15:117db924cf7c | 2977 | break; |
wolfSSL | 15:117db924cf7c | 2978 | |
wolfSSL | 15:117db924cf7c | 2979 | case ENCRYPT_AND_DECRYPT_SIDE: |
wolfSSL | 15:117db924cf7c | 2980 | #ifdef WOLFSSL_DEBUG_TLS |
wolfSSL | 15:117db924cf7c | 2981 | WOLFSSL_MSG("Provisioning ENCRYPT key"); |
wolfSSL | 15:117db924cf7c | 2982 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2983 | WOLFSSL_BUFFER(ssl->keys.client_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2984 | } |
wolfSSL | 15:117db924cf7c | 2985 | else { |
wolfSSL | 15:117db924cf7c | 2986 | WOLFSSL_BUFFER(ssl->keys.server_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2987 | } |
wolfSSL | 15:117db924cf7c | 2988 | WOLFSSL_MSG("Provisioning DECRYPT key"); |
wolfSSL | 15:117db924cf7c | 2989 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 2990 | WOLFSSL_BUFFER(ssl->keys.server_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2991 | } |
wolfSSL | 15:117db924cf7c | 2992 | else { |
wolfSSL | 15:117db924cf7c | 2993 | WOLFSSL_BUFFER(ssl->keys.client_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 2994 | } |
wolfSSL | 15:117db924cf7c | 2995 | #endif |
wolfSSL | 15:117db924cf7c | 2996 | wc_encrypt = &ssl->encrypt; |
wolfSSL | 15:117db924cf7c | 2997 | wc_decrypt = &ssl->decrypt; |
wolfSSL | 15:117db924cf7c | 2998 | break; |
wolfSSL | 15:117db924cf7c | 2999 | |
wolfSSL | 15:117db924cf7c | 3000 | default: |
wolfSSL | 15:117db924cf7c | 3001 | return BAD_FUNC_ARG; |
wolfSSL | 15:117db924cf7c | 3002 | } |
wolfSSL | 15:117db924cf7c | 3003 | |
wolfSSL | 15:117db924cf7c | 3004 | #ifdef HAVE_ONE_TIME_AUTH |
wolfSSL | 15:117db924cf7c | 3005 | if (!ssl->auth.setup && ssl->specs.bulk_cipher_algorithm == wolfssl_chacha){ |
wolfSSL | 15:117db924cf7c | 3006 | ret = SetAuthKeys(&ssl->auth, keys, &ssl->specs, ssl->heap, devId); |
wolfSSL | 15:117db924cf7c | 3007 | if (ret != 0) |
wolfSSL | 15:117db924cf7c | 3008 | return ret; |
wolfSSL | 15:117db924cf7c | 3009 | } |
wolfSSL | 15:117db924cf7c | 3010 | #endif |
wolfSSL | 15:117db924cf7c | 3011 | |
wolfSSL | 15:117db924cf7c | 3012 | ret = SetKeys(wc_encrypt, wc_decrypt, keys, &ssl->specs, ssl->options.side, |
wolfSSL | 15:117db924cf7c | 3013 | ssl->heap, devId); |
wolfSSL | 15:117db924cf7c | 3014 | |
wolfSSL | 15:117db924cf7c | 3015 | #ifdef HAVE_SECURE_RENEGOTIATION |
wolfSSL | 15:117db924cf7c | 3016 | if (copy) { |
wolfSSL | 15:117db924cf7c | 3017 | int clientCopy = 0; |
wolfSSL | 15:117db924cf7c | 3018 | |
wolfSSL | 15:117db924cf7c | 3019 | if (ssl->options.side == WOLFSSL_CLIENT_END && wc_encrypt) |
wolfSSL | 15:117db924cf7c | 3020 | clientCopy = 1; |
wolfSSL | 15:117db924cf7c | 3021 | else if (ssl->options.side == WOLFSSL_SERVER_END && wc_decrypt) |
wolfSSL | 15:117db924cf7c | 3022 | clientCopy = 1; |
wolfSSL | 15:117db924cf7c | 3023 | |
wolfSSL | 15:117db924cf7c | 3024 | if (clientCopy) { |
wolfSSL | 15:117db924cf7c | 3025 | XMEMCPY(ssl->keys.client_write_MAC_secret, |
wolfSSL | 15:117db924cf7c | 3026 | keys->client_write_MAC_secret, WC_MAX_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3027 | XMEMCPY(ssl->keys.client_write_key, |
wolfSSL | 15:117db924cf7c | 3028 | keys->client_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 3029 | XMEMCPY(ssl->keys.client_write_IV, |
wolfSSL | 15:117db924cf7c | 3030 | keys->client_write_IV, MAX_WRITE_IV_SZ); |
wolfSSL | 15:117db924cf7c | 3031 | } else { |
wolfSSL | 15:117db924cf7c | 3032 | XMEMCPY(ssl->keys.server_write_MAC_secret, |
wolfSSL | 15:117db924cf7c | 3033 | keys->server_write_MAC_secret, WC_MAX_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3034 | XMEMCPY(ssl->keys.server_write_key, |
wolfSSL | 15:117db924cf7c | 3035 | keys->server_write_key, AES_256_KEY_SIZE); |
wolfSSL | 15:117db924cf7c | 3036 | XMEMCPY(ssl->keys.server_write_IV, |
wolfSSL | 15:117db924cf7c | 3037 | keys->server_write_IV, MAX_WRITE_IV_SZ); |
wolfSSL | 15:117db924cf7c | 3038 | } |
wolfSSL | 15:117db924cf7c | 3039 | if (wc_encrypt) { |
wolfSSL | 15:117db924cf7c | 3040 | ssl->keys.sequence_number_hi = keys->sequence_number_hi; |
wolfSSL | 15:117db924cf7c | 3041 | ssl->keys.sequence_number_lo = keys->sequence_number_lo; |
wolfSSL | 15:117db924cf7c | 3042 | #ifdef HAVE_AEAD |
wolfSSL | 15:117db924cf7c | 3043 | if (ssl->specs.cipher_type == aead) { |
wolfSSL | 15:117db924cf7c | 3044 | /* Initialize the AES-GCM/CCM explicit IV to a zero. */ |
wolfSSL | 15:117db924cf7c | 3045 | XMEMCPY(ssl->keys.aead_exp_IV, keys->aead_exp_IV, |
wolfSSL | 15:117db924cf7c | 3046 | AEAD_MAX_EXP_SZ); |
wolfSSL | 15:117db924cf7c | 3047 | |
wolfSSL | 15:117db924cf7c | 3048 | /* Initialize encrypt implicit IV by encrypt side */ |
wolfSSL | 15:117db924cf7c | 3049 | if (ssl->options.side == WOLFSSL_CLIENT_END) { |
wolfSSL | 15:117db924cf7c | 3050 | XMEMCPY(ssl->keys.aead_enc_imp_IV, |
wolfSSL | 15:117db924cf7c | 3051 | keys->client_write_IV, AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 3052 | } else { |
wolfSSL | 15:117db924cf7c | 3053 | XMEMCPY(ssl->keys.aead_enc_imp_IV, |
wolfSSL | 15:117db924cf7c | 3054 | keys->server_write_IV, AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 3055 | } |
wolfSSL | 15:117db924cf7c | 3056 | } |
wolfSSL | 15:117db924cf7c | 3057 | #endif |
wolfSSL | 15:117db924cf7c | 3058 | } |
wolfSSL | 15:117db924cf7c | 3059 | if (wc_decrypt) { |
wolfSSL | 15:117db924cf7c | 3060 | ssl->keys.peer_sequence_number_hi = keys->peer_sequence_number_hi; |
wolfSSL | 15:117db924cf7c | 3061 | ssl->keys.peer_sequence_number_lo = keys->peer_sequence_number_lo; |
wolfSSL | 15:117db924cf7c | 3062 | #ifdef HAVE_AEAD |
wolfSSL | 15:117db924cf7c | 3063 | if (ssl->specs.cipher_type == aead) { |
wolfSSL | 15:117db924cf7c | 3064 | /* Initialize decrypt implicit IV by decrypt side */ |
wolfSSL | 15:117db924cf7c | 3065 | if (ssl->options.side == WOLFSSL_SERVER_END) { |
wolfSSL | 15:117db924cf7c | 3066 | XMEMCPY(ssl->keys.aead_dec_imp_IV, |
wolfSSL | 15:117db924cf7c | 3067 | keys->client_write_IV, AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 3068 | } else { |
wolfSSL | 15:117db924cf7c | 3069 | XMEMCPY(ssl->keys.aead_dec_imp_IV, |
wolfSSL | 15:117db924cf7c | 3070 | keys->server_write_IV, AEAD_MAX_IMP_SZ); |
wolfSSL | 15:117db924cf7c | 3071 | } |
wolfSSL | 15:117db924cf7c | 3072 | } |
wolfSSL | 15:117db924cf7c | 3073 | #endif |
wolfSSL | 15:117db924cf7c | 3074 | } |
wolfSSL | 15:117db924cf7c | 3075 | CacheStatusPP(ssl->secure_renegotiation); |
wolfSSL | 15:117db924cf7c | 3076 | } |
wolfSSL | 15:117db924cf7c | 3077 | #endif /* HAVE_SECURE_RENEGOTIATION */ |
wolfSSL | 15:117db924cf7c | 3078 | |
wolfSSL | 15:117db924cf7c | 3079 | return ret; |
wolfSSL | 15:117db924cf7c | 3080 | } |
wolfSSL | 15:117db924cf7c | 3081 | |
wolfSSL | 15:117db924cf7c | 3082 | |
wolfSSL | 15:117db924cf7c | 3083 | /* TLS can call too */ |
wolfSSL | 15:117db924cf7c | 3084 | int StoreKeys(WOLFSSL* ssl, const byte* keyData, int side) |
wolfSSL | 15:117db924cf7c | 3085 | { |
wolfSSL | 15:117db924cf7c | 3086 | int sz, i = 0; |
wolfSSL | 15:117db924cf7c | 3087 | Keys* keys = &ssl->keys; |
wolfSSL | 15:117db924cf7c | 3088 | |
wolfSSL | 15:117db924cf7c | 3089 | #ifdef HAVE_SECURE_RENEGOTIATION |
wolfSSL | 15:117db924cf7c | 3090 | if (ssl->secure_renegotiation && ssl->secure_renegotiation->cache_status == |
wolfSSL | 15:117db924cf7c | 3091 | SCR_CACHE_NEEDED) { |
wolfSSL | 15:117db924cf7c | 3092 | keys = &ssl->secure_renegotiation->tmp_keys; |
wolfSSL | 15:117db924cf7c | 3093 | CacheStatusPP(ssl->secure_renegotiation); |
wolfSSL | 15:117db924cf7c | 3094 | } |
wolfSSL | 15:117db924cf7c | 3095 | #endif /* HAVE_SECURE_RENEGOTIATION */ |
wolfSSL | 15:117db924cf7c | 3096 | |
wolfSSL | 15:117db924cf7c | 3097 | #ifdef WOLFSSL_MULTICAST |
wolfSSL | 15:117db924cf7c | 3098 | if (ssl->options.haveMcast) { |
wolfSSL | 15:117db924cf7c | 3099 | /* Use the same keys for encrypt and decrypt. */ |
wolfSSL | 15:117db924cf7c | 3100 | if (ssl->specs.cipher_type != aead) { |
wolfSSL | 15:117db924cf7c | 3101 | sz = ssl->specs.hash_size; |
wolfSSL | 15:117db924cf7c | 3102 | XMEMCPY(keys->client_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3103 | XMEMCPY(keys->server_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3104 | i += sz; |
wolfSSL | 15:117db924cf7c | 3105 | } |
wolfSSL | 15:117db924cf7c | 3106 | sz = ssl->specs.key_size; |
wolfSSL | 15:117db924cf7c | 3107 | XMEMCPY(keys->client_write_key, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3108 | XMEMCPY(keys->server_write_key, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3109 | i += sz; |
wolfSSL | 15:117db924cf7c | 3110 | |
wolfSSL | 15:117db924cf7c | 3111 | sz = ssl->specs.iv_size; |
wolfSSL | 15:117db924cf7c | 3112 | XMEMCPY(keys->client_write_IV, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3113 | XMEMCPY(keys->server_write_IV, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3114 | |
wolfSSL | 15:117db924cf7c | 3115 | #ifdef HAVE_AEAD |
wolfSSL | 15:117db924cf7c | 3116 | if (ssl->specs.cipher_type == aead) { |
wolfSSL | 15:117db924cf7c | 3117 | /* Initialize the AES-GCM/CCM explicit IV to a zero. */ |
wolfSSL | 15:117db924cf7c | 3118 | XMEMSET(keys->aead_exp_IV, 0, AEAD_MAX_EXP_SZ); |
wolfSSL | 15:117db924cf7c | 3119 | } |
wolfSSL | 15:117db924cf7c | 3120 | #endif /* HAVE_AEAD */ |
wolfSSL | 15:117db924cf7c | 3121 | |
wolfSSL | 15:117db924cf7c | 3122 | return 0; |
wolfSSL | 15:117db924cf7c | 3123 | } |
wolfSSL | 15:117db924cf7c | 3124 | #endif /* WOLFSSL_MULTICAST */ |
wolfSSL | 15:117db924cf7c | 3125 | |
wolfSSL | 15:117db924cf7c | 3126 | if (ssl->specs.cipher_type != aead) { |
wolfSSL | 15:117db924cf7c | 3127 | sz = ssl->specs.hash_size; |
wolfSSL | 15:117db924cf7c | 3128 | if (side & PROVISION_CLIENT) { |
wolfSSL | 15:117db924cf7c | 3129 | XMEMCPY(keys->client_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3130 | i += sz; |
wolfSSL | 15:117db924cf7c | 3131 | } |
wolfSSL | 15:117db924cf7c | 3132 | if (side & PROVISION_SERVER) { |
wolfSSL | 15:117db924cf7c | 3133 | XMEMCPY(keys->server_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3134 | i += sz; |
wolfSSL | 15:117db924cf7c | 3135 | } |
wolfSSL | 15:117db924cf7c | 3136 | } |
wolfSSL | 15:117db924cf7c | 3137 | sz = ssl->specs.key_size; |
wolfSSL | 15:117db924cf7c | 3138 | if (side & PROVISION_CLIENT) { |
wolfSSL | 15:117db924cf7c | 3139 | XMEMCPY(keys->client_write_key, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3140 | i += sz; |
wolfSSL | 15:117db924cf7c | 3141 | } |
wolfSSL | 15:117db924cf7c | 3142 | if (side & PROVISION_SERVER) { |
wolfSSL | 15:117db924cf7c | 3143 | XMEMCPY(keys->server_write_key, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3144 | i += sz; |
wolfSSL | 15:117db924cf7c | 3145 | } |
wolfSSL | 15:117db924cf7c | 3146 | |
wolfSSL | 15:117db924cf7c | 3147 | sz = ssl->specs.iv_size; |
wolfSSL | 15:117db924cf7c | 3148 | if (side & PROVISION_CLIENT) { |
wolfSSL | 15:117db924cf7c | 3149 | XMEMCPY(keys->client_write_IV, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3150 | i += sz; |
wolfSSL | 15:117db924cf7c | 3151 | } |
wolfSSL | 15:117db924cf7c | 3152 | if (side & PROVISION_SERVER) |
wolfSSL | 15:117db924cf7c | 3153 | XMEMCPY(keys->server_write_IV, &keyData[i], sz); |
wolfSSL | 15:117db924cf7c | 3154 | |
wolfSSL | 15:117db924cf7c | 3155 | #ifdef HAVE_AEAD |
wolfSSL | 15:117db924cf7c | 3156 | if (ssl->specs.cipher_type == aead) { |
wolfSSL | 15:117db924cf7c | 3157 | /* Initialize the AES-GCM/CCM explicit IV to a zero. */ |
wolfSSL | 15:117db924cf7c | 3158 | XMEMSET(keys->aead_exp_IV, 0, AEAD_MAX_EXP_SZ); |
wolfSSL | 15:117db924cf7c | 3159 | } |
wolfSSL | 15:117db924cf7c | 3160 | #endif |
wolfSSL | 15:117db924cf7c | 3161 | |
wolfSSL | 15:117db924cf7c | 3162 | return 0; |
wolfSSL | 15:117db924cf7c | 3163 | } |
wolfSSL | 15:117db924cf7c | 3164 | |
wolfSSL | 15:117db924cf7c | 3165 | #ifndef NO_OLD_TLS |
wolfSSL | 15:117db924cf7c | 3166 | int DeriveKeys(WOLFSSL* ssl) |
wolfSSL | 15:117db924cf7c | 3167 | { |
wolfSSL | 15:117db924cf7c | 3168 | int length = 2 * ssl->specs.hash_size + |
wolfSSL | 15:117db924cf7c | 3169 | 2 * ssl->specs.key_size + |
wolfSSL | 15:117db924cf7c | 3170 | 2 * ssl->specs.iv_size; |
wolfSSL | 15:117db924cf7c | 3171 | int rounds = (length + WC_MD5_DIGEST_SIZE - 1 ) / WC_MD5_DIGEST_SIZE, i; |
wolfSSL | 15:117db924cf7c | 3172 | int ret = 0; |
wolfSSL | 15:117db924cf7c | 3173 | |
wolfSSL | 15:117db924cf7c | 3174 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3175 | byte* shaOutput; |
wolfSSL | 15:117db924cf7c | 3176 | byte* md5Input; |
wolfSSL | 15:117db924cf7c | 3177 | byte* shaInput; |
wolfSSL | 15:117db924cf7c | 3178 | byte* keyData; |
wolfSSL | 15:117db924cf7c | 3179 | wc_Md5* md5; |
wolfSSL | 15:117db924cf7c | 3180 | wc_Sha* sha; |
wolfSSL | 15:117db924cf7c | 3181 | #else |
wolfSSL | 15:117db924cf7c | 3182 | byte shaOutput[WC_SHA_DIGEST_SIZE]; |
wolfSSL | 15:117db924cf7c | 3183 | byte md5Input[SECRET_LEN + WC_SHA_DIGEST_SIZE]; |
wolfSSL | 15:117db924cf7c | 3184 | byte shaInput[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN]; |
wolfSSL | 15:117db924cf7c | 3185 | byte keyData[KEY_PREFIX * WC_MD5_DIGEST_SIZE]; |
wolfSSL | 15:117db924cf7c | 3186 | wc_Md5 md5[1]; |
wolfSSL | 15:117db924cf7c | 3187 | wc_Sha sha[1]; |
wolfSSL | 15:117db924cf7c | 3188 | #endif |
wolfSSL | 15:117db924cf7c | 3189 | |
wolfSSL | 15:117db924cf7c | 3190 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3191 | shaOutput = (byte*)XMALLOC(WC_SHA_DIGEST_SIZE, |
wolfSSL | 15:117db924cf7c | 3192 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3193 | md5Input = (byte*)XMALLOC(SECRET_LEN + WC_SHA_DIGEST_SIZE, |
wolfSSL | 15:117db924cf7c | 3194 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3195 | shaInput = (byte*)XMALLOC(KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN, |
wolfSSL | 15:117db924cf7c | 3196 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3197 | keyData = (byte*)XMALLOC(KEY_PREFIX * WC_MD5_DIGEST_SIZE, |
wolfSSL | 15:117db924cf7c | 3198 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3199 | md5 = (wc_Md5*)XMALLOC(sizeof(wc_Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3200 | sha = (wc_Sha*)XMALLOC(sizeof(wc_Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3201 | |
wolfSSL | 15:117db924cf7c | 3202 | if (shaOutput == NULL || md5Input == NULL || shaInput == NULL || |
wolfSSL | 15:117db924cf7c | 3203 | keyData == NULL || md5 == NULL || sha == NULL) { |
wolfSSL | 15:117db924cf7c | 3204 | if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3205 | if (md5Input) XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3206 | if (shaInput) XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3207 | if (keyData) XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3208 | if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3209 | if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3210 | |
wolfSSL | 15:117db924cf7c | 3211 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 3212 | } |
wolfSSL | 15:117db924cf7c | 3213 | #endif |
wolfSSL | 15:117db924cf7c | 3214 | |
wolfSSL | 15:117db924cf7c | 3215 | ret = wc_InitMd5(md5); |
wolfSSL | 15:117db924cf7c | 3216 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3217 | ret = wc_InitSha(sha); |
wolfSSL | 15:117db924cf7c | 3218 | } |
wolfSSL | 15:117db924cf7c | 3219 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3220 | XMEMCPY(md5Input, ssl->arrays->masterSecret, SECRET_LEN); |
wolfSSL | 15:117db924cf7c | 3221 | |
wolfSSL | 15:117db924cf7c | 3222 | for (i = 0; i < rounds; ++i) { |
wolfSSL | 15:117db924cf7c | 3223 | int j = i + 1; |
wolfSSL | 15:117db924cf7c | 3224 | int idx = j; |
wolfSSL | 15:117db924cf7c | 3225 | |
wolfSSL | 15:117db924cf7c | 3226 | if (!SetPrefix(shaInput, i)) { |
wolfSSL | 15:117db924cf7c | 3227 | ret = PREFIX_ERROR; |
wolfSSL | 15:117db924cf7c | 3228 | break; |
wolfSSL | 15:117db924cf7c | 3229 | } |
wolfSSL | 15:117db924cf7c | 3230 | |
wolfSSL | 15:117db924cf7c | 3231 | XMEMCPY(shaInput + idx, ssl->arrays->masterSecret, SECRET_LEN); |
wolfSSL | 15:117db924cf7c | 3232 | idx += SECRET_LEN; |
wolfSSL | 15:117db924cf7c | 3233 | XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN); |
wolfSSL | 15:117db924cf7c | 3234 | idx += RAN_LEN; |
wolfSSL | 15:117db924cf7c | 3235 | XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN); |
wolfSSL | 15:117db924cf7c | 3236 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3237 | ret = wc_ShaUpdate(sha, shaInput, |
wolfSSL | 15:117db924cf7c | 3238 | (KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN) - KEY_PREFIX + j); |
wolfSSL | 15:117db924cf7c | 3239 | } |
wolfSSL | 15:117db924cf7c | 3240 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3241 | ret = wc_ShaFinal(sha, shaOutput); |
wolfSSL | 15:117db924cf7c | 3242 | } |
wolfSSL | 15:117db924cf7c | 3243 | |
wolfSSL | 15:117db924cf7c | 3244 | XMEMCPY(md5Input + SECRET_LEN, shaOutput, WC_SHA_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3245 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3246 | ret = wc_Md5Update(md5, md5Input, SECRET_LEN + WC_SHA_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3247 | } |
wolfSSL | 15:117db924cf7c | 3248 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3249 | ret = wc_Md5Final(md5, keyData + i * WC_MD5_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3250 | } |
wolfSSL | 15:117db924cf7c | 3251 | } |
wolfSSL | 15:117db924cf7c | 3252 | |
wolfSSL | 15:117db924cf7c | 3253 | if (ret == 0) |
wolfSSL | 15:117db924cf7c | 3254 | ret = StoreKeys(ssl, keyData, PROVISION_CLIENT_SERVER); |
wolfSSL | 15:117db924cf7c | 3255 | } |
wolfSSL | 15:117db924cf7c | 3256 | |
wolfSSL | 15:117db924cf7c | 3257 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3258 | XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3259 | XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3260 | XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3261 | XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3262 | XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3263 | XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3264 | #endif |
wolfSSL | 15:117db924cf7c | 3265 | |
wolfSSL | 15:117db924cf7c | 3266 | return ret; |
wolfSSL | 15:117db924cf7c | 3267 | } |
wolfSSL | 15:117db924cf7c | 3268 | |
wolfSSL | 15:117db924cf7c | 3269 | |
wolfSSL | 15:117db924cf7c | 3270 | static int CleanPreMaster(WOLFSSL* ssl) |
wolfSSL | 15:117db924cf7c | 3271 | { |
wolfSSL | 15:117db924cf7c | 3272 | int i, ret, sz = ssl->arrays->preMasterSz; |
wolfSSL | 15:117db924cf7c | 3273 | |
wolfSSL | 15:117db924cf7c | 3274 | for (i = 0; i < sz; i++) |
wolfSSL | 15:117db924cf7c | 3275 | ssl->arrays->preMasterSecret[i] = 0; |
wolfSSL | 15:117db924cf7c | 3276 | |
wolfSSL | 15:117db924cf7c | 3277 | ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret, sz); |
wolfSSL | 15:117db924cf7c | 3278 | if (ret != 0) |
wolfSSL | 15:117db924cf7c | 3279 | return ret; |
wolfSSL | 15:117db924cf7c | 3280 | |
wolfSSL | 15:117db924cf7c | 3281 | for (i = 0; i < sz; i++) |
wolfSSL | 15:117db924cf7c | 3282 | ssl->arrays->preMasterSecret[i] = 0; |
wolfSSL | 15:117db924cf7c | 3283 | |
wolfSSL | 15:117db924cf7c | 3284 | return 0; |
wolfSSL | 15:117db924cf7c | 3285 | } |
wolfSSL | 15:117db924cf7c | 3286 | |
wolfSSL | 15:117db924cf7c | 3287 | |
wolfSSL | 15:117db924cf7c | 3288 | /* Create and store the master secret see page 32, 6.1 */ |
wolfSSL | 15:117db924cf7c | 3289 | static int MakeSslMasterSecret(WOLFSSL* ssl) |
wolfSSL | 15:117db924cf7c | 3290 | { |
wolfSSL | 15:117db924cf7c | 3291 | int i, ret; |
wolfSSL | 15:117db924cf7c | 3292 | word32 idx; |
wolfSSL | 15:117db924cf7c | 3293 | word32 pmsSz = ssl->arrays->preMasterSz; |
wolfSSL | 15:117db924cf7c | 3294 | |
wolfSSL | 15:117db924cf7c | 3295 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3296 | byte* shaOutput; |
wolfSSL | 15:117db924cf7c | 3297 | byte* md5Input; |
wolfSSL | 15:117db924cf7c | 3298 | byte* shaInput; |
wolfSSL | 15:117db924cf7c | 3299 | wc_Md5* md5; |
wolfSSL | 15:117db924cf7c | 3300 | wc_Sha* sha; |
wolfSSL | 15:117db924cf7c | 3301 | #else |
wolfSSL | 15:117db924cf7c | 3302 | byte shaOutput[WC_SHA_DIGEST_SIZE]; |
wolfSSL | 15:117db924cf7c | 3303 | byte md5Input[ENCRYPT_LEN + WC_SHA_DIGEST_SIZE]; |
wolfSSL | 15:117db924cf7c | 3304 | byte shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN]; |
wolfSSL | 15:117db924cf7c | 3305 | wc_Md5 md5[1]; |
wolfSSL | 15:117db924cf7c | 3306 | wc_Sha sha[1]; |
wolfSSL | 15:117db924cf7c | 3307 | #endif |
wolfSSL | 15:117db924cf7c | 3308 | |
wolfSSL | 15:117db924cf7c | 3309 | #ifdef SHOW_SECRETS |
wolfSSL | 15:117db924cf7c | 3310 | { |
wolfSSL | 15:117db924cf7c | 3311 | word32 j; |
wolfSSL | 15:117db924cf7c | 3312 | printf("pre master secret: "); |
wolfSSL | 15:117db924cf7c | 3313 | for (j = 0; j < pmsSz; j++) |
wolfSSL | 15:117db924cf7c | 3314 | printf("%02x", ssl->arrays->preMasterSecret[j]); |
wolfSSL | 15:117db924cf7c | 3315 | printf("\n"); |
wolfSSL | 15:117db924cf7c | 3316 | } |
wolfSSL | 15:117db924cf7c | 3317 | #endif |
wolfSSL | 15:117db924cf7c | 3318 | |
wolfSSL | 15:117db924cf7c | 3319 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3320 | shaOutput = (byte*)XMALLOC(WC_SHA_DIGEST_SIZE, |
wolfSSL | 15:117db924cf7c | 3321 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3322 | md5Input = (byte*)XMALLOC(ENCRYPT_LEN + WC_SHA_DIGEST_SIZE, |
wolfSSL | 15:117db924cf7c | 3323 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3324 | shaInput = (byte*)XMALLOC(PREFIX + ENCRYPT_LEN + 2 * RAN_LEN, |
wolfSSL | 15:117db924cf7c | 3325 | NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3326 | md5 = (wc_Md5*)XMALLOC(sizeof(wc_Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3327 | sha = (wc_Sha*)XMALLOC(sizeof(wc_Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3328 | |
wolfSSL | 15:117db924cf7c | 3329 | if (shaOutput == NULL || md5Input == NULL || shaInput == NULL || |
wolfSSL | 15:117db924cf7c | 3330 | md5 == NULL || sha == NULL) { |
wolfSSL | 15:117db924cf7c | 3331 | if (shaOutput) XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3332 | if (md5Input) XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3333 | if (shaInput) XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3334 | if (md5) XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3335 | if (sha) XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3336 | |
wolfSSL | 15:117db924cf7c | 3337 | return MEMORY_E; |
wolfSSL | 15:117db924cf7c | 3338 | } |
wolfSSL | 15:117db924cf7c | 3339 | #endif |
wolfSSL | 15:117db924cf7c | 3340 | |
wolfSSL | 15:117db924cf7c | 3341 | ret = wc_InitMd5(md5); |
wolfSSL | 15:117db924cf7c | 3342 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3343 | ret = wc_InitSha(sha); |
wolfSSL | 15:117db924cf7c | 3344 | } |
wolfSSL | 15:117db924cf7c | 3345 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3346 | XMEMCPY(md5Input, ssl->arrays->preMasterSecret, pmsSz); |
wolfSSL | 15:117db924cf7c | 3347 | |
wolfSSL | 15:117db924cf7c | 3348 | for (i = 0; i < MASTER_ROUNDS; ++i) { |
wolfSSL | 15:117db924cf7c | 3349 | byte prefix[KEY_PREFIX]; /* only need PREFIX bytes but static */ |
wolfSSL | 15:117db924cf7c | 3350 | if (!SetPrefix(prefix, i)) { /* analysis thinks will overrun */ |
wolfSSL | 15:117db924cf7c | 3351 | ret = PREFIX_ERROR; |
wolfSSL | 15:117db924cf7c | 3352 | break; |
wolfSSL | 15:117db924cf7c | 3353 | } |
wolfSSL | 15:117db924cf7c | 3354 | |
wolfSSL | 15:117db924cf7c | 3355 | idx = 0; |
wolfSSL | 15:117db924cf7c | 3356 | XMEMCPY(shaInput, prefix, i + 1); |
wolfSSL | 15:117db924cf7c | 3357 | idx += i + 1; |
wolfSSL | 15:117db924cf7c | 3358 | |
wolfSSL | 15:117db924cf7c | 3359 | XMEMCPY(shaInput + idx, ssl->arrays->preMasterSecret, pmsSz); |
wolfSSL | 15:117db924cf7c | 3360 | idx += pmsSz; |
wolfSSL | 15:117db924cf7c | 3361 | XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN); |
wolfSSL | 15:117db924cf7c | 3362 | idx += RAN_LEN; |
wolfSSL | 15:117db924cf7c | 3363 | XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN); |
wolfSSL | 15:117db924cf7c | 3364 | idx += RAN_LEN; |
wolfSSL | 15:117db924cf7c | 3365 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3366 | ret = wc_ShaUpdate(sha, shaInput, idx); |
wolfSSL | 15:117db924cf7c | 3367 | } |
wolfSSL | 15:117db924cf7c | 3368 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3369 | ret = wc_ShaFinal(sha, shaOutput); |
wolfSSL | 15:117db924cf7c | 3370 | } |
wolfSSL | 15:117db924cf7c | 3371 | idx = pmsSz; /* preSz */ |
wolfSSL | 15:117db924cf7c | 3372 | XMEMCPY(md5Input + idx, shaOutput, WC_SHA_DIGEST_SIZE); |
wolfSSL | 15:117db924cf7c | 3373 | idx += WC_SHA_DIGEST_SIZE; |
wolfSSL | 15:117db924cf7c | 3374 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3375 | ret = wc_Md5Update(md5, md5Input, idx); |
wolfSSL | 15:117db924cf7c | 3376 | } |
wolfSSL | 15:117db924cf7c | 3377 | if (ret == 0) { |
wolfSSL | 15:117db924cf7c | 3378 | ret = wc_Md5Final(md5, |
wolfSSL | 15:117db924cf7c | 3379 | &ssl->arrays->masterSecret[i * WC_MD5_DIGEST_SIZE]); |
wolfSSL | 15:117db924cf7c | 3380 | } |
wolfSSL | 15:117db924cf7c | 3381 | } |
wolfSSL | 15:117db924cf7c | 3382 | |
wolfSSL | 15:117db924cf7c | 3383 | #ifdef SHOW_SECRETS |
wolfSSL | 15:117db924cf7c | 3384 | { |
wolfSSL | 15:117db924cf7c | 3385 | word32 j; |
wolfSSL | 15:117db924cf7c | 3386 | printf("master secret: "); |
wolfSSL | 15:117db924cf7c | 3387 | for (j = 0; j < SECRET_LEN; j++) |
wolfSSL | 15:117db924cf7c | 3388 | printf("%02x", ssl->arrays->masterSecret[j]); |
wolfSSL | 15:117db924cf7c | 3389 | printf("\n"); |
wolfSSL | 15:117db924cf7c | 3390 | } |
wolfSSL | 15:117db924cf7c | 3391 | #endif |
wolfSSL | 15:117db924cf7c | 3392 | |
wolfSSL | 15:117db924cf7c | 3393 | if (ret == 0) |
wolfSSL | 15:117db924cf7c | 3394 | ret = DeriveKeys(ssl); |
wolfSSL | 15:117db924cf7c | 3395 | } |
wolfSSL | 15:117db924cf7c | 3396 | |
wolfSSL | 15:117db924cf7c | 3397 | #ifdef WOLFSSL_SMALL_STACK |
wolfSSL | 15:117db924cf7c | 3398 | XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3399 | XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3400 | XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3401 | XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3402 | XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); |
wolfSSL | 15:117db924cf7c | 3403 | #endif |
wolfSSL | 15:117db924cf7c | 3404 | |
wolfSSL | 15:117db924cf7c | 3405 | if (ret == 0) |
wolfSSL | 15:117db924cf7c | 3406 | ret = CleanPreMaster(ssl); |
wolfSSL | 15:117db924cf7c | 3407 | else |
wolfSSL | 15:117db924cf7c | 3408 | CleanPreMaster(ssl); |
wolfSSL | 15:117db924cf7c | 3409 | |
wolfSSL | 15:117db924cf7c | 3410 | return ret; |
wolfSSL | 15:117db924cf7c | 3411 | } |
wolfSSL | 15:117db924cf7c | 3412 | #endif |
wolfSSL | 15:117db924cf7c | 3413 | |
wolfSSL | 15:117db924cf7c | 3414 | |
wolfSSL | 15:117db924cf7c | 3415 | /* Master wrapper, doesn't use SSL stack space in TLS mode */ |
wolfSSL | 15:117db924cf7c | 3416 | int MakeMasterSecret(WOLFSSL* ssl) |
wolfSSL | 15:117db924cf7c | 3417 | { |
wolfSSL | 15:117db924cf7c | 3418 | /* append secret to premaster : premaster | SerSi | CliSi */ |
wolfSSL | 15:117db924cf7c | 3419 | #ifdef HAVE_QSH |
wolfSSL | 15:117db924cf7c | 3420 | word32 offset = 0; |
wolfSSL | 15:117db924cf7c | 3421 | |
wolfSSL | 15:117db924cf7c | 3422 | if (ssl->peerQSHKeyPresent) { |
wolfSSL | 15:117db924cf7c | 3423 | offset += ssl->arrays->preMasterSz; |
wolfSSL | 15:117db924cf7c | 3424 | ssl->arrays->preMasterSz += ssl->QSH_secret->CliSi->length + |
wolfSSL | 15:117db924cf7c | 3425 | ssl->QSH_secret->SerSi->length; |
wolfSSL | 15:117db924cf7c | 3426 | /* test and set flag if QSH has been used */ |
wolfSSL | 15:117db924cf7c | 3427 | if (ssl->QSH_secret->CliSi->length > 0 || |
wolfSSL | 15:117db924cf7c | 3428 | ssl->QSH_secret->SerSi->length > 0) |
wolfSSL | 15:117db924cf7c | 3429 | ssl->isQSH = 1; |
wolfSSL | 15:117db924cf7c | 3430 | |
wolfSSL | 15:117db924cf7c | 3431 | /* append secrets to the premaster */ |
wolfSSL | 15:117db924cf7c | 3432 | if (ssl->QSH_secret->SerSi != NULL) { |
wolfSSL | 15:117db924cf7c | 3433 | XMEMCPY(ssl->arrays->preMasterSecret + offset, |
wolfSSL | 15:117db924cf7c | 3434 | ssl->QSH_secret->SerSi->buffer, ssl->QSH_secret->SerSi->length); |
wolfSSL | 15:117db924cf7c | 3435 | } |
wolfSSL | 15:117db924cf7c | 3436 | offset += ssl->QSH_secret->SerSi->length; |
wolfSSL | 15:117db924cf7c | 3437 | if (ssl->QSH_secret->CliSi != NULL) { |
wolfSSL | 15:117db924cf7c | 3438 | XMEMCPY(ssl->arrays->preMasterSecret + offset, |
wolfSSL | 15:117db924cf7c | 3439 | ssl->QSH_secret->CliSi->buffer, ssl->QSH_secret->CliSi->length); |
wolfSSL | 15:117db924cf7c | 3440 | } |
wolfSSL | 15:117db924cf7c | 3441 | |
wolfSSL | 15:117db924cf7c | 3442 | /* show secret SerSi and CliSi */ |
wolfSSL | 15:117db924cf7c | 3443 | #ifdef SHOW_SECRETS |
wolfSSL | 15:117db924cf7c | 3444 | { |
wolfSSL | 15:117db924cf7c | 3445 | word32 j; |
wolfSSL | 15:117db924cf7c | 3446 | printf("QSH generated secret material\n"); |
wolfSSL | 15:117db924cf7c | 3447 | printf("SerSi : "); |
wolfSSL | 15:117db924cf7c | 3448 | for (j = 0; j < ssl->QSH_secret->SerSi->length; j++) { |
wolfSSL | 15:117db924cf7c | 3449 | printf("%02x", ssl->QSH_secret->SerSi->buffer[j]); |
wolfSSL | 15:117db924cf7c | 3450 | } |
wolfSSL | 15:117db924cf7c | 3451 | printf("\n"); |
wolfSSL | 15:117db924cf7c | 3452 | printf("CliSi : "); |
wolfSSL | 15:117db924cf7c | 3453 | for (j = 0; j < ssl->QSH_secret->CliSi->length; j++) { |
wolfSSL | 15:117db924cf7c | 3454 | printf("%02x", ssl->QSH_secret->CliSi->buffer[j]); |
wolfSSL | 15:117db924cf7c | 3455 | } |
wolfSSL | 15:117db924cf7c | 3456 | printf("\n"); |
wolfSSL | 15:117db924cf7c | 3457 | } |
wolfSSL | 15:117db924cf7c | 3458 | #endif |
wolfSSL | 15:117db924cf7c | 3459 | } |
wolfSSL | 15:117db924cf7c | 3460 | #endif |
wolfSSL | 15:117db924cf7c | 3461 | |
wolfSSL | 15:117db924cf7c | 3462 | #ifndef NO_OLD_TLS |
wolfSSL | 15:117db924cf7c | 3463 | if (ssl->options.tls) return MakeTlsMasterSecret(ssl); |
wolfSSL | 15:117db924cf7c | 3464 | return MakeSslMasterSecret(ssl); |
wolfSSL | 15:117db924cf7c | 3465 | #elif !defined(WOLFSSL_NO_TLS12) |
wolfSSL | 15:117db924cf7c | 3466 | return MakeTlsMasterSecret(ssl); |
wolfSSL | 15:117db924cf7c | 3467 | #else |
wolfSSL | 15:117db924cf7c | 3468 | (void)ssl; |
wolfSSL | 15:117db924cf7c | 3469 | return 0; |
wolfSSL | 15:117db924cf7c | 3470 | #endif |
wolfSSL | 15:117db924cf7c | 3471 | } |
wolfSSL | 15:117db924cf7c | 3472 | |
wolfSSL | 15:117db924cf7c | 3473 | #endif /* WOLFCRYPT_ONLY */ |
wolfSSL | 15:117db924cf7c | 3474 | |
wolfSSL | 15:117db924cf7c | 3475 |