SSL/TLS Library
CyaSSL is SSL/TLS library for embedded systems.
src/keys.c@0:9d17e4342598, 2014-04-20 (annotated)
- Committer:
- wolfSSL
- Date:
- Sun Apr 20 12:40:57 2014 +0000
- Revision:
- 0:9d17e4342598
CyaSSL SSL/TLS Library 2.9.4;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wolfSSL | 0:9d17e4342598 | 1 | /* keys.c |
wolfSSL | 0:9d17e4342598 | 2 | * |
wolfSSL | 0:9d17e4342598 | 3 | * Copyright (C) 2006-2013 wolfSSL Inc. |
wolfSSL | 0:9d17e4342598 | 4 | * |
wolfSSL | 0:9d17e4342598 | 5 | * This file is part of CyaSSL. |
wolfSSL | 0:9d17e4342598 | 6 | * |
wolfSSL | 0:9d17e4342598 | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
wolfSSL | 0:9d17e4342598 | 8 | * it under the terms of the GNU General Public License as published by |
wolfSSL | 0:9d17e4342598 | 9 | * the Free Software Foundation; either version 2 of the License, or |
wolfSSL | 0:9d17e4342598 | 10 | * (at your option) any later version. |
wolfSSL | 0:9d17e4342598 | 11 | * |
wolfSSL | 0:9d17e4342598 | 12 | * CyaSSL is distributed in the hope that it will be useful, |
wolfSSL | 0:9d17e4342598 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
wolfSSL | 0:9d17e4342598 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
wolfSSL | 0:9d17e4342598 | 15 | * GNU General Public License for more details. |
wolfSSL | 0:9d17e4342598 | 16 | * |
wolfSSL | 0:9d17e4342598 | 17 | * You should have received a copy of the GNU General Public License |
wolfSSL | 0:9d17e4342598 | 18 | * along with this program; if not, write to the Free Software |
wolfSSL | 0:9d17e4342598 | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
wolfSSL | 0:9d17e4342598 | 20 | */ |
wolfSSL | 0:9d17e4342598 | 21 | |
wolfSSL | 0:9d17e4342598 | 22 | |
wolfSSL | 0:9d17e4342598 | 23 | #ifdef HAVE_CONFIG_H |
wolfSSL | 0:9d17e4342598 | 24 | #include <config.h> |
wolfSSL | 0:9d17e4342598 | 25 | #endif |
wolfSSL | 0:9d17e4342598 | 26 | |
wolfSSL | 0:9d17e4342598 | 27 | #include <cyassl/ctaocrypt/settings.h> |
wolfSSL | 0:9d17e4342598 | 28 | |
wolfSSL | 0:9d17e4342598 | 29 | #include <cyassl/internal.h> |
wolfSSL | 0:9d17e4342598 | 30 | #include <cyassl/error-ssl.h> |
wolfSSL | 0:9d17e4342598 | 31 | #ifdef SHOW_SECRETS |
wolfSSL | 0:9d17e4342598 | 32 | #ifdef FREESCALE_MQX |
wolfSSL | 0:9d17e4342598 | 33 | #include <fio.h> |
wolfSSL | 0:9d17e4342598 | 34 | #else |
wolfSSL | 0:9d17e4342598 | 35 | #include <stdio.h> |
wolfSSL | 0:9d17e4342598 | 36 | #endif |
wolfSSL | 0:9d17e4342598 | 37 | #endif |
wolfSSL | 0:9d17e4342598 | 38 | |
wolfSSL | 0:9d17e4342598 | 39 | |
wolfSSL | 0:9d17e4342598 | 40 | int SetCipherSpecs(CYASSL* ssl) |
wolfSSL | 0:9d17e4342598 | 41 | { |
wolfSSL | 0:9d17e4342598 | 42 | /* ECC extensions, or AES-CCM */ |
wolfSSL | 0:9d17e4342598 | 43 | if (ssl->options.cipherSuite0 == ECC_BYTE) { |
wolfSSL | 0:9d17e4342598 | 44 | |
wolfSSL | 0:9d17e4342598 | 45 | switch (ssl->options.cipherSuite) { |
wolfSSL | 0:9d17e4342598 | 46 | |
wolfSSL | 0:9d17e4342598 | 47 | #ifdef HAVE_ECC |
wolfSSL | 0:9d17e4342598 | 48 | |
wolfSSL | 0:9d17e4342598 | 49 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 50 | case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 51 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 52 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 53 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 54 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 55 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 56 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 57 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 58 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 59 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 60 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 61 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 62 | break; |
wolfSSL | 0:9d17e4342598 | 63 | #endif |
wolfSSL | 0:9d17e4342598 | 64 | |
wolfSSL | 0:9d17e4342598 | 65 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 66 | case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 67 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 68 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 69 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 70 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 71 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 72 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 73 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 74 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 75 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 76 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 77 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 78 | break; |
wolfSSL | 0:9d17e4342598 | 79 | #endif |
wolfSSL | 0:9d17e4342598 | 80 | |
wolfSSL | 0:9d17e4342598 | 81 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 82 | case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 83 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 84 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 85 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 86 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 87 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 88 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 89 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 90 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 91 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 92 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 93 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 94 | break; |
wolfSSL | 0:9d17e4342598 | 95 | #endif |
wolfSSL | 0:9d17e4342598 | 96 | |
wolfSSL | 0:9d17e4342598 | 97 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 98 | case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 99 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 100 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 101 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 102 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 103 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 104 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 105 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 106 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 107 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 108 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 109 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 110 | break; |
wolfSSL | 0:9d17e4342598 | 111 | #endif |
wolfSSL | 0:9d17e4342598 | 112 | |
wolfSSL | 0:9d17e4342598 | 113 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 0:9d17e4342598 | 114 | case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 0:9d17e4342598 | 115 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 116 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 117 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 118 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 119 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 120 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 121 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 122 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 123 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 124 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 125 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 126 | break; |
wolfSSL | 0:9d17e4342598 | 127 | #endif |
wolfSSL | 0:9d17e4342598 | 128 | |
wolfSSL | 0:9d17e4342598 | 129 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 0:9d17e4342598 | 130 | case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 0:9d17e4342598 | 131 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 132 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 133 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 134 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 135 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 136 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 137 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 138 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 139 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 140 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 141 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 142 | break; |
wolfSSL | 0:9d17e4342598 | 143 | #endif |
wolfSSL | 0:9d17e4342598 | 144 | |
wolfSSL | 0:9d17e4342598 | 145 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 0:9d17e4342598 | 146 | case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 0:9d17e4342598 | 147 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 148 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 149 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 150 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 151 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 152 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 153 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 154 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 155 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 156 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 157 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 158 | break; |
wolfSSL | 0:9d17e4342598 | 159 | #endif |
wolfSSL | 0:9d17e4342598 | 160 | |
wolfSSL | 0:9d17e4342598 | 161 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 |
wolfSSL | 0:9d17e4342598 | 162 | case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 : |
wolfSSL | 0:9d17e4342598 | 163 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 164 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 165 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 166 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 167 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 168 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 169 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 170 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 171 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 172 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 173 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 174 | break; |
wolfSSL | 0:9d17e4342598 | 175 | #endif |
wolfSSL | 0:9d17e4342598 | 176 | |
wolfSSL | 0:9d17e4342598 | 177 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 178 | case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 179 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 180 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 181 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 182 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 183 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 184 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 185 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 186 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 187 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 188 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 189 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 190 | |
wolfSSL | 0:9d17e4342598 | 191 | break; |
wolfSSL | 0:9d17e4342598 | 192 | #endif |
wolfSSL | 0:9d17e4342598 | 193 | |
wolfSSL | 0:9d17e4342598 | 194 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 195 | case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 196 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 197 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 198 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 199 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 200 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 201 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 202 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 203 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 204 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 205 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 206 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 207 | |
wolfSSL | 0:9d17e4342598 | 208 | break; |
wolfSSL | 0:9d17e4342598 | 209 | #endif |
wolfSSL | 0:9d17e4342598 | 210 | |
wolfSSL | 0:9d17e4342598 | 211 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 212 | case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 213 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 214 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 215 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 216 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 217 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 218 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 219 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 220 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 221 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 222 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 223 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 224 | |
wolfSSL | 0:9d17e4342598 | 225 | break; |
wolfSSL | 0:9d17e4342598 | 226 | #endif |
wolfSSL | 0:9d17e4342598 | 227 | |
wolfSSL | 0:9d17e4342598 | 228 | #ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 229 | case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 230 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 231 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 232 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 233 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 234 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 235 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 236 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 237 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 238 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 239 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 240 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 241 | |
wolfSSL | 0:9d17e4342598 | 242 | break; |
wolfSSL | 0:9d17e4342598 | 243 | #endif |
wolfSSL | 0:9d17e4342598 | 244 | |
wolfSSL | 0:9d17e4342598 | 245 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 246 | case TLS_ECDHE_RSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 247 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 248 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 249 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 250 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 251 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 252 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 253 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 254 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 255 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 256 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 257 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 258 | |
wolfSSL | 0:9d17e4342598 | 259 | break; |
wolfSSL | 0:9d17e4342598 | 260 | #endif |
wolfSSL | 0:9d17e4342598 | 261 | |
wolfSSL | 0:9d17e4342598 | 262 | #ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 263 | case TLS_ECDH_RSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 264 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 265 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 266 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 267 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 268 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 269 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 270 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 271 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 272 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 273 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 274 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 275 | |
wolfSSL | 0:9d17e4342598 | 276 | break; |
wolfSSL | 0:9d17e4342598 | 277 | #endif |
wolfSSL | 0:9d17e4342598 | 278 | |
wolfSSL | 0:9d17e4342598 | 279 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 280 | case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 281 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 282 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 283 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 284 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 285 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 286 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 287 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 288 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 289 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 290 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 291 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 292 | |
wolfSSL | 0:9d17e4342598 | 293 | break; |
wolfSSL | 0:9d17e4342598 | 294 | #endif |
wolfSSL | 0:9d17e4342598 | 295 | |
wolfSSL | 0:9d17e4342598 | 296 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 297 | case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 298 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 299 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 300 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 301 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 302 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 303 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 304 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 305 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 306 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 307 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 308 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 309 | |
wolfSSL | 0:9d17e4342598 | 310 | break; |
wolfSSL | 0:9d17e4342598 | 311 | #endif |
wolfSSL | 0:9d17e4342598 | 312 | |
wolfSSL | 0:9d17e4342598 | 313 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 314 | case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 315 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 316 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 317 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 318 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 319 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 320 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 321 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 322 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 323 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 324 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 325 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 326 | |
wolfSSL | 0:9d17e4342598 | 327 | break; |
wolfSSL | 0:9d17e4342598 | 328 | #endif |
wolfSSL | 0:9d17e4342598 | 329 | |
wolfSSL | 0:9d17e4342598 | 330 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 331 | case TLS_ECDH_ECDSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 332 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 333 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 334 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 335 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 336 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 337 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 338 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 339 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 340 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 341 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 342 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 343 | |
wolfSSL | 0:9d17e4342598 | 344 | break; |
wolfSSL | 0:9d17e4342598 | 345 | #endif |
wolfSSL | 0:9d17e4342598 | 346 | |
wolfSSL | 0:9d17e4342598 | 347 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 348 | case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 349 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 350 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 351 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 352 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 353 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 354 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 355 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 356 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 357 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 358 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 359 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 360 | |
wolfSSL | 0:9d17e4342598 | 361 | break; |
wolfSSL | 0:9d17e4342598 | 362 | #endif |
wolfSSL | 0:9d17e4342598 | 363 | |
wolfSSL | 0:9d17e4342598 | 364 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 365 | case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 366 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 367 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 368 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 369 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 370 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 371 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 372 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 373 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 374 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 375 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 376 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 377 | |
wolfSSL | 0:9d17e4342598 | 378 | break; |
wolfSSL | 0:9d17e4342598 | 379 | #endif |
wolfSSL | 0:9d17e4342598 | 380 | |
wolfSSL | 0:9d17e4342598 | 381 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 382 | case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 383 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 384 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 385 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 386 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 387 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 388 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 389 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 390 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 391 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 392 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 393 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 394 | |
wolfSSL | 0:9d17e4342598 | 395 | break; |
wolfSSL | 0:9d17e4342598 | 396 | #endif |
wolfSSL | 0:9d17e4342598 | 397 | |
wolfSSL | 0:9d17e4342598 | 398 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 399 | case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 400 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 401 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 402 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 403 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 404 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 405 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 406 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 407 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 408 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 409 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 410 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 411 | |
wolfSSL | 0:9d17e4342598 | 412 | break; |
wolfSSL | 0:9d17e4342598 | 413 | #endif |
wolfSSL | 0:9d17e4342598 | 414 | |
wolfSSL | 0:9d17e4342598 | 415 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 416 | case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 417 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 418 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 419 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 420 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 421 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 422 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 423 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 424 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 425 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 426 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 427 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 428 | |
wolfSSL | 0:9d17e4342598 | 429 | break; |
wolfSSL | 0:9d17e4342598 | 430 | #endif |
wolfSSL | 0:9d17e4342598 | 431 | |
wolfSSL | 0:9d17e4342598 | 432 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 433 | case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 434 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 435 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 436 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 437 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 438 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 439 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 440 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 441 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 442 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 443 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 444 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 445 | |
wolfSSL | 0:9d17e4342598 | 446 | break; |
wolfSSL | 0:9d17e4342598 | 447 | #endif |
wolfSSL | 0:9d17e4342598 | 448 | |
wolfSSL | 0:9d17e4342598 | 449 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 450 | case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 451 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 452 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 453 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 454 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 455 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 456 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 457 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 458 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 459 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 460 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 461 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 462 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 463 | |
wolfSSL | 0:9d17e4342598 | 464 | break; |
wolfSSL | 0:9d17e4342598 | 465 | #endif |
wolfSSL | 0:9d17e4342598 | 466 | |
wolfSSL | 0:9d17e4342598 | 467 | #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 468 | case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 469 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 470 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 471 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 472 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 473 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 474 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 475 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 476 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 477 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 478 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 479 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 480 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 481 | |
wolfSSL | 0:9d17e4342598 | 482 | break; |
wolfSSL | 0:9d17e4342598 | 483 | #endif |
wolfSSL | 0:9d17e4342598 | 484 | |
wolfSSL | 0:9d17e4342598 | 485 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 486 | case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 487 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 488 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 489 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 490 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 491 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 492 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 493 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 494 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 495 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 496 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 497 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 498 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 499 | |
wolfSSL | 0:9d17e4342598 | 500 | break; |
wolfSSL | 0:9d17e4342598 | 501 | #endif |
wolfSSL | 0:9d17e4342598 | 502 | |
wolfSSL | 0:9d17e4342598 | 503 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 504 | case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 505 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 506 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 507 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 508 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 509 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 510 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 511 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 512 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 513 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 514 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 515 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 516 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 517 | |
wolfSSL | 0:9d17e4342598 | 518 | break; |
wolfSSL | 0:9d17e4342598 | 519 | #endif |
wolfSSL | 0:9d17e4342598 | 520 | |
wolfSSL | 0:9d17e4342598 | 521 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 522 | case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 523 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 524 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 525 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 526 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 527 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 528 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 529 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 530 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 531 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 532 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 533 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 534 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 535 | |
wolfSSL | 0:9d17e4342598 | 536 | break; |
wolfSSL | 0:9d17e4342598 | 537 | #endif |
wolfSSL | 0:9d17e4342598 | 538 | |
wolfSSL | 0:9d17e4342598 | 539 | #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 540 | case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 541 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 542 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 543 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 544 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 545 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 546 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 547 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 548 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 549 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 550 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 551 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 552 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 553 | |
wolfSSL | 0:9d17e4342598 | 554 | break; |
wolfSSL | 0:9d17e4342598 | 555 | #endif |
wolfSSL | 0:9d17e4342598 | 556 | |
wolfSSL | 0:9d17e4342598 | 557 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 558 | case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 559 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 560 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 561 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 562 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 563 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 564 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 565 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 566 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 567 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 568 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 569 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 570 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 571 | |
wolfSSL | 0:9d17e4342598 | 572 | break; |
wolfSSL | 0:9d17e4342598 | 573 | #endif |
wolfSSL | 0:9d17e4342598 | 574 | |
wolfSSL | 0:9d17e4342598 | 575 | #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 576 | case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 577 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 578 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 579 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 580 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 581 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 582 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 583 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 584 | ssl->specs.static_ecdh = 1; |
wolfSSL | 0:9d17e4342598 | 585 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 586 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 587 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 588 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 589 | |
wolfSSL | 0:9d17e4342598 | 590 | break; |
wolfSSL | 0:9d17e4342598 | 591 | #endif |
wolfSSL | 0:9d17e4342598 | 592 | |
wolfSSL | 0:9d17e4342598 | 593 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 |
wolfSSL | 0:9d17e4342598 | 594 | case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 595 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 596 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 597 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 598 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 599 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 600 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 601 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 602 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 603 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 604 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 605 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 606 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 607 | |
wolfSSL | 0:9d17e4342598 | 608 | break; |
wolfSSL | 0:9d17e4342598 | 609 | #endif |
wolfSSL | 0:9d17e4342598 | 610 | |
wolfSSL | 0:9d17e4342598 | 611 | #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 |
wolfSSL | 0:9d17e4342598 | 612 | case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 613 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 614 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 615 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 616 | ssl->specs.kea = ecc_diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 617 | ssl->specs.sig_algo = ecc_dsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 618 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 619 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 620 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 621 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 622 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 623 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 624 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 625 | |
wolfSSL | 0:9d17e4342598 | 626 | break; |
wolfSSL | 0:9d17e4342598 | 627 | #endif |
wolfSSL | 0:9d17e4342598 | 628 | #endif /* HAVE_ECC */ |
wolfSSL | 0:9d17e4342598 | 629 | |
wolfSSL | 0:9d17e4342598 | 630 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8 |
wolfSSL | 0:9d17e4342598 | 631 | case TLS_RSA_WITH_AES_128_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 632 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 633 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 634 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 635 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 636 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 637 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 638 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 639 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 640 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 641 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 642 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 643 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 644 | |
wolfSSL | 0:9d17e4342598 | 645 | break; |
wolfSSL | 0:9d17e4342598 | 646 | #endif |
wolfSSL | 0:9d17e4342598 | 647 | |
wolfSSL | 0:9d17e4342598 | 648 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8 |
wolfSSL | 0:9d17e4342598 | 649 | case TLS_RSA_WITH_AES_256_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 650 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 651 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 652 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 653 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 654 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 655 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 656 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 657 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 658 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 659 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 660 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 661 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 662 | |
wolfSSL | 0:9d17e4342598 | 663 | break; |
wolfSSL | 0:9d17e4342598 | 664 | #endif |
wolfSSL | 0:9d17e4342598 | 665 | |
wolfSSL | 0:9d17e4342598 | 666 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8 |
wolfSSL | 0:9d17e4342598 | 667 | case TLS_PSK_WITH_AES_128_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 668 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 669 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 670 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 671 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 672 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 673 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 674 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 675 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 676 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 677 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 678 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 679 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 680 | |
wolfSSL | 0:9d17e4342598 | 681 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 682 | break; |
wolfSSL | 0:9d17e4342598 | 683 | #endif |
wolfSSL | 0:9d17e4342598 | 684 | |
wolfSSL | 0:9d17e4342598 | 685 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8 |
wolfSSL | 0:9d17e4342598 | 686 | case TLS_PSK_WITH_AES_256_CCM_8 : |
wolfSSL | 0:9d17e4342598 | 687 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; |
wolfSSL | 0:9d17e4342598 | 688 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 689 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 690 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 691 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 692 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 693 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 694 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 695 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 696 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 697 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 698 | ssl->specs.aead_mac_size = AES_CCM_8_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 699 | |
wolfSSL | 0:9d17e4342598 | 700 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 701 | break; |
wolfSSL | 0:9d17e4342598 | 702 | #endif |
wolfSSL | 0:9d17e4342598 | 703 | |
wolfSSL | 0:9d17e4342598 | 704 | default: |
wolfSSL | 0:9d17e4342598 | 705 | CYASSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC"); |
wolfSSL | 0:9d17e4342598 | 706 | return UNSUPPORTED_SUITE; |
wolfSSL | 0:9d17e4342598 | 707 | } /* switch */ |
wolfSSL | 0:9d17e4342598 | 708 | } /* if */ |
wolfSSL | 0:9d17e4342598 | 709 | if (ssl->options.cipherSuite0 != ECC_BYTE) { /* normal suites */ |
wolfSSL | 0:9d17e4342598 | 710 | switch (ssl->options.cipherSuite) { |
wolfSSL | 0:9d17e4342598 | 711 | |
wolfSSL | 0:9d17e4342598 | 712 | #ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 713 | case SSL_RSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 714 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 715 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 716 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 717 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 718 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 719 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 720 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 721 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 722 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 723 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 724 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 725 | |
wolfSSL | 0:9d17e4342598 | 726 | break; |
wolfSSL | 0:9d17e4342598 | 727 | #endif |
wolfSSL | 0:9d17e4342598 | 728 | |
wolfSSL | 0:9d17e4342598 | 729 | #ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA |
wolfSSL | 0:9d17e4342598 | 730 | case TLS_NTRU_RSA_WITH_RC4_128_SHA : |
wolfSSL | 0:9d17e4342598 | 731 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 732 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 733 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 734 | ssl->specs.kea = ntru_kea; |
wolfSSL | 0:9d17e4342598 | 735 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 736 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 737 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 738 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 739 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 740 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 741 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 742 | |
wolfSSL | 0:9d17e4342598 | 743 | break; |
wolfSSL | 0:9d17e4342598 | 744 | #endif |
wolfSSL | 0:9d17e4342598 | 745 | |
wolfSSL | 0:9d17e4342598 | 746 | #ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5 |
wolfSSL | 0:9d17e4342598 | 747 | case SSL_RSA_WITH_RC4_128_MD5 : |
wolfSSL | 0:9d17e4342598 | 748 | ssl->specs.bulk_cipher_algorithm = cyassl_rc4; |
wolfSSL | 0:9d17e4342598 | 749 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 750 | ssl->specs.mac_algorithm = md5_mac; |
wolfSSL | 0:9d17e4342598 | 751 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 752 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 753 | ssl->specs.hash_size = MD5_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 754 | ssl->specs.pad_size = PAD_MD5; |
wolfSSL | 0:9d17e4342598 | 755 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 756 | ssl->specs.key_size = RC4_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 757 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 758 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 759 | |
wolfSSL | 0:9d17e4342598 | 760 | break; |
wolfSSL | 0:9d17e4342598 | 761 | #endif |
wolfSSL | 0:9d17e4342598 | 762 | |
wolfSSL | 0:9d17e4342598 | 763 | #ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 764 | case SSL_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 765 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 766 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 767 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 768 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 769 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 770 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 771 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 772 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 773 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 774 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 775 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 776 | |
wolfSSL | 0:9d17e4342598 | 777 | break; |
wolfSSL | 0:9d17e4342598 | 778 | #endif |
wolfSSL | 0:9d17e4342598 | 779 | |
wolfSSL | 0:9d17e4342598 | 780 | #ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 781 | case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 782 | ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; |
wolfSSL | 0:9d17e4342598 | 783 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 784 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 785 | ssl->specs.kea = ntru_kea; |
wolfSSL | 0:9d17e4342598 | 786 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 787 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 788 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 789 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 790 | ssl->specs.key_size = DES3_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 791 | ssl->specs.block_size = DES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 792 | ssl->specs.iv_size = DES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 793 | |
wolfSSL | 0:9d17e4342598 | 794 | break; |
wolfSSL | 0:9d17e4342598 | 795 | #endif |
wolfSSL | 0:9d17e4342598 | 796 | |
wolfSSL | 0:9d17e4342598 | 797 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 798 | case TLS_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 799 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 800 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 801 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 802 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 803 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 804 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 805 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 806 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 807 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 808 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 809 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 810 | |
wolfSSL | 0:9d17e4342598 | 811 | break; |
wolfSSL | 0:9d17e4342598 | 812 | #endif |
wolfSSL | 0:9d17e4342598 | 813 | |
wolfSSL | 0:9d17e4342598 | 814 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 815 | case TLS_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 816 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 817 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 818 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 819 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 820 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 821 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 822 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 823 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 824 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 825 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 826 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 827 | |
wolfSSL | 0:9d17e4342598 | 828 | break; |
wolfSSL | 0:9d17e4342598 | 829 | #endif |
wolfSSL | 0:9d17e4342598 | 830 | |
wolfSSL | 0:9d17e4342598 | 831 | #ifdef BUILD_TLS_RSA_WITH_NULL_SHA |
wolfSSL | 0:9d17e4342598 | 832 | case TLS_RSA_WITH_NULL_SHA : |
wolfSSL | 0:9d17e4342598 | 833 | ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; |
wolfSSL | 0:9d17e4342598 | 834 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 835 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 836 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 837 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 838 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 839 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 840 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 841 | ssl->specs.key_size = 0; |
wolfSSL | 0:9d17e4342598 | 842 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 843 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 844 | |
wolfSSL | 0:9d17e4342598 | 845 | break; |
wolfSSL | 0:9d17e4342598 | 846 | #endif |
wolfSSL | 0:9d17e4342598 | 847 | |
wolfSSL | 0:9d17e4342598 | 848 | #ifdef BUILD_TLS_RSA_WITH_NULL_SHA256 |
wolfSSL | 0:9d17e4342598 | 849 | case TLS_RSA_WITH_NULL_SHA256 : |
wolfSSL | 0:9d17e4342598 | 850 | ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; |
wolfSSL | 0:9d17e4342598 | 851 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 852 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 853 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 854 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 855 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 856 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 857 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 858 | ssl->specs.key_size = 0; |
wolfSSL | 0:9d17e4342598 | 859 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 860 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 861 | |
wolfSSL | 0:9d17e4342598 | 862 | break; |
wolfSSL | 0:9d17e4342598 | 863 | #endif |
wolfSSL | 0:9d17e4342598 | 864 | |
wolfSSL | 0:9d17e4342598 | 865 | #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 866 | case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 867 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 868 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 869 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 870 | ssl->specs.kea = ntru_kea; |
wolfSSL | 0:9d17e4342598 | 871 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 872 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 873 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 874 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 875 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 876 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 877 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 878 | |
wolfSSL | 0:9d17e4342598 | 879 | break; |
wolfSSL | 0:9d17e4342598 | 880 | #endif |
wolfSSL | 0:9d17e4342598 | 881 | |
wolfSSL | 0:9d17e4342598 | 882 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 883 | case TLS_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 884 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 885 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 886 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 887 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 888 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 889 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 890 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 891 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 892 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 893 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 894 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 895 | |
wolfSSL | 0:9d17e4342598 | 896 | break; |
wolfSSL | 0:9d17e4342598 | 897 | #endif |
wolfSSL | 0:9d17e4342598 | 898 | |
wolfSSL | 0:9d17e4342598 | 899 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 900 | case TLS_RSA_WITH_AES_256_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 901 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 902 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 903 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 904 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 905 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 906 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 907 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 908 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 909 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 910 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 911 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 912 | |
wolfSSL | 0:9d17e4342598 | 913 | break; |
wolfSSL | 0:9d17e4342598 | 914 | #endif |
wolfSSL | 0:9d17e4342598 | 915 | |
wolfSSL | 0:9d17e4342598 | 916 | #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 917 | case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 918 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 919 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 920 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 921 | ssl->specs.kea = ntru_kea; |
wolfSSL | 0:9d17e4342598 | 922 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 923 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 924 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 925 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 926 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 927 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 928 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 929 | |
wolfSSL | 0:9d17e4342598 | 930 | break; |
wolfSSL | 0:9d17e4342598 | 931 | #endif |
wolfSSL | 0:9d17e4342598 | 932 | |
wolfSSL | 0:9d17e4342598 | 933 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 934 | case TLS_PSK_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 935 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 936 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 937 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 938 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 939 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 940 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 941 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 942 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 943 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 944 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 945 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 946 | |
wolfSSL | 0:9d17e4342598 | 947 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 948 | break; |
wolfSSL | 0:9d17e4342598 | 949 | #endif |
wolfSSL | 0:9d17e4342598 | 950 | |
wolfSSL | 0:9d17e4342598 | 951 | #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 952 | case TLS_PSK_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 953 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 954 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 955 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 956 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 957 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 958 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 959 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 960 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 961 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 962 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 963 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 964 | |
wolfSSL | 0:9d17e4342598 | 965 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 966 | break; |
wolfSSL | 0:9d17e4342598 | 967 | #endif |
wolfSSL | 0:9d17e4342598 | 968 | |
wolfSSL | 0:9d17e4342598 | 969 | #ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 970 | case TLS_PSK_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 971 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 972 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 973 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 974 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 975 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 976 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 977 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 978 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 979 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 980 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 981 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 982 | |
wolfSSL | 0:9d17e4342598 | 983 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 984 | break; |
wolfSSL | 0:9d17e4342598 | 985 | #endif |
wolfSSL | 0:9d17e4342598 | 986 | |
wolfSSL | 0:9d17e4342598 | 987 | #ifdef BUILD_TLS_PSK_WITH_NULL_SHA256 |
wolfSSL | 0:9d17e4342598 | 988 | case TLS_PSK_WITH_NULL_SHA256 : |
wolfSSL | 0:9d17e4342598 | 989 | ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; |
wolfSSL | 0:9d17e4342598 | 990 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 991 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 992 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 993 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 994 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 995 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 996 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 997 | ssl->specs.key_size = 0; |
wolfSSL | 0:9d17e4342598 | 998 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 999 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 1000 | |
wolfSSL | 0:9d17e4342598 | 1001 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 1002 | break; |
wolfSSL | 0:9d17e4342598 | 1003 | #endif |
wolfSSL | 0:9d17e4342598 | 1004 | |
wolfSSL | 0:9d17e4342598 | 1005 | #ifdef BUILD_TLS_PSK_WITH_NULL_SHA |
wolfSSL | 0:9d17e4342598 | 1006 | case TLS_PSK_WITH_NULL_SHA : |
wolfSSL | 0:9d17e4342598 | 1007 | ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; |
wolfSSL | 0:9d17e4342598 | 1008 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 1009 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1010 | ssl->specs.kea = psk_kea; |
wolfSSL | 0:9d17e4342598 | 1011 | ssl->specs.sig_algo = anonymous_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1012 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1013 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1014 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1015 | ssl->specs.key_size = 0; |
wolfSSL | 0:9d17e4342598 | 1016 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 1017 | ssl->specs.iv_size = 0; |
wolfSSL | 0:9d17e4342598 | 1018 | |
wolfSSL | 0:9d17e4342598 | 1019 | ssl->options.usingPSK_cipher = 1; |
wolfSSL | 0:9d17e4342598 | 1020 | break; |
wolfSSL | 0:9d17e4342598 | 1021 | #endif |
wolfSSL | 0:9d17e4342598 | 1022 | |
wolfSSL | 0:9d17e4342598 | 1023 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1024 | case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1025 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1026 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1027 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1028 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1029 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1030 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1031 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1032 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1033 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1034 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1035 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1036 | |
wolfSSL | 0:9d17e4342598 | 1037 | break; |
wolfSSL | 0:9d17e4342598 | 1038 | #endif |
wolfSSL | 0:9d17e4342598 | 1039 | |
wolfSSL | 0:9d17e4342598 | 1040 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1041 | case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1042 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1043 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1044 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1045 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1046 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1047 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1048 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1049 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1050 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1051 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1052 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1053 | |
wolfSSL | 0:9d17e4342598 | 1054 | break; |
wolfSSL | 0:9d17e4342598 | 1055 | #endif |
wolfSSL | 0:9d17e4342598 | 1056 | |
wolfSSL | 0:9d17e4342598 | 1057 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1058 | case TLS_DHE_RSA_WITH_AES_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1059 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1060 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1061 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1062 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1063 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1064 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1065 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1066 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1067 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1068 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1069 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1070 | |
wolfSSL | 0:9d17e4342598 | 1071 | break; |
wolfSSL | 0:9d17e4342598 | 1072 | #endif |
wolfSSL | 0:9d17e4342598 | 1073 | |
wolfSSL | 0:9d17e4342598 | 1074 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1075 | case TLS_DHE_RSA_WITH_AES_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1076 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1077 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1078 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1079 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1080 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1081 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1082 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1083 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1084 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1085 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1086 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1087 | |
wolfSSL | 0:9d17e4342598 | 1088 | break; |
wolfSSL | 0:9d17e4342598 | 1089 | #endif |
wolfSSL | 0:9d17e4342598 | 1090 | |
wolfSSL | 0:9d17e4342598 | 1091 | #ifdef BUILD_TLS_RSA_WITH_HC_128_MD5 |
wolfSSL | 0:9d17e4342598 | 1092 | case TLS_RSA_WITH_HC_128_MD5 : |
wolfSSL | 0:9d17e4342598 | 1093 | ssl->specs.bulk_cipher_algorithm = cyassl_hc128; |
wolfSSL | 0:9d17e4342598 | 1094 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 1095 | ssl->specs.mac_algorithm = md5_mac; |
wolfSSL | 0:9d17e4342598 | 1096 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1097 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1098 | ssl->specs.hash_size = MD5_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1099 | ssl->specs.pad_size = PAD_MD5; |
wolfSSL | 0:9d17e4342598 | 1100 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1101 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1102 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 1103 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1104 | |
wolfSSL | 0:9d17e4342598 | 1105 | break; |
wolfSSL | 0:9d17e4342598 | 1106 | #endif |
wolfSSL | 0:9d17e4342598 | 1107 | |
wolfSSL | 0:9d17e4342598 | 1108 | #ifdef BUILD_TLS_RSA_WITH_HC_128_SHA |
wolfSSL | 0:9d17e4342598 | 1109 | case TLS_RSA_WITH_HC_128_SHA : |
wolfSSL | 0:9d17e4342598 | 1110 | ssl->specs.bulk_cipher_algorithm = cyassl_hc128; |
wolfSSL | 0:9d17e4342598 | 1111 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 1112 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1113 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1114 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1115 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1116 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1117 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1118 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1119 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 1120 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1121 | |
wolfSSL | 0:9d17e4342598 | 1122 | break; |
wolfSSL | 0:9d17e4342598 | 1123 | #endif |
wolfSSL | 0:9d17e4342598 | 1124 | |
wolfSSL | 0:9d17e4342598 | 1125 | #ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256 |
wolfSSL | 0:9d17e4342598 | 1126 | case TLS_RSA_WITH_HC_128_B2B256: |
wolfSSL | 0:9d17e4342598 | 1127 | ssl->specs.bulk_cipher_algorithm = cyassl_hc128; |
wolfSSL | 0:9d17e4342598 | 1128 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 1129 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 0:9d17e4342598 | 1130 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1131 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1132 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 0:9d17e4342598 | 1133 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1134 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1135 | ssl->specs.key_size = HC_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1136 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 1137 | ssl->specs.iv_size = HC_128_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1138 | |
wolfSSL | 0:9d17e4342598 | 1139 | break; |
wolfSSL | 0:9d17e4342598 | 1140 | #endif |
wolfSSL | 0:9d17e4342598 | 1141 | |
wolfSSL | 0:9d17e4342598 | 1142 | #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256 |
wolfSSL | 0:9d17e4342598 | 1143 | case TLS_RSA_WITH_AES_128_CBC_B2B256: |
wolfSSL | 0:9d17e4342598 | 1144 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1145 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1146 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 0:9d17e4342598 | 1147 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1148 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1149 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 0:9d17e4342598 | 1150 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1151 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1152 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1153 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1154 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1155 | |
wolfSSL | 0:9d17e4342598 | 1156 | break; |
wolfSSL | 0:9d17e4342598 | 1157 | #endif |
wolfSSL | 0:9d17e4342598 | 1158 | |
wolfSSL | 0:9d17e4342598 | 1159 | #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256 |
wolfSSL | 0:9d17e4342598 | 1160 | case TLS_RSA_WITH_AES_256_CBC_B2B256: |
wolfSSL | 0:9d17e4342598 | 1161 | ssl->specs.bulk_cipher_algorithm = cyassl_aes; |
wolfSSL | 0:9d17e4342598 | 1162 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1163 | ssl->specs.mac_algorithm = blake2b_mac; |
wolfSSL | 0:9d17e4342598 | 1164 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1165 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1166 | ssl->specs.hash_size = BLAKE2B_256; |
wolfSSL | 0:9d17e4342598 | 1167 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1168 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1169 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1170 | ssl->specs.iv_size = AES_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1171 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1172 | |
wolfSSL | 0:9d17e4342598 | 1173 | break; |
wolfSSL | 0:9d17e4342598 | 1174 | #endif |
wolfSSL | 0:9d17e4342598 | 1175 | |
wolfSSL | 0:9d17e4342598 | 1176 | #ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA |
wolfSSL | 0:9d17e4342598 | 1177 | case TLS_RSA_WITH_RABBIT_SHA : |
wolfSSL | 0:9d17e4342598 | 1178 | ssl->specs.bulk_cipher_algorithm = cyassl_rabbit; |
wolfSSL | 0:9d17e4342598 | 1179 | ssl->specs.cipher_type = stream; |
wolfSSL | 0:9d17e4342598 | 1180 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1181 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1182 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1183 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1184 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1185 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1186 | ssl->specs.key_size = RABBIT_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1187 | ssl->specs.block_size = 0; |
wolfSSL | 0:9d17e4342598 | 1188 | ssl->specs.iv_size = RABBIT_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1189 | |
wolfSSL | 0:9d17e4342598 | 1190 | break; |
wolfSSL | 0:9d17e4342598 | 1191 | #endif |
wolfSSL | 0:9d17e4342598 | 1192 | |
wolfSSL | 0:9d17e4342598 | 1193 | #ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 1194 | case TLS_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1195 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 1196 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 1197 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1198 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1199 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1200 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1201 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1202 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1203 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1204 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1205 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 1206 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 1207 | |
wolfSSL | 0:9d17e4342598 | 1208 | break; |
wolfSSL | 0:9d17e4342598 | 1209 | #endif |
wolfSSL | 0:9d17e4342598 | 1210 | |
wolfSSL | 0:9d17e4342598 | 1211 | #ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 1212 | case TLS_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 1213 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 1214 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 1215 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 1216 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1217 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1218 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1219 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1220 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1221 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1222 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1223 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 1224 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 1225 | |
wolfSSL | 0:9d17e4342598 | 1226 | break; |
wolfSSL | 0:9d17e4342598 | 1227 | #endif |
wolfSSL | 0:9d17e4342598 | 1228 | |
wolfSSL | 0:9d17e4342598 | 1229 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 |
wolfSSL | 0:9d17e4342598 | 1230 | case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1231 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 1232 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 1233 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1234 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1235 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1236 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1237 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1238 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1239 | ssl->specs.key_size = AES_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1240 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1241 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 1242 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 1243 | |
wolfSSL | 0:9d17e4342598 | 1244 | break; |
wolfSSL | 0:9d17e4342598 | 1245 | #endif |
wolfSSL | 0:9d17e4342598 | 1246 | |
wolfSSL | 0:9d17e4342598 | 1247 | #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 |
wolfSSL | 0:9d17e4342598 | 1248 | case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 : |
wolfSSL | 0:9d17e4342598 | 1249 | ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; |
wolfSSL | 0:9d17e4342598 | 1250 | ssl->specs.cipher_type = aead; |
wolfSSL | 0:9d17e4342598 | 1251 | ssl->specs.mac_algorithm = sha384_mac; |
wolfSSL | 0:9d17e4342598 | 1252 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1253 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1254 | ssl->specs.hash_size = SHA384_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1255 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1256 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1257 | ssl->specs.key_size = AES_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1258 | ssl->specs.block_size = AES_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1259 | ssl->specs.iv_size = AEAD_IMP_IV_SZ; |
wolfSSL | 0:9d17e4342598 | 1260 | ssl->specs.aead_mac_size = AES_GCM_AUTH_SZ; |
wolfSSL | 0:9d17e4342598 | 1261 | |
wolfSSL | 0:9d17e4342598 | 1262 | break; |
wolfSSL | 0:9d17e4342598 | 1263 | #endif |
wolfSSL | 0:9d17e4342598 | 1264 | |
wolfSSL | 0:9d17e4342598 | 1265 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1266 | case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1267 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1268 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1269 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1270 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1271 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1272 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1273 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1274 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1275 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1276 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1277 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1278 | |
wolfSSL | 0:9d17e4342598 | 1279 | break; |
wolfSSL | 0:9d17e4342598 | 1280 | #endif |
wolfSSL | 0:9d17e4342598 | 1281 | |
wolfSSL | 0:9d17e4342598 | 1282 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1283 | case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1284 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1285 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1286 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1287 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1288 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1289 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1290 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1291 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1292 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1293 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1294 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1295 | |
wolfSSL | 0:9d17e4342598 | 1296 | break; |
wolfSSL | 0:9d17e4342598 | 1297 | #endif |
wolfSSL | 0:9d17e4342598 | 1298 | |
wolfSSL | 0:9d17e4342598 | 1299 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1300 | case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1301 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1302 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1303 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1304 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1305 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1306 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1307 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1308 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1309 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1310 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1311 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1312 | |
wolfSSL | 0:9d17e4342598 | 1313 | break; |
wolfSSL | 0:9d17e4342598 | 1314 | #endif |
wolfSSL | 0:9d17e4342598 | 1315 | |
wolfSSL | 0:9d17e4342598 | 1316 | #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1317 | case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1318 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1319 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1320 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1321 | ssl->specs.kea = rsa_kea; |
wolfSSL | 0:9d17e4342598 | 1322 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1323 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1324 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1325 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1326 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1327 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1328 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1329 | |
wolfSSL | 0:9d17e4342598 | 1330 | break; |
wolfSSL | 0:9d17e4342598 | 1331 | #endif |
wolfSSL | 0:9d17e4342598 | 1332 | |
wolfSSL | 0:9d17e4342598 | 1333 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1334 | case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1335 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1336 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1337 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1338 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1339 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1340 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1341 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1342 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1343 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1344 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1345 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1346 | |
wolfSSL | 0:9d17e4342598 | 1347 | break; |
wolfSSL | 0:9d17e4342598 | 1348 | #endif |
wolfSSL | 0:9d17e4342598 | 1349 | |
wolfSSL | 0:9d17e4342598 | 1350 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA |
wolfSSL | 0:9d17e4342598 | 1351 | case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA : |
wolfSSL | 0:9d17e4342598 | 1352 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1353 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1354 | ssl->specs.mac_algorithm = sha_mac; |
wolfSSL | 0:9d17e4342598 | 1355 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1356 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1357 | ssl->specs.hash_size = SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1358 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1359 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1360 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1361 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1362 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1363 | |
wolfSSL | 0:9d17e4342598 | 1364 | break; |
wolfSSL | 0:9d17e4342598 | 1365 | #endif |
wolfSSL | 0:9d17e4342598 | 1366 | |
wolfSSL | 0:9d17e4342598 | 1367 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1368 | case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1369 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1370 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1371 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1372 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1373 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1374 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1375 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1376 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1377 | ssl->specs.key_size = CAMELLIA_128_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1378 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1379 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1380 | |
wolfSSL | 0:9d17e4342598 | 1381 | break; |
wolfSSL | 0:9d17e4342598 | 1382 | #endif |
wolfSSL | 0:9d17e4342598 | 1383 | |
wolfSSL | 0:9d17e4342598 | 1384 | #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 |
wolfSSL | 0:9d17e4342598 | 1385 | case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 : |
wolfSSL | 0:9d17e4342598 | 1386 | ssl->specs.bulk_cipher_algorithm = cyassl_camellia; |
wolfSSL | 0:9d17e4342598 | 1387 | ssl->specs.cipher_type = block; |
wolfSSL | 0:9d17e4342598 | 1388 | ssl->specs.mac_algorithm = sha256_mac; |
wolfSSL | 0:9d17e4342598 | 1389 | ssl->specs.kea = diffie_hellman_kea; |
wolfSSL | 0:9d17e4342598 | 1390 | ssl->specs.sig_algo = rsa_sa_algo; |
wolfSSL | 0:9d17e4342598 | 1391 | ssl->specs.hash_size = SHA256_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1392 | ssl->specs.pad_size = PAD_SHA; |
wolfSSL | 0:9d17e4342598 | 1393 | ssl->specs.static_ecdh = 0; |
wolfSSL | 0:9d17e4342598 | 1394 | ssl->specs.key_size = CAMELLIA_256_KEY_SIZE; |
wolfSSL | 0:9d17e4342598 | 1395 | ssl->specs.block_size = CAMELLIA_BLOCK_SIZE; |
wolfSSL | 0:9d17e4342598 | 1396 | ssl->specs.iv_size = CAMELLIA_IV_SIZE; |
wolfSSL | 0:9d17e4342598 | 1397 | |
wolfSSL | 0:9d17e4342598 | 1398 | break; |
wolfSSL | 0:9d17e4342598 | 1399 | #endif |
wolfSSL | 0:9d17e4342598 | 1400 | |
wolfSSL | 0:9d17e4342598 | 1401 | default: |
wolfSSL | 0:9d17e4342598 | 1402 | CYASSL_MSG("Unsupported cipher suite, SetCipherSpecs"); |
wolfSSL | 0:9d17e4342598 | 1403 | return UNSUPPORTED_SUITE; |
wolfSSL | 0:9d17e4342598 | 1404 | } /* switch */ |
wolfSSL | 0:9d17e4342598 | 1405 | } /* if ECC / Normal suites else */ |
wolfSSL | 0:9d17e4342598 | 1406 | |
wolfSSL | 0:9d17e4342598 | 1407 | /* set TLS if it hasn't been turned off */ |
wolfSSL | 0:9d17e4342598 | 1408 | if (ssl->version.major == 3 && ssl->version.minor >= 1) { |
wolfSSL | 0:9d17e4342598 | 1409 | #ifndef NO_TLS |
wolfSSL | 0:9d17e4342598 | 1410 | ssl->options.tls = 1; |
wolfSSL | 0:9d17e4342598 | 1411 | ssl->hmac = TLS_hmac; |
wolfSSL | 0:9d17e4342598 | 1412 | if (ssl->version.minor >= 2) |
wolfSSL | 0:9d17e4342598 | 1413 | ssl->options.tls1_1 = 1; |
wolfSSL | 0:9d17e4342598 | 1414 | #endif |
wolfSSL | 0:9d17e4342598 | 1415 | } |
wolfSSL | 0:9d17e4342598 | 1416 | |
wolfSSL | 0:9d17e4342598 | 1417 | #ifdef CYASSL_DTLS |
wolfSSL | 0:9d17e4342598 | 1418 | if (ssl->options.dtls) |
wolfSSL | 0:9d17e4342598 | 1419 | ssl->hmac = TLS_hmac; |
wolfSSL | 0:9d17e4342598 | 1420 | #endif |
wolfSSL | 0:9d17e4342598 | 1421 | |
wolfSSL | 0:9d17e4342598 | 1422 | return 0; |
wolfSSL | 0:9d17e4342598 | 1423 | } |
wolfSSL | 0:9d17e4342598 | 1424 | |
wolfSSL | 0:9d17e4342598 | 1425 | |
wolfSSL | 0:9d17e4342598 | 1426 | enum KeyStuff { |
wolfSSL | 0:9d17e4342598 | 1427 | MASTER_ROUNDS = 3, |
wolfSSL | 0:9d17e4342598 | 1428 | PREFIX = 3, /* up to three letters for master prefix */ |
wolfSSL | 0:9d17e4342598 | 1429 | KEY_PREFIX = 7 /* up to 7 prefix letters for key rounds */ |
wolfSSL | 0:9d17e4342598 | 1430 | |
wolfSSL | 0:9d17e4342598 | 1431 | |
wolfSSL | 0:9d17e4342598 | 1432 | }; |
wolfSSL | 0:9d17e4342598 | 1433 | |
wolfSSL | 0:9d17e4342598 | 1434 | #ifndef NO_OLD_TLS |
wolfSSL | 0:9d17e4342598 | 1435 | /* true or false, zero for error */ |
wolfSSL | 0:9d17e4342598 | 1436 | static int SetPrefix(byte* sha_input, int idx) |
wolfSSL | 0:9d17e4342598 | 1437 | { |
wolfSSL | 0:9d17e4342598 | 1438 | switch (idx) { |
wolfSSL | 0:9d17e4342598 | 1439 | case 0: |
wolfSSL | 0:9d17e4342598 | 1440 | XMEMCPY(sha_input, "A", 1); |
wolfSSL | 0:9d17e4342598 | 1441 | break; |
wolfSSL | 0:9d17e4342598 | 1442 | case 1: |
wolfSSL | 0:9d17e4342598 | 1443 | XMEMCPY(sha_input, "BB", 2); |
wolfSSL | 0:9d17e4342598 | 1444 | break; |
wolfSSL | 0:9d17e4342598 | 1445 | case 2: |
wolfSSL | 0:9d17e4342598 | 1446 | XMEMCPY(sha_input, "CCC", 3); |
wolfSSL | 0:9d17e4342598 | 1447 | break; |
wolfSSL | 0:9d17e4342598 | 1448 | case 3: |
wolfSSL | 0:9d17e4342598 | 1449 | XMEMCPY(sha_input, "DDDD", 4); |
wolfSSL | 0:9d17e4342598 | 1450 | break; |
wolfSSL | 0:9d17e4342598 | 1451 | case 4: |
wolfSSL | 0:9d17e4342598 | 1452 | XMEMCPY(sha_input, "EEEEE", 5); |
wolfSSL | 0:9d17e4342598 | 1453 | break; |
wolfSSL | 0:9d17e4342598 | 1454 | case 5: |
wolfSSL | 0:9d17e4342598 | 1455 | XMEMCPY(sha_input, "FFFFFF", 6); |
wolfSSL | 0:9d17e4342598 | 1456 | break; |
wolfSSL | 0:9d17e4342598 | 1457 | case 6: |
wolfSSL | 0:9d17e4342598 | 1458 | XMEMCPY(sha_input, "GGGGGGG", 7); |
wolfSSL | 0:9d17e4342598 | 1459 | break; |
wolfSSL | 0:9d17e4342598 | 1460 | default: |
wolfSSL | 0:9d17e4342598 | 1461 | CYASSL_MSG("Set Prefix error, bad input"); |
wolfSSL | 0:9d17e4342598 | 1462 | return 0; |
wolfSSL | 0:9d17e4342598 | 1463 | } |
wolfSSL | 0:9d17e4342598 | 1464 | return 1; |
wolfSSL | 0:9d17e4342598 | 1465 | } |
wolfSSL | 0:9d17e4342598 | 1466 | #endif |
wolfSSL | 0:9d17e4342598 | 1467 | |
wolfSSL | 0:9d17e4342598 | 1468 | |
wolfSSL | 0:9d17e4342598 | 1469 | static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, |
wolfSSL | 0:9d17e4342598 | 1470 | byte side, void* heap, int devId) |
wolfSSL | 0:9d17e4342598 | 1471 | { |
wolfSSL | 0:9d17e4342598 | 1472 | #ifdef BUILD_ARC4 |
wolfSSL | 0:9d17e4342598 | 1473 | word32 sz = specs->key_size; |
wolfSSL | 0:9d17e4342598 | 1474 | if (specs->bulk_cipher_algorithm == cyassl_rc4) { |
wolfSSL | 0:9d17e4342598 | 1475 | if (enc->arc4 == NULL) |
wolfSSL | 0:9d17e4342598 | 1476 | enc->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1477 | if (enc->arc4 == NULL) |
wolfSSL | 0:9d17e4342598 | 1478 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1479 | if (dec->arc4 == NULL) |
wolfSSL | 0:9d17e4342598 | 1480 | dec->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1481 | if (dec->arc4 == NULL) |
wolfSSL | 0:9d17e4342598 | 1482 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1483 | #ifdef HAVE_CAVIUM |
wolfSSL | 0:9d17e4342598 | 1484 | if (devId != NO_CAVIUM_DEVICE) { |
wolfSSL | 0:9d17e4342598 | 1485 | if (Arc4InitCavium(enc->arc4, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1486 | CYASSL_MSG("Arc4InitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1487 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1488 | } |
wolfSSL | 0:9d17e4342598 | 1489 | if (Arc4InitCavium(dec->arc4, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1490 | CYASSL_MSG("Arc4InitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1491 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1492 | } |
wolfSSL | 0:9d17e4342598 | 1493 | } |
wolfSSL | 0:9d17e4342598 | 1494 | #endif |
wolfSSL | 0:9d17e4342598 | 1495 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1496 | Arc4SetKey(enc->arc4, keys->client_write_key, sz); |
wolfSSL | 0:9d17e4342598 | 1497 | Arc4SetKey(dec->arc4, keys->server_write_key, sz); |
wolfSSL | 0:9d17e4342598 | 1498 | } |
wolfSSL | 0:9d17e4342598 | 1499 | else { |
wolfSSL | 0:9d17e4342598 | 1500 | Arc4SetKey(enc->arc4, keys->server_write_key, sz); |
wolfSSL | 0:9d17e4342598 | 1501 | Arc4SetKey(dec->arc4, keys->client_write_key, sz); |
wolfSSL | 0:9d17e4342598 | 1502 | } |
wolfSSL | 0:9d17e4342598 | 1503 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1504 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1505 | } |
wolfSSL | 0:9d17e4342598 | 1506 | #endif |
wolfSSL | 0:9d17e4342598 | 1507 | |
wolfSSL | 0:9d17e4342598 | 1508 | #ifdef HAVE_HC128 |
wolfSSL | 0:9d17e4342598 | 1509 | if (specs->bulk_cipher_algorithm == cyassl_hc128) { |
wolfSSL | 0:9d17e4342598 | 1510 | int hcRet; |
wolfSSL | 0:9d17e4342598 | 1511 | if (enc->hc128 == NULL) |
wolfSSL | 0:9d17e4342598 | 1512 | enc->hc128 = |
wolfSSL | 0:9d17e4342598 | 1513 | (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1514 | if (enc->hc128 == NULL) |
wolfSSL | 0:9d17e4342598 | 1515 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1516 | if (dec->hc128 == NULL) |
wolfSSL | 0:9d17e4342598 | 1517 | dec->hc128 = |
wolfSSL | 0:9d17e4342598 | 1518 | (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1519 | if (dec->hc128 == NULL) |
wolfSSL | 0:9d17e4342598 | 1520 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1521 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1522 | hcRet = Hc128_SetKey(enc->hc128, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1523 | keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1524 | if (hcRet != 0) return hcRet; |
wolfSSL | 0:9d17e4342598 | 1525 | hcRet = Hc128_SetKey(dec->hc128, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1526 | keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1527 | if (hcRet != 0) return hcRet; |
wolfSSL | 0:9d17e4342598 | 1528 | } |
wolfSSL | 0:9d17e4342598 | 1529 | else { |
wolfSSL | 0:9d17e4342598 | 1530 | hcRet = Hc128_SetKey(enc->hc128, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1531 | keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1532 | if (hcRet != 0) return hcRet; |
wolfSSL | 0:9d17e4342598 | 1533 | hcRet = Hc128_SetKey(dec->hc128, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1534 | keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1535 | if (hcRet != 0) return hcRet; |
wolfSSL | 0:9d17e4342598 | 1536 | } |
wolfSSL | 0:9d17e4342598 | 1537 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1538 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1539 | } |
wolfSSL | 0:9d17e4342598 | 1540 | #endif |
wolfSSL | 0:9d17e4342598 | 1541 | |
wolfSSL | 0:9d17e4342598 | 1542 | #ifdef BUILD_RABBIT |
wolfSSL | 0:9d17e4342598 | 1543 | if (specs->bulk_cipher_algorithm == cyassl_rabbit) { |
wolfSSL | 0:9d17e4342598 | 1544 | int rabRet; |
wolfSSL | 0:9d17e4342598 | 1545 | if (enc->rabbit == NULL) |
wolfSSL | 0:9d17e4342598 | 1546 | enc->rabbit = |
wolfSSL | 0:9d17e4342598 | 1547 | (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1548 | if (enc->rabbit == NULL) |
wolfSSL | 0:9d17e4342598 | 1549 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1550 | if (dec->rabbit == NULL) |
wolfSSL | 0:9d17e4342598 | 1551 | dec->rabbit = |
wolfSSL | 0:9d17e4342598 | 1552 | (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1553 | if (dec->rabbit == NULL) |
wolfSSL | 0:9d17e4342598 | 1554 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1555 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1556 | rabRet = RabbitSetKey(enc->rabbit, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1557 | keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1558 | if (rabRet != 0) return rabRet; |
wolfSSL | 0:9d17e4342598 | 1559 | rabRet = RabbitSetKey(dec->rabbit, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1560 | keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1561 | if (rabRet != 0) return rabRet; |
wolfSSL | 0:9d17e4342598 | 1562 | } |
wolfSSL | 0:9d17e4342598 | 1563 | else { |
wolfSSL | 0:9d17e4342598 | 1564 | rabRet = RabbitSetKey(enc->rabbit, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1565 | keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1566 | if (rabRet != 0) return rabRet; |
wolfSSL | 0:9d17e4342598 | 1567 | rabRet = RabbitSetKey(dec->rabbit, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1568 | keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1569 | if (rabRet != 0) return rabRet; |
wolfSSL | 0:9d17e4342598 | 1570 | } |
wolfSSL | 0:9d17e4342598 | 1571 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1572 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1573 | } |
wolfSSL | 0:9d17e4342598 | 1574 | #endif |
wolfSSL | 0:9d17e4342598 | 1575 | |
wolfSSL | 0:9d17e4342598 | 1576 | #ifdef BUILD_DES3 |
wolfSSL | 0:9d17e4342598 | 1577 | if (specs->bulk_cipher_algorithm == cyassl_triple_des) { |
wolfSSL | 0:9d17e4342598 | 1578 | int desRet = 0; |
wolfSSL | 0:9d17e4342598 | 1579 | |
wolfSSL | 0:9d17e4342598 | 1580 | if (enc->des3 == NULL) |
wolfSSL | 0:9d17e4342598 | 1581 | enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1582 | if (enc->des3 == NULL) |
wolfSSL | 0:9d17e4342598 | 1583 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1584 | if (dec->des3 == NULL) |
wolfSSL | 0:9d17e4342598 | 1585 | dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1586 | if (dec->des3 == NULL) |
wolfSSL | 0:9d17e4342598 | 1587 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1588 | #ifdef HAVE_CAVIUM |
wolfSSL | 0:9d17e4342598 | 1589 | if (devId != NO_CAVIUM_DEVICE) { |
wolfSSL | 0:9d17e4342598 | 1590 | if (Des3_InitCavium(enc->des3, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1591 | CYASSL_MSG("Des3_InitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1592 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1593 | } |
wolfSSL | 0:9d17e4342598 | 1594 | if (Des3_InitCavium(dec->des3, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1595 | CYASSL_MSG("Des3_InitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1596 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1597 | } |
wolfSSL | 0:9d17e4342598 | 1598 | } |
wolfSSL | 0:9d17e4342598 | 1599 | #endif |
wolfSSL | 0:9d17e4342598 | 1600 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1601 | desRet = Des3_SetKey(enc->des3, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1602 | keys->client_write_IV, DES_ENCRYPTION); |
wolfSSL | 0:9d17e4342598 | 1603 | if (desRet != 0) |
wolfSSL | 0:9d17e4342598 | 1604 | return desRet; |
wolfSSL | 0:9d17e4342598 | 1605 | desRet = Des3_SetKey(dec->des3, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1606 | keys->server_write_IV, DES_DECRYPTION); |
wolfSSL | 0:9d17e4342598 | 1607 | if (desRet != 0) |
wolfSSL | 0:9d17e4342598 | 1608 | return desRet; |
wolfSSL | 0:9d17e4342598 | 1609 | } |
wolfSSL | 0:9d17e4342598 | 1610 | else { |
wolfSSL | 0:9d17e4342598 | 1611 | desRet = Des3_SetKey(enc->des3, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1612 | keys->server_write_IV, DES_ENCRYPTION); |
wolfSSL | 0:9d17e4342598 | 1613 | if (desRet != 0) |
wolfSSL | 0:9d17e4342598 | 1614 | return desRet; |
wolfSSL | 0:9d17e4342598 | 1615 | desRet = Des3_SetKey(dec->des3, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1616 | keys->client_write_IV, DES_DECRYPTION); |
wolfSSL | 0:9d17e4342598 | 1617 | if (desRet != 0) |
wolfSSL | 0:9d17e4342598 | 1618 | return desRet; |
wolfSSL | 0:9d17e4342598 | 1619 | } |
wolfSSL | 0:9d17e4342598 | 1620 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1621 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1622 | } |
wolfSSL | 0:9d17e4342598 | 1623 | #endif |
wolfSSL | 0:9d17e4342598 | 1624 | |
wolfSSL | 0:9d17e4342598 | 1625 | #ifdef BUILD_AES |
wolfSSL | 0:9d17e4342598 | 1626 | if (specs->bulk_cipher_algorithm == cyassl_aes) { |
wolfSSL | 0:9d17e4342598 | 1627 | int aesRet = 0; |
wolfSSL | 0:9d17e4342598 | 1628 | |
wolfSSL | 0:9d17e4342598 | 1629 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1630 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1631 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1632 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1633 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1634 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1635 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1636 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1637 | #ifdef HAVE_CAVIUM |
wolfSSL | 0:9d17e4342598 | 1638 | if (devId != NO_CAVIUM_DEVICE) { |
wolfSSL | 0:9d17e4342598 | 1639 | if (AesInitCavium(enc->aes, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1640 | CYASSL_MSG("AesInitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1641 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1642 | } |
wolfSSL | 0:9d17e4342598 | 1643 | if (AesInitCavium(dec->aes, devId) != 0) { |
wolfSSL | 0:9d17e4342598 | 1644 | CYASSL_MSG("AesInitCavium failed in SetKeys"); |
wolfSSL | 0:9d17e4342598 | 1645 | return CAVIUM_INIT_E; |
wolfSSL | 0:9d17e4342598 | 1646 | } |
wolfSSL | 0:9d17e4342598 | 1647 | } |
wolfSSL | 0:9d17e4342598 | 1648 | #endif |
wolfSSL | 0:9d17e4342598 | 1649 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1650 | aesRet = AesSetKey(enc->aes, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1651 | specs->key_size, keys->client_write_IV, |
wolfSSL | 0:9d17e4342598 | 1652 | AES_ENCRYPTION); |
wolfSSL | 0:9d17e4342598 | 1653 | if (aesRet != 0) |
wolfSSL | 0:9d17e4342598 | 1654 | return aesRet; |
wolfSSL | 0:9d17e4342598 | 1655 | aesRet = AesSetKey(dec->aes, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1656 | specs->key_size, keys->server_write_IV, |
wolfSSL | 0:9d17e4342598 | 1657 | AES_DECRYPTION); |
wolfSSL | 0:9d17e4342598 | 1658 | if (aesRet != 0) |
wolfSSL | 0:9d17e4342598 | 1659 | return aesRet; |
wolfSSL | 0:9d17e4342598 | 1660 | } |
wolfSSL | 0:9d17e4342598 | 1661 | else { |
wolfSSL | 0:9d17e4342598 | 1662 | aesRet = AesSetKey(enc->aes, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1663 | specs->key_size, keys->server_write_IV, |
wolfSSL | 0:9d17e4342598 | 1664 | AES_ENCRYPTION); |
wolfSSL | 0:9d17e4342598 | 1665 | if (aesRet != 0) |
wolfSSL | 0:9d17e4342598 | 1666 | return aesRet; |
wolfSSL | 0:9d17e4342598 | 1667 | aesRet = AesSetKey(dec->aes, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1668 | specs->key_size, keys->client_write_IV, |
wolfSSL | 0:9d17e4342598 | 1669 | AES_DECRYPTION); |
wolfSSL | 0:9d17e4342598 | 1670 | if (aesRet != 0) |
wolfSSL | 0:9d17e4342598 | 1671 | return aesRet; |
wolfSSL | 0:9d17e4342598 | 1672 | } |
wolfSSL | 0:9d17e4342598 | 1673 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1674 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1675 | } |
wolfSSL | 0:9d17e4342598 | 1676 | #endif |
wolfSSL | 0:9d17e4342598 | 1677 | |
wolfSSL | 0:9d17e4342598 | 1678 | #ifdef BUILD_AESGCM |
wolfSSL | 0:9d17e4342598 | 1679 | if (specs->bulk_cipher_algorithm == cyassl_aes_gcm) { |
wolfSSL | 0:9d17e4342598 | 1680 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1681 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1682 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1683 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1684 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1685 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1686 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1687 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1688 | |
wolfSSL | 0:9d17e4342598 | 1689 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1690 | AesGcmSetKey(enc->aes, keys->client_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1691 | XMEMCPY(keys->aead_enc_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1692 | keys->client_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1693 | AesGcmSetKey(dec->aes, keys->server_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1694 | XMEMCPY(keys->aead_dec_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1695 | keys->server_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1696 | } |
wolfSSL | 0:9d17e4342598 | 1697 | else { |
wolfSSL | 0:9d17e4342598 | 1698 | AesGcmSetKey(enc->aes, keys->server_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1699 | XMEMCPY(keys->aead_enc_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1700 | keys->server_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1701 | AesGcmSetKey(dec->aes, keys->client_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1702 | XMEMCPY(keys->aead_dec_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1703 | keys->client_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1704 | } |
wolfSSL | 0:9d17e4342598 | 1705 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1706 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1707 | } |
wolfSSL | 0:9d17e4342598 | 1708 | #endif |
wolfSSL | 0:9d17e4342598 | 1709 | |
wolfSSL | 0:9d17e4342598 | 1710 | #ifdef HAVE_AESCCM |
wolfSSL | 0:9d17e4342598 | 1711 | if (specs->bulk_cipher_algorithm == cyassl_aes_ccm) { |
wolfSSL | 0:9d17e4342598 | 1712 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1713 | enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1714 | if (enc->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1715 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1716 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1717 | dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1718 | if (dec->aes == NULL) |
wolfSSL | 0:9d17e4342598 | 1719 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1720 | |
wolfSSL | 0:9d17e4342598 | 1721 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1722 | AesCcmSetKey(enc->aes, keys->client_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1723 | XMEMCPY(keys->aead_enc_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1724 | keys->client_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1725 | AesCcmSetKey(dec->aes, keys->server_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1726 | XMEMCPY(keys->aead_dec_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1727 | keys->server_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1728 | } |
wolfSSL | 0:9d17e4342598 | 1729 | else { |
wolfSSL | 0:9d17e4342598 | 1730 | AesCcmSetKey(enc->aes, keys->server_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1731 | XMEMCPY(keys->aead_enc_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1732 | keys->server_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1733 | AesCcmSetKey(dec->aes, keys->client_write_key, specs->key_size); |
wolfSSL | 0:9d17e4342598 | 1734 | XMEMCPY(keys->aead_dec_imp_IV, |
wolfSSL | 0:9d17e4342598 | 1735 | keys->client_write_IV, AEAD_IMP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1736 | } |
wolfSSL | 0:9d17e4342598 | 1737 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1738 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1739 | } |
wolfSSL | 0:9d17e4342598 | 1740 | #endif |
wolfSSL | 0:9d17e4342598 | 1741 | |
wolfSSL | 0:9d17e4342598 | 1742 | #ifdef HAVE_CAMELLIA |
wolfSSL | 0:9d17e4342598 | 1743 | if (specs->bulk_cipher_algorithm == cyassl_camellia) { |
wolfSSL | 0:9d17e4342598 | 1744 | if (enc->cam == NULL) |
wolfSSL | 0:9d17e4342598 | 1745 | enc->cam = |
wolfSSL | 0:9d17e4342598 | 1746 | (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1747 | if (enc->cam == NULL) |
wolfSSL | 0:9d17e4342598 | 1748 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1749 | if (dec->cam == NULL) |
wolfSSL | 0:9d17e4342598 | 1750 | dec->cam = |
wolfSSL | 0:9d17e4342598 | 1751 | (Camellia*)XMALLOC(sizeof(Camellia), heap, DYNAMIC_TYPE_CIPHER); |
wolfSSL | 0:9d17e4342598 | 1752 | if (dec->cam == NULL) |
wolfSSL | 0:9d17e4342598 | 1753 | return MEMORY_E; |
wolfSSL | 0:9d17e4342598 | 1754 | if (side == CYASSL_CLIENT_END) { |
wolfSSL | 0:9d17e4342598 | 1755 | CamelliaSetKey(enc->cam, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1756 | specs->key_size, keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1757 | CamelliaSetKey(dec->cam, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1758 | specs->key_size, keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1759 | } |
wolfSSL | 0:9d17e4342598 | 1760 | else { |
wolfSSL | 0:9d17e4342598 | 1761 | CamelliaSetKey(enc->cam, keys->server_write_key, |
wolfSSL | 0:9d17e4342598 | 1762 | specs->key_size, keys->server_write_IV); |
wolfSSL | 0:9d17e4342598 | 1763 | CamelliaSetKey(dec->cam, keys->client_write_key, |
wolfSSL | 0:9d17e4342598 | 1764 | specs->key_size, keys->client_write_IV); |
wolfSSL | 0:9d17e4342598 | 1765 | } |
wolfSSL | 0:9d17e4342598 | 1766 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1767 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1768 | } |
wolfSSL | 0:9d17e4342598 | 1769 | #endif |
wolfSSL | 0:9d17e4342598 | 1770 | |
wolfSSL | 0:9d17e4342598 | 1771 | #ifdef HAVE_NULL_CIPHER |
wolfSSL | 0:9d17e4342598 | 1772 | if (specs->bulk_cipher_algorithm == cyassl_cipher_null) { |
wolfSSL | 0:9d17e4342598 | 1773 | enc->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1774 | dec->setup = 1; |
wolfSSL | 0:9d17e4342598 | 1775 | } |
wolfSSL | 0:9d17e4342598 | 1776 | #endif |
wolfSSL | 0:9d17e4342598 | 1777 | |
wolfSSL | 0:9d17e4342598 | 1778 | keys->sequence_number = 0; |
wolfSSL | 0:9d17e4342598 | 1779 | keys->peer_sequence_number = 0; |
wolfSSL | 0:9d17e4342598 | 1780 | keys->encryptionOn = 0; |
wolfSSL | 0:9d17e4342598 | 1781 | (void)side; |
wolfSSL | 0:9d17e4342598 | 1782 | (void)heap; |
wolfSSL | 0:9d17e4342598 | 1783 | (void)enc; |
wolfSSL | 0:9d17e4342598 | 1784 | (void)dec; |
wolfSSL | 0:9d17e4342598 | 1785 | (void)specs; |
wolfSSL | 0:9d17e4342598 | 1786 | (void)devId; |
wolfSSL | 0:9d17e4342598 | 1787 | |
wolfSSL | 0:9d17e4342598 | 1788 | return 0; |
wolfSSL | 0:9d17e4342598 | 1789 | } |
wolfSSL | 0:9d17e4342598 | 1790 | |
wolfSSL | 0:9d17e4342598 | 1791 | |
wolfSSL | 0:9d17e4342598 | 1792 | /* TLS can call too */ |
wolfSSL | 0:9d17e4342598 | 1793 | int StoreKeys(CYASSL* ssl, const byte* keyData) |
wolfSSL | 0:9d17e4342598 | 1794 | { |
wolfSSL | 0:9d17e4342598 | 1795 | int sz, i = 0; |
wolfSSL | 0:9d17e4342598 | 1796 | int devId = NO_CAVIUM_DEVICE; |
wolfSSL | 0:9d17e4342598 | 1797 | |
wolfSSL | 0:9d17e4342598 | 1798 | #ifdef HAVE_CAVIUM |
wolfSSL | 0:9d17e4342598 | 1799 | devId = ssl->devId; |
wolfSSL | 0:9d17e4342598 | 1800 | #endif |
wolfSSL | 0:9d17e4342598 | 1801 | |
wolfSSL | 0:9d17e4342598 | 1802 | if (ssl->specs.cipher_type != aead) { |
wolfSSL | 0:9d17e4342598 | 1803 | sz = ssl->specs.hash_size; |
wolfSSL | 0:9d17e4342598 | 1804 | XMEMCPY(ssl->keys.client_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1805 | i += sz; |
wolfSSL | 0:9d17e4342598 | 1806 | XMEMCPY(ssl->keys.server_write_MAC_secret,&keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1807 | i += sz; |
wolfSSL | 0:9d17e4342598 | 1808 | } |
wolfSSL | 0:9d17e4342598 | 1809 | sz = ssl->specs.key_size; |
wolfSSL | 0:9d17e4342598 | 1810 | XMEMCPY(ssl->keys.client_write_key, &keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1811 | i += sz; |
wolfSSL | 0:9d17e4342598 | 1812 | XMEMCPY(ssl->keys.server_write_key, &keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1813 | i += sz; |
wolfSSL | 0:9d17e4342598 | 1814 | |
wolfSSL | 0:9d17e4342598 | 1815 | sz = ssl->specs.iv_size; |
wolfSSL | 0:9d17e4342598 | 1816 | XMEMCPY(ssl->keys.client_write_IV, &keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1817 | i += sz; |
wolfSSL | 0:9d17e4342598 | 1818 | XMEMCPY(ssl->keys.server_write_IV, &keyData[i], sz); |
wolfSSL | 0:9d17e4342598 | 1819 | |
wolfSSL | 0:9d17e4342598 | 1820 | #ifdef HAVE_AEAD |
wolfSSL | 0:9d17e4342598 | 1821 | if (ssl->specs.cipher_type == aead) { |
wolfSSL | 0:9d17e4342598 | 1822 | /* Initialize the AES-GCM/CCM explicit IV to a zero. */ |
wolfSSL | 0:9d17e4342598 | 1823 | XMEMSET(ssl->keys.aead_exp_IV, 0, AEAD_EXP_IV_SZ); |
wolfSSL | 0:9d17e4342598 | 1824 | } |
wolfSSL | 0:9d17e4342598 | 1825 | #endif |
wolfSSL | 0:9d17e4342598 | 1826 | |
wolfSSL | 0:9d17e4342598 | 1827 | return SetKeys(&ssl->encrypt, &ssl->decrypt, &ssl->keys, &ssl->specs, |
wolfSSL | 0:9d17e4342598 | 1828 | ssl->options.side, ssl->heap, devId); |
wolfSSL | 0:9d17e4342598 | 1829 | } |
wolfSSL | 0:9d17e4342598 | 1830 | |
wolfSSL | 0:9d17e4342598 | 1831 | #ifndef NO_OLD_TLS |
wolfSSL | 0:9d17e4342598 | 1832 | int DeriveKeys(CYASSL* ssl) |
wolfSSL | 0:9d17e4342598 | 1833 | { |
wolfSSL | 0:9d17e4342598 | 1834 | int length = 2 * ssl->specs.hash_size + |
wolfSSL | 0:9d17e4342598 | 1835 | 2 * ssl->specs.key_size + |
wolfSSL | 0:9d17e4342598 | 1836 | 2 * ssl->specs.iv_size; |
wolfSSL | 0:9d17e4342598 | 1837 | int rounds = (length + MD5_DIGEST_SIZE - 1 ) / MD5_DIGEST_SIZE, i; |
wolfSSL | 0:9d17e4342598 | 1838 | int ret = 0; |
wolfSSL | 0:9d17e4342598 | 1839 | |
wolfSSL | 0:9d17e4342598 | 1840 | byte shaOutput[SHA_DIGEST_SIZE]; |
wolfSSL | 0:9d17e4342598 | 1841 | byte md5Input[SECRET_LEN + SHA_DIGEST_SIZE]; |
wolfSSL | 0:9d17e4342598 | 1842 | byte shaInput[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN]; |
wolfSSL | 0:9d17e4342598 | 1843 | |
wolfSSL | 0:9d17e4342598 | 1844 | Md5 md5; |
wolfSSL | 0:9d17e4342598 | 1845 | Sha sha; |
wolfSSL | 0:9d17e4342598 | 1846 | |
wolfSSL | 0:9d17e4342598 | 1847 | byte keyData[KEY_PREFIX * MD5_DIGEST_SIZE]; /* max size */ |
wolfSSL | 0:9d17e4342598 | 1848 | |
wolfSSL | 0:9d17e4342598 | 1849 | InitMd5(&md5); |
wolfSSL | 0:9d17e4342598 | 1850 | ret = InitSha(&sha); |
wolfSSL | 0:9d17e4342598 | 1851 | if (ret != 0) |
wolfSSL | 0:9d17e4342598 | 1852 | return ret; |
wolfSSL | 0:9d17e4342598 | 1853 | |
wolfSSL | 0:9d17e4342598 | 1854 | XMEMCPY(md5Input, ssl->arrays->masterSecret, SECRET_LEN); |
wolfSSL | 0:9d17e4342598 | 1855 | |
wolfSSL | 0:9d17e4342598 | 1856 | for (i = 0; i < rounds; ++i) { |
wolfSSL | 0:9d17e4342598 | 1857 | int j = i + 1; |
wolfSSL | 0:9d17e4342598 | 1858 | int idx = j; |
wolfSSL | 0:9d17e4342598 | 1859 | |
wolfSSL | 0:9d17e4342598 | 1860 | if (!SetPrefix(shaInput, i)) { |
wolfSSL | 0:9d17e4342598 | 1861 | return PREFIX_ERROR; |
wolfSSL | 0:9d17e4342598 | 1862 | } |
wolfSSL | 0:9d17e4342598 | 1863 | |
wolfSSL | 0:9d17e4342598 | 1864 | XMEMCPY(shaInput + idx, ssl->arrays->masterSecret, SECRET_LEN); |
wolfSSL | 0:9d17e4342598 | 1865 | idx += SECRET_LEN; |
wolfSSL | 0:9d17e4342598 | 1866 | XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN); |
wolfSSL | 0:9d17e4342598 | 1867 | idx += RAN_LEN; |
wolfSSL | 0:9d17e4342598 | 1868 | XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN); |
wolfSSL | 0:9d17e4342598 | 1869 | |
wolfSSL | 0:9d17e4342598 | 1870 | ShaUpdate(&sha, shaInput, (word32)sizeof(shaInput) - KEY_PREFIX + j); |
wolfSSL | 0:9d17e4342598 | 1871 | ShaFinal(&sha, shaOutput); |
wolfSSL | 0:9d17e4342598 | 1872 | |
wolfSSL | 0:9d17e4342598 | 1873 | XMEMCPY(&md5Input[SECRET_LEN], shaOutput, SHA_DIGEST_SIZE); |
wolfSSL | 0:9d17e4342598 | 1874 | Md5Update(&md5, md5Input, sizeof(md5Input)); |
wolfSSL | 0:9d17e4342598 | 1875 | Md5Final(&md5, keyData + i * MD5_DIGEST_SIZE); |
wolfSSL | 0:9d17e4342598 | 1876 | } |
wolfSSL | 0:9d17e4342598 | 1877 | |
wolfSSL | 0:9d17e4342598 | 1878 | return StoreKeys(ssl, keyData); |
wolfSSL | 0:9d17e4342598 | 1879 | } |
wolfSSL | 0:9d17e4342598 | 1880 | |
wolfSSL | 0:9d17e4342598 | 1881 | |
wolfSSL | 0:9d17e4342598 | 1882 | static void CleanPreMaster(CYASSL* ssl) |
wolfSSL | 0:9d17e4342598 | 1883 | { |
wolfSSL | 0:9d17e4342598 | 1884 | int i, sz = ssl->arrays->preMasterSz; |
wolfSSL | 0:9d17e4342598 | 1885 | |
wolfSSL | 0:9d17e4342598 | 1886 | for (i = 0; i < sz; i++) |
wolfSSL | 0:9d17e4342598 | 1887 | ssl->arrays->preMasterSecret[i] = 0; |
wolfSSL | 0:9d17e4342598 | 1888 | |
wolfSSL | 0:9d17e4342598 | 1889 | RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret, sz); |
wolfSSL | 0:9d17e4342598 | 1890 | |
wolfSSL | 0:9d17e4342598 | 1891 | for (i = 0; i < sz; i++) |
wolfSSL | 0:9d17e4342598 | 1892 | ssl->arrays->preMasterSecret[i] = 0; |
wolfSSL | 0:9d17e4342598 | 1893 | |
wolfSSL | 0:9d17e4342598 | 1894 | } |
wolfSSL | 0:9d17e4342598 | 1895 | |
wolfSSL | 0:9d17e4342598 | 1896 | |
wolfSSL | 0:9d17e4342598 | 1897 | /* Create and store the master secret see page 32, 6.1 */ |
wolfSSL | 0:9d17e4342598 | 1898 | static int MakeSslMasterSecret(CYASSL* ssl) |
wolfSSL | 0:9d17e4342598 | 1899 | { |
wolfSSL | 0:9d17e4342598 | 1900 | byte shaOutput[SHA_DIGEST_SIZE]; |
wolfSSL | 0:9d17e4342598 | 1901 | byte md5Input[ENCRYPT_LEN + SHA_DIGEST_SIZE]; |
wolfSSL | 0:9d17e4342598 | 1902 | byte shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN]; |
wolfSSL | 0:9d17e4342598 | 1903 | int i, ret; |
wolfSSL | 0:9d17e4342598 | 1904 | word32 idx; |
wolfSSL | 0:9d17e4342598 | 1905 | word32 pmsSz = ssl->arrays->preMasterSz; |
wolfSSL | 0:9d17e4342598 | 1906 | |
wolfSSL | 0:9d17e4342598 | 1907 | Md5 md5; |
wolfSSL | 0:9d17e4342598 | 1908 | Sha sha; |
wolfSSL | 0:9d17e4342598 | 1909 | |
wolfSSL | 0:9d17e4342598 | 1910 | #ifdef SHOW_SECRETS |
wolfSSL | 0:9d17e4342598 | 1911 | { |
wolfSSL | 0:9d17e4342598 | 1912 | word32 j; |
wolfSSL | 0:9d17e4342598 | 1913 | printf("pre master secret: "); |
wolfSSL | 0:9d17e4342598 | 1914 | for (j = 0; j < pmsSz; j++) |
wolfSSL | 0:9d17e4342598 | 1915 | printf("%02x", ssl->arrays->preMasterSecret[j]); |
wolfSSL | 0:9d17e4342598 | 1916 | printf("\n"); |
wolfSSL | 0:9d17e4342598 | 1917 | } |
wolfSSL | 0:9d17e4342598 | 1918 | #endif |
wolfSSL | 0:9d17e4342598 | 1919 | |
wolfSSL | 0:9d17e4342598 | 1920 | InitMd5(&md5); |
wolfSSL | 0:9d17e4342598 | 1921 | ret = InitSha(&sha); |
wolfSSL | 0:9d17e4342598 | 1922 | if (ret != 0) |
wolfSSL | 0:9d17e4342598 | 1923 | return ret; |
wolfSSL | 0:9d17e4342598 | 1924 | |
wolfSSL | 0:9d17e4342598 | 1925 | XMEMCPY(md5Input, ssl->arrays->preMasterSecret, pmsSz); |
wolfSSL | 0:9d17e4342598 | 1926 | |
wolfSSL | 0:9d17e4342598 | 1927 | for (i = 0; i < MASTER_ROUNDS; ++i) { |
wolfSSL | 0:9d17e4342598 | 1928 | byte prefix[PREFIX]; |
wolfSSL | 0:9d17e4342598 | 1929 | if (!SetPrefix(prefix, i)) { |
wolfSSL | 0:9d17e4342598 | 1930 | return PREFIX_ERROR; |
wolfSSL | 0:9d17e4342598 | 1931 | } |
wolfSSL | 0:9d17e4342598 | 1932 | |
wolfSSL | 0:9d17e4342598 | 1933 | idx = 0; |
wolfSSL | 0:9d17e4342598 | 1934 | XMEMCPY(shaInput, prefix, i + 1); |
wolfSSL | 0:9d17e4342598 | 1935 | idx += i + 1; |
wolfSSL | 0:9d17e4342598 | 1936 | |
wolfSSL | 0:9d17e4342598 | 1937 | XMEMCPY(shaInput + idx, ssl->arrays->preMasterSecret, pmsSz); |
wolfSSL | 0:9d17e4342598 | 1938 | idx += pmsSz; |
wolfSSL | 0:9d17e4342598 | 1939 | XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN); |
wolfSSL | 0:9d17e4342598 | 1940 | idx += RAN_LEN; |
wolfSSL | 0:9d17e4342598 | 1941 | XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN); |
wolfSSL | 0:9d17e4342598 | 1942 | idx += RAN_LEN; |
wolfSSL | 0:9d17e4342598 | 1943 | ShaUpdate(&sha, shaInput, idx); |
wolfSSL | 0:9d17e4342598 | 1944 | ShaFinal(&sha, shaOutput); |
wolfSSL | 0:9d17e4342598 | 1945 | |
wolfSSL | 0:9d17e4342598 | 1946 | idx = pmsSz; /* preSz */ |
wolfSSL | 0:9d17e4342598 | 1947 | XMEMCPY(md5Input + idx, shaOutput, SHA_DIGEST_SIZE); |
wolfSSL | 0:9d17e4342598 | 1948 | idx += SHA_DIGEST_SIZE; |
wolfSSL | 0:9d17e4342598 | 1949 | Md5Update(&md5, md5Input, idx); |
wolfSSL | 0:9d17e4342598 | 1950 | Md5Final(&md5, &ssl->arrays->masterSecret[i * MD5_DIGEST_SIZE]); |
wolfSSL | 0:9d17e4342598 | 1951 | } |
wolfSSL | 0:9d17e4342598 | 1952 | |
wolfSSL | 0:9d17e4342598 | 1953 | #ifdef SHOW_SECRETS |
wolfSSL | 0:9d17e4342598 | 1954 | { |
wolfSSL | 0:9d17e4342598 | 1955 | word32 j; |
wolfSSL | 0:9d17e4342598 | 1956 | printf("master secret: "); |
wolfSSL | 0:9d17e4342598 | 1957 | for (j = 0; j < SECRET_LEN; j++) |
wolfSSL | 0:9d17e4342598 | 1958 | printf("%02x", ssl->arrays->masterSecret[j]); |
wolfSSL | 0:9d17e4342598 | 1959 | printf("\n"); |
wolfSSL | 0:9d17e4342598 | 1960 | } |
wolfSSL | 0:9d17e4342598 | 1961 | #endif |
wolfSSL | 0:9d17e4342598 | 1962 | |
wolfSSL | 0:9d17e4342598 | 1963 | ret = DeriveKeys(ssl); |
wolfSSL | 0:9d17e4342598 | 1964 | CleanPreMaster(ssl); |
wolfSSL | 0:9d17e4342598 | 1965 | |
wolfSSL | 0:9d17e4342598 | 1966 | return ret; |
wolfSSL | 0:9d17e4342598 | 1967 | } |
wolfSSL | 0:9d17e4342598 | 1968 | #endif |
wolfSSL | 0:9d17e4342598 | 1969 | |
wolfSSL | 0:9d17e4342598 | 1970 | |
wolfSSL | 0:9d17e4342598 | 1971 | /* Master wrapper, doesn't use SSL stack space in TLS mode */ |
wolfSSL | 0:9d17e4342598 | 1972 | int MakeMasterSecret(CYASSL* ssl) |
wolfSSL | 0:9d17e4342598 | 1973 | { |
wolfSSL | 0:9d17e4342598 | 1974 | #ifdef NO_OLD_TLS |
wolfSSL | 0:9d17e4342598 | 1975 | return MakeTlsMasterSecret(ssl); |
wolfSSL | 0:9d17e4342598 | 1976 | #elif !defined(NO_TLS) |
wolfSSL | 0:9d17e4342598 | 1977 | if (ssl->options.tls) return MakeTlsMasterSecret(ssl); |
wolfSSL | 0:9d17e4342598 | 1978 | #endif |
wolfSSL | 0:9d17e4342598 | 1979 | |
wolfSSL | 0:9d17e4342598 | 1980 | #ifndef NO_OLD_TLS |
wolfSSL | 0:9d17e4342598 | 1981 | return MakeSslMasterSecret(ssl); |
wolfSSL | 0:9d17e4342598 | 1982 | #endif |
wolfSSL | 0:9d17e4342598 | 1983 | } |
wolfSSL | 0:9d17e4342598 | 1984 |