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