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