2011-02-05 11:14:47 -08:00
|
|
|
/* keys.c
|
|
|
|
|
*
|
2025-01-21 09:55:03 -07:00
|
|
|
* Copyright (C) 2006-2025 wolfSSL Inc.
|
2011-02-05 11:14:47 -08:00
|
|
|
*
|
2016-03-17 16:02:13 -06:00
|
|
|
* This file is part of wolfSSL.
|
2011-02-05 11:14:47 -08:00
|
|
|
*
|
2014-12-19 11:27:01 -07:00
|
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
2011-02-05 11:14:47 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2025-07-10 16:01:52 -06:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2011-02-05 11:14:47 -08:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2014-12-19 11:27:01 -07:00
|
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
2011-02-05 11:14:47 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2016-03-17 16:02:13 -06:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
2011-02-05 11:14:47 -08:00
|
|
|
*/
|
|
|
|
|
|
2016-03-17 16:02:13 -06:00
|
|
|
|
2015-02-17 14:20:10 -07:00
|
|
|
/* Name change compatibility layer no longer needs to be included here */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2025-04-04 18:44:12 -05:00
|
|
|
#include <wolfssl/wolfcrypt/libwolfssl_sources.h>
|
2013-04-10 11:04:29 -07:00
|
|
|
|
2024-12-10 14:10:15 -08:00
|
|
|
#if !defined(WOLFCRYPT_ONLY) && !defined(NO_TLS)
|
2015-09-10 16:24:25 -07:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
#include <wolfssl/internal.h>
|
|
|
|
|
#include <wolfssl/error-ssl.h>
|
2014-07-01 14:16:44 -06:00
|
|
|
#if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST)
|
2019-11-18 12:14:34 -08:00
|
|
|
#ifndef NO_STDIO_FILESYSTEM
|
2012-11-01 11:23:42 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
#endif
|
|
|
|
|
|
2023-08-12 17:28:24 +09:00
|
|
|
#if defined(WOLFSSL_RENESAS_FSPSM_TLS) || defined(WOLFSSL_RENESAS_TSIP_TLS)
|
2021-11-24 19:11:16 +09:00
|
|
|
#include <wolfssl/wolfcrypt/port/Renesas/renesas_cmn.h>
|
2021-10-30 20:21:21 +09:00
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
int SetCipherSpecs(WOLFSSL* ssl)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2023-03-09 19:00:25 +01:00
|
|
|
int ret = GetCipherSpec(ssl->options.side, ssl->options.cipherSuite0,
|
2022-12-21 15:52:55 +01:00
|
|
|
ssl->options.cipherSuite, &ssl->specs,
|
|
|
|
|
&ssl->options);
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
/* set TLS if it hasn't been turned off */
|
|
|
|
|
if (ssl->version.major == SSLv3_MAJOR &&
|
|
|
|
|
ssl->version.minor >= TLSv1_MINOR) {
|
|
|
|
|
#ifndef NO_TLS
|
|
|
|
|
ssl->options.tls = 1;
|
|
|
|
|
#if !defined(WOLFSSL_NO_TLS12) && !defined(WOLFSSL_AEAD_ONLY)
|
2023-08-12 17:28:24 +09:00
|
|
|
#if !defined(WOLFSSL_RENESAS_FSPSM_TLS) && \
|
2022-12-21 15:52:55 +01:00
|
|
|
!defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
|
|
ssl->hmac = TLS_hmac;
|
|
|
|
|
#else
|
|
|
|
|
ssl->hmac = Renesas_cmn_TLS_hmac;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
if (ssl->version.minor >= TLSv1_1_MINOR) {
|
|
|
|
|
ssl->options.tls1_1 = 1;
|
|
|
|
|
if (ssl->version.minor >= TLSv1_3_MINOR)
|
|
|
|
|
ssl->options.tls1_3 = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_ENCRYPT_THEN_MAC) && !defined(WOLFSSL_AEAD_ONLY)
|
|
|
|
|
if (IsAtLeastTLSv1_3(ssl->version) || ssl->specs.cipher_type != block)
|
|
|
|
|
ssl->options.encThenMac = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(WOLFSSL_DTLS)
|
|
|
|
|
if (ssl->options.dtls && ssl->version.major == DTLS_MAJOR) {
|
|
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2023-08-12 17:28:24 +09:00
|
|
|
#if !defined(WOLFSSL_RENESAS_FSPSM_TLS) && \
|
2022-12-21 15:52:55 +01:00
|
|
|
!defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
|
|
ssl->hmac = TLS_hmac;
|
|
|
|
|
#else
|
|
|
|
|
ssl->hmac = Renesas_cmn_TLS_hmac;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
ssl->options.tls = 1;
|
|
|
|
|
ssl->options.tls1_1 = 1; /* DTLS 1.0 == TLS 1.1 */
|
|
|
|
|
#ifdef WOLFSSL_DTLS13
|
|
|
|
|
if (ssl->version.minor <= DTLSv1_3_MINOR)
|
|
|
|
|
ssl->options.tls1_3 = 1;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-03-09 19:00:25 +01:00
|
|
|
* Populate specs with the specification of the chosen ciphersuite. If opts is
|
|
|
|
|
* not NULL then the appropriate options will also be set.
|
2022-12-21 15:52:55 +01:00
|
|
|
*
|
|
|
|
|
* @param side [in] WOLFSSL_SERVER_END or WOLFSSL_CLIENT_END
|
|
|
|
|
* @param cipherSuite0 [in]
|
|
|
|
|
* @param cipherSuite [in]
|
|
|
|
|
* @param specs [out] CipherSpecs
|
|
|
|
|
* @param opts [in/out] Options can be NULL
|
2024-06-21 10:36:57 -06:00
|
|
|
* @return int (less than 0 on fail, 0 on success)
|
2022-12-21 15:52:55 +01:00
|
|
|
*/
|
2023-03-09 19:00:25 +01:00
|
|
|
int GetCipherSpec(word16 side, byte cipherSuite0, byte cipherSuite,
|
2022-12-21 15:52:55 +01:00
|
|
|
CipherSpecs* specs, Options* opts)
|
|
|
|
|
{
|
|
|
|
|
word16 havePSK = 0;
|
|
|
|
|
(void)havePSK;
|
|
|
|
|
(void)side;
|
|
|
|
|
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
havePSK = opts->havePSK;
|
|
|
|
|
#endif
|
2014-12-19 11:27:01 -07:00
|
|
|
#ifndef NO_WOLFSSL_CLIENT
|
2022-12-21 15:52:55 +01:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-04-10 14:11:30 -07:00
|
|
|
/* server side verified before SetCipherSpecs call */
|
2022-12-21 15:52:55 +01:00
|
|
|
if (VerifyClientSuite(havePSK, cipherSuite0, cipherSuite) != 1) {
|
2019-12-24 12:29:33 -06:00
|
|
|
WOLFSSL_MSG("SetCipherSpecs() client has an unusable suite");
|
2022-08-02 13:47:46 -07:00
|
|
|
WOLFSSL_ERROR_VERBOSE(UNSUPPORTED_SUITE);
|
2014-04-10 14:11:30 -07:00
|
|
|
return UNSUPPORTED_SUITE;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-19 11:27:01 -07:00
|
|
|
#endif /* NO_WOLFSSL_CLIENT */
|
2014-07-01 14:16:44 -06:00
|
|
|
|
2025-04-22 14:43:01 -05:00
|
|
|
/* Initialize specs */
|
|
|
|
|
XMEMSET(specs, 0, sizeof(CipherSpecs));
|
|
|
|
|
|
2014-07-01 14:16:44 -06:00
|
|
|
/* Chacha extensions, 0xcc */
|
2022-12-21 15:52:55 +01:00
|
|
|
if (cipherSuite0 == CHACHA_BYTE) {
|
2016-02-01 14:43:17 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
switch (cipherSuite) {
|
2016-01-27 14:03:05 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 1; /* use old poly1305 padding */
|
2016-01-27 14:03:05 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_OLD_POLY1305_SHA256
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_CHACHA20_OLD_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 1; /* use old poly1305 padding */
|
2016-01-27 14:03:05 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_CHACHA20_OLD_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 1; /* use old poly1305 padding */
|
2016-01-27 14:03:05 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2014-07-10 16:35:56 -06:00
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
2014-07-01 14:16:44 -06:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 16:35:56 -06:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
2014-07-10 16:35:56 -06:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
2014-07-10 16:35:56 -06:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2016-02-04 09:50:29 -07:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_PSK_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
2016-02-04 09:50:29 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL) {
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
|
|
|
|
}
|
2016-02-04 09:50:29 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecdhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
2016-02-04 09:50:29 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL) {
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
|
|
|
|
}
|
2016-02-04 09:50:29 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
2016-02-04 09:50:29 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL) {
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
|
|
|
|
}
|
2016-02-04 09:50:29 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
2014-07-01 14:16:44 -06:00
|
|
|
default:
|
2014-12-19 11:27:01 -07:00
|
|
|
WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ChaCha");
|
2014-07-01 14:16:44 -06:00
|
|
|
return UNSUPPORTED_SUITE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 08:26:55 +10:00
|
|
|
/* ECC extensions, AES-CCM or TLS 1.3 Integrity-only */
|
2022-12-21 15:52:55 +01:00
|
|
|
if (cipherSuite0 == ECC_BYTE) {
|
2016-02-01 14:43:17 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
switch (cipherSuite) {
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2020-02-19 18:07:45 +10:00
|
|
|
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_CURVE448)
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2013-03-04 13:25:46 -08:00
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2013-03-04 13:25:46 -08:00
|
|
|
|
2018-07-23 10:20:18 +10:00
|
|
|
break;
|
2013-03-04 13:25:46 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2013-03-04 13:25:46 -08:00
|
|
|
|
2018-07-23 10:20:18 +10:00
|
|
|
break;
|
2013-03-04 13:25:46 -08:00
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
/* DES_IV_SIZE is incorrectly 16 in FIPS v2. It should be 8, same as the
|
|
|
|
|
* block size. */
|
|
|
|
|
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#else
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_RC4_128_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-06-18 15:57:37 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-07-23 10:20:18 +10:00
|
|
|
#ifdef BUILD_TLS_ECDHE_PSK_WITH_NULL_SHA256
|
|
|
|
|
case TLS_ECDHE_PSK_WITH_NULL_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecdhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2018-07-23 10:20:18 +10:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecdhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2018-07-23 10:20:18 +10:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-19 18:07:45 +10:00
|
|
|
#endif /* HAVE_ECC || HAVE_CURVE25519 || HAVE_CURVE448 */
|
2018-07-23 10:20:18 +10:00
|
|
|
|
2020-02-19 18:07:45 +10:00
|
|
|
#if defined(HAVE_ECC) || (defined(HAVE_CURVE25519) && defined(HAVE_ED25519)) \
|
|
|
|
|
|| (defined(HAVE_CURVE448) && defined(HAVE_ED448))
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#else
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#endif
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-06-18 15:57:37 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-06-13 14:39:41 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2016-06-13 14:39:41 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-03-22 11:30:12 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
2013-01-21 15:19:45 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-03-22 11:30:12 -07:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
2013-01-21 15:19:45 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
2016-02-01 14:43:17 -07:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_NULL_SHA
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_NULL_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2016-02-01 14:43:17 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2016-02-03 13:44:13 -07:00
|
|
|
|
2020-02-19 18:07:45 +10:00
|
|
|
#endif /* HAVE_ECC || (CURVE25519 && ED25519) || (CURVE448 && ED448) */
|
2016-02-03 13:44:13 -07:00
|
|
|
|
2018-07-23 10:20:18 +10:00
|
|
|
#if defined(HAVE_ECC)
|
2016-02-03 15:25:34 -07:00
|
|
|
|
2018-07-23 10:20:18 +10:00
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
|
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2016-02-03 15:25:34 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#else
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#endif
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA
|
|
|
|
|
case TLS_ECDH_RSA_WITH_RC4_128_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#else
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#endif
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_RC4_128_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 1;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2018-07-23 10:20:18 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-07-06 13:05:39 -04:00
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aria_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = ARIA_128_KEY_SIZE;
|
|
|
|
|
specs->block_size = ARIA_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = ARIA_GCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aria_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = ecc_dsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = ARIA_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = ARIA_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = ARIA_GCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-15 15:20:30 -08:00
|
|
|
#endif /* HAVE_ECC */
|
|
|
|
|
|
2013-03-22 11:30:12 -07:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8
|
|
|
|
|
case TLS_RSA_WITH_AES_128_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
2013-01-15 15:20:30 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-03-22 11:30:12 -07:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8
|
|
|
|
|
case TLS_RSA_WITH_AES_256_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8
|
|
|
|
|
case TLS_PSK_WITH_AES_128_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2013-03-22 11:30:12 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8
|
|
|
|
|
case TLS_PSK_WITH_AES_256_CCM_8 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2013-03-22 11:30:12 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2013-01-15 15:20:30 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
2012-06-18 15:57:37 -07:00
|
|
|
|
2014-07-10 11:18:49 -06:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_128_CCM
|
|
|
|
|
case TLS_PSK_WITH_AES_128_CCM :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_256_CCM
|
|
|
|
|
case TLS_PSK_WITH_AES_256_CCM :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_128_CCM :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_256_CCM :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_IMP_IV_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-26 08:26:55 +10:00
|
|
|
#if defined(WOLFSSL_TLS13) && defined(HAVE_NULL_CIPHER)
|
|
|
|
|
#ifdef BUILD_TLS_SHA256_SHA256
|
|
|
|
|
case TLS_SHA256_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = HMAC_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = WC_SHA256_DIGEST_SIZE;
|
2019-07-26 08:26:55 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_SHA384_SHA384
|
|
|
|
|
case TLS_SHA384_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = HMAC_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = WC_SHA384_DIGEST_SIZE;
|
2019-07-26 08:26:55 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
default:
|
2014-12-19 11:27:01 -07:00
|
|
|
WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC");
|
2011-02-05 11:14:47 -08:00
|
|
|
return UNSUPPORTED_SUITE;
|
2011-07-12 14:20:51 -07:00
|
|
|
} /* switch */
|
|
|
|
|
} /* if */
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
/* TLSi v1.3 cipher suites, 0x13 */
|
2022-12-21 15:52:55 +01:00
|
|
|
if (cipherSuite0 == TLS13_BYTE) {
|
|
|
|
|
switch (cipherSuite) {
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_TLS13
|
|
|
|
|
#ifdef BUILD_TLS_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_CHACHA20_POLY1305_SHA256
|
|
|
|
|
case TLS_CHACHA20_POLY1305_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_chacha;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CHACHA20_256_KEY_SIZE;
|
|
|
|
|
specs->block_size = CHACHA20_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = CHACHA20_IV_SIZE;
|
|
|
|
|
specs->aead_mac_size = POLY1305_AUTH_SZ;
|
|
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->oldPoly = 0; /* use recent padding RFC */
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_AES_128_CCM_SHA256
|
|
|
|
|
case TLS_AES_128_CCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_NONCE_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_16_AUTH_SZ;
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_AES_128_CCM_8_SHA256
|
|
|
|
|
case TLS_AES_128_CCM_8_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = AESCCM_NONCE_SZ;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->aead_mac_size = AES_CCM_8_AUTH_SZ;
|
2016-11-24 01:31:07 +10:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
#endif /* WOLFSSL_TLS13 */
|
2021-01-12 12:25:52 +10:00
|
|
|
default:
|
|
|
|
|
break;
|
2016-11-24 01:31:07 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (cipherSuite0 == ECDHE_PSK_BYTE) {
|
2022-05-17 14:23:53 -04:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
switch (cipherSuite) {
|
2022-05-17 14:23:53 -04:00
|
|
|
|
|
|
|
|
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_CURVE448)
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = ecdhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2022-05-17 14:23:53 -04:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2022-05-17 14:23:53 -04:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-10 11:48:59 +10:00
|
|
|
if (cipherSuite0 == SM_BYTE) {
|
|
|
|
|
|
|
|
|
|
switch (cipherSuite) {
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_SM4_CBC_SM3
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_SM4_CBC_SM3 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_sm4_cbc;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sm3_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = sm2_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SM3_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = SM4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = SM4_IV_SIZE;
|
|
|
|
|
specs->block_size = SM4_BLOCK_SIZE;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_SM4_GCM_SM3
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_SM4_GCM_SM3 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_sm4_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sm3_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = sm2_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SM3_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = SM4_KEY_SIZE;
|
|
|
|
|
specs->block_size = SM4_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = GCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = SM4_GCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_ECDHE_ECDSA_WITH_SM4_CCM_SM3
|
|
|
|
|
case TLS_ECDHE_ECDSA_WITH_SM4_CCM_SM3 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_sm4_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sm3_mac;
|
|
|
|
|
specs->kea = ecc_diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = sm2_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SM3_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = SM4_KEY_SIZE;
|
|
|
|
|
specs->block_size = SM4_BLOCK_SIZE;
|
2024-02-06 14:51:14 -05:00
|
|
|
specs->iv_size = CCM_IMP_IV_SZ;
|
2023-02-10 11:48:59 +10:00
|
|
|
specs->aead_mac_size = SM4_CCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-17 14:23:53 -04:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (cipherSuite0 != ECC_BYTE &&
|
|
|
|
|
cipherSuite0 != ECDHE_PSK_BYTE &&
|
|
|
|
|
cipherSuite0 != CHACHA_BYTE &&
|
2023-02-10 11:48:59 +10:00
|
|
|
#if defined(WOLFSSL_SM2) && defined(WOLFSSL_SM3) && \
|
|
|
|
|
(defined(WOLFSSL_SM4_CBC) || defined(WOLFSSL_SM4_GCM) || \
|
|
|
|
|
defined(WOLFSSL_SM4_CCM))
|
|
|
|
|
cipherSuite0 != SM_BYTE &&
|
|
|
|
|
#endif
|
2022-12-21 15:52:55 +01:00
|
|
|
cipherSuite0 != TLS13_BYTE) { /* normal suites */
|
|
|
|
|
switch (cipherSuite) {
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2023-02-10 11:48:59 +10:00
|
|
|
#ifdef BUILD_TLS_SM4_GCM_SM3
|
|
|
|
|
case TLS_SM4_GCM_SM3 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_sm4_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sm3_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2023-02-10 11:48:59 +10:00
|
|
|
specs->hash_size = WC_SM3_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = SM4_KEY_SIZE;
|
|
|
|
|
specs->block_size = SM4_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = SM4_GCM_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = SM4_GCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_SM4_CCM_SM3
|
|
|
|
|
case TLS_SM4_CCM_SM3 :
|
|
|
|
|
specs->bulk_cipher_algorithm = wolfssl_sm4_ccm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sm3_mac;
|
2025-08-12 16:35:38 -07:00
|
|
|
specs->kea = any_kea;
|
|
|
|
|
specs->sig_algo = any_sa_algo;
|
2023-02-10 11:48:59 +10:00
|
|
|
specs->hash_size = WC_SM3_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = SM4_KEY_SIZE;
|
|
|
|
|
specs->block_size = SM4_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = SM4_CCM_NONCE_SZ;
|
|
|
|
|
specs->aead_mac_size = SM4_CCM_AUTH_SZ;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA
|
|
|
|
|
case SSL_RSA_WITH_RC4_128_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5
|
|
|
|
|
case SSL_RSA_WITH_RC4_128_MD5 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_rc4;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = md5_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_MD5_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_MD5;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = RC4_KEY_SIZE;
|
|
|
|
|
specs->iv_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case SSL_RSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#if defined(HAVE_FIPS) && defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_BLOCK_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#else
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2021-07-22 18:17:41 -07:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_RSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-03-04 11:13:28 -08:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_RSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-03-04 11:13:28 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-07-10 14:32:14 -05:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_NULL_MD5
|
|
|
|
|
case TLS_RSA_WITH_NULL_MD5 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = md5_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_MD5_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_MD5;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2019-07-10 14:32:14 -05:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-10-19 20:52:22 -07:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_NULL_SHA
|
|
|
|
|
case TLS_RSA_WITH_NULL_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2012-10-19 20:52:22 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_NULL_SHA256
|
|
|
|
|
case TLS_RSA_WITH_NULL_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2012-10-19 20:52:22 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_RSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-03-04 11:13:28 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256
|
|
|
|
|
case TLS_RSA_WITH_AES_256_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 11:18:49 -06:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_PSK_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_PSK_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
2019-01-18 14:08:58 -08:00
|
|
|
|
2018-04-20 10:35:37 -07:00
|
|
|
#ifdef BUILD_TLS_DH_anon_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_DH_anon_WITH_AES_256_GCM_SHA384:
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2018-04-20 10:35:37 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingAnon_cipher = 1;
|
2018-04-20 10:35:37 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
2014-07-10 11:18:49 -06:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-20 14:52:17 -08:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_PSK_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2012-11-20 14:52:17 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2012-11-20 14:52:17 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 11:18:49 -06:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_PSK_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
|
|
|
|
|
case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_PSK_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_PSK_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
2011-04-26 09:32:18 -07:00
|
|
|
|
2012-11-20 14:52:17 -08:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_NULL_SHA256
|
|
|
|
|
case TLS_PSK_WITH_NULL_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2012-11-20 14:52:17 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2012-11-20 14:52:17 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 11:18:49 -06:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_NULL_SHA384
|
|
|
|
|
case TLS_PSK_WITH_NULL_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-10-19 10:37:21 -07:00
|
|
|
#ifdef BUILD_TLS_PSK_WITH_NULL_SHA
|
|
|
|
|
case TLS_PSK_WITH_NULL_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2012-10-19 10:37:21 -07:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2012-10-19 10:37:21 -07:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-07-10 11:18:49 -06:00
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256
|
|
|
|
|
case TLS_DHE_PSK_WITH_NULL_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384
|
|
|
|
|
case TLS_DHE_PSK_WITH_NULL_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = dhe_psk_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = 0;
|
|
|
|
|
specs->block_size = 0;
|
|
|
|
|
specs->iv_size = 0;
|
2014-07-10 11:18:49 -06:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingPSK_cipher = 1;
|
2014-07-10 11:18:49 -06:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-26 09:32:18 -07:00
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-04-26 09:32:18 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-04-29 09:17:12 -06:00
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
|
|
|
|
|
case TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_triple_des;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = DES3_KEY_SIZE;
|
|
|
|
|
specs->block_size = DES_BLOCK_SIZE;
|
|
|
|
|
specs->iv_size = DES_IV_SIZE;
|
2016-04-29 09:17:12 -06:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-26 09:32:18 -07:00
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-04-26 09:32:18 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-06-18 15:57:37 -07:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_RSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_RSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-28 23:09:13 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-28 23:09:13 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
|
|
|
|
|
case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes_gcm;
|
|
|
|
|
specs->cipher_type = aead;
|
|
|
|
|
specs->mac_algorithm = sha384_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA384_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AESGCM_IMP_IV_SZ;
|
|
|
|
|
specs->aead_mac_size = AES_GCM_AUTH_SZ;
|
2012-06-18 15:57:37 -07:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-01-21 10:53:42 -08:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
|
|
|
|
|
case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2017-04-06 14:42:42 -06:00
|
|
|
|
2013-01-21 10:53:42 -08:00
|
|
|
#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
|
|
|
|
|
case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
|
|
|
|
|
case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
|
|
|
|
|
case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = rsa_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
|
|
|
|
|
case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
|
|
|
|
|
case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
|
|
|
|
|
case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_camellia;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = rsa_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = CAMELLIA_256_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_CAMELLIA_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = CAMELLIA_IV_SIZE;
|
2013-01-21 10:53:42 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-01 11:44:32 -08:00
|
|
|
#ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA
|
|
|
|
|
case TLS_DH_anon_WITH_AES_128_CBC_SHA :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_aes;
|
|
|
|
|
specs->cipher_type = block;
|
|
|
|
|
specs->mac_algorithm = sha_mac;
|
|
|
|
|
specs->kea = diffie_hellman_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
|
|
|
|
specs->static_ecdh = 0;
|
|
|
|
|
specs->key_size = AES_128_KEY_SIZE;
|
2024-11-22 19:27:56 -06:00
|
|
|
specs->block_size = WC_AES_BLOCK_SIZE;
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->iv_size = AES_IV_SIZE;
|
2014-12-01 11:44:32 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (opts != NULL)
|
|
|
|
|
opts->usingAnon_cipher = 1;
|
2014-12-01 11:44:32 -08:00
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-07 14:52:41 -08:00
|
|
|
#ifdef BUILD_WDM_WITH_NULL_SHA256
|
|
|
|
|
case WDM_WITH_NULL_SHA256 :
|
2022-12-21 15:52:55 +01:00
|
|
|
specs->bulk_cipher_algorithm = wolfssl_cipher_null;
|
|
|
|
|
specs->cipher_type = stream;
|
|
|
|
|
specs->mac_algorithm = sha256_mac;
|
|
|
|
|
specs->kea = no_kea;
|
|
|
|
|
specs->sig_algo = anonymous_sa_algo;
|
|
|
|
|
specs->hash_size = WC_SHA256_DIGEST_SIZE;
|
|
|
|
|
specs->pad_size = PAD_SHA;
|
2016-12-07 14:52:41 -08:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
default:
|
2014-12-19 11:27:01 -07:00
|
|
|
WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs");
|
2022-08-02 13:47:46 -07:00
|
|
|
WOLFSSL_ERROR_VERBOSE(UNSUPPORTED_SUITE);
|
2011-02-05 11:14:47 -08:00
|
|
|
return UNSUPPORTED_SUITE;
|
2011-07-12 14:20:51 -07:00
|
|
|
} /* switch */
|
|
|
|
|
} /* if ECC / Normal suites else */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2022-12-21 15:52:55 +01:00
|
|
|
if (specs->sig_algo == anonymous_sa_algo && opts != NULL) {
|
2022-03-14 12:03:49 +10:00
|
|
|
/* CLIENT/SERVER: No peer authentication to be performed. */
|
2022-12-21 15:52:55 +01:00
|
|
|
opts->peerAuthGood = 1;
|
2022-03-14 12:03:49 +10:00
|
|
|
}
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum KeyStuff {
|
|
|
|
|
MASTER_ROUNDS = 3,
|
|
|
|
|
PREFIX = 3, /* up to three letters for master prefix */
|
2015-12-15 11:54:03 -08:00
|
|
|
KEY_PREFIX = 9 /* up to 9 prefix letters for key rounds */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2012-11-26 18:40:43 -08:00
|
|
|
#ifndef NO_OLD_TLS
|
2011-02-05 11:14:47 -08:00
|
|
|
/* true or false, zero for error */
|
2011-05-25 10:25:05 -07:00
|
|
|
static int SetPrefix(byte* sha_input, int idx)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2011-05-25 10:25:05 -07:00
|
|
|
switch (idx) {
|
2011-02-05 11:14:47 -08:00
|
|
|
case 0:
|
|
|
|
|
XMEMCPY(sha_input, "A", 1);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
XMEMCPY(sha_input, "BB", 2);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
XMEMCPY(sha_input, "CCC", 3);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
XMEMCPY(sha_input, "DDDD", 4);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
XMEMCPY(sha_input, "EEEEE", 5);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
XMEMCPY(sha_input, "FFFFFF", 6);
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
XMEMCPY(sha_input, "GGGGGGG", 7);
|
|
|
|
|
break;
|
2015-12-15 11:54:03 -08:00
|
|
|
case 7:
|
|
|
|
|
XMEMCPY(sha_input, "HHHHHHHH", 8);
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
XMEMCPY(sha_input, "IIIIIIIII", 9);
|
|
|
|
|
break;
|
2011-02-05 11:14:47 -08:00
|
|
|
default:
|
2014-12-19 11:27:01 -07:00
|
|
|
WOLFSSL_MSG("Set Prefix error, bad input");
|
2017-04-06 14:42:42 -06:00
|
|
|
return 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-11-26 18:40:43 -08:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
|
2024-07-26 14:14:30 +10:00
|
|
|
int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
|
2019-07-26 08:26:55 +10:00
|
|
|
int side, void* heap, int devId, WC_RNG* rng, int tls13)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2019-02-13 10:13:14 -08:00
|
|
|
(void)rng;
|
2019-07-26 08:26:55 +10:00
|
|
|
(void)tls13;
|
2019-02-13 10:13:14 -08:00
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_ARC4
|
2014-12-18 14:23:33 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_rc4) {
|
2019-02-13 10:13:14 -08:00
|
|
|
word32 sz = specs->key_size;
|
2020-04-08 09:46:22 +10:00
|
|
|
if (enc && enc->arc4 == NULL) {
|
2013-05-21 16:21:49 -07:00
|
|
|
enc->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER);
|
2020-04-08 09:46:22 +10:00
|
|
|
if (enc->arc4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
if (dec && dec->arc4 == NULL) {
|
2013-05-21 16:21:49 -07:00
|
|
|
dec->arc4 = (Arc4*)XMALLOC(sizeof(Arc4), heap, DYNAMIC_TYPE_CIPHER);
|
2020-04-08 09:46:22 +10:00
|
|
|
if (dec->arc4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_Arc4Init(enc->arc4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Arc4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
2013-02-01 12:21:38 -08:00
|
|
|
}
|
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (dec) {
|
|
|
|
|
if (wc_Arc4Init(dec->arc4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Arc4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
2014-12-17 09:58:11 -07:00
|
|
|
wc_Arc4SetKey(enc->arc4, keys->client_write_key, sz);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec)
|
2014-12-17 09:58:11 -07:00
|
|
|
wc_Arc4SetKey(dec->arc4, keys->server_write_key, sz);
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
2014-12-17 09:58:11 -07:00
|
|
|
wc_Arc4SetKey(enc->arc4, keys->server_write_key, sz);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec)
|
2014-12-17 09:58:11 -07:00
|
|
|
wc_Arc4SetKey(dec->arc4, keys->client_write_key, sz);
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* BUILD_ARC4 */
|
2014-07-01 14:16:44 -06:00
|
|
|
|
2017-04-06 14:42:42 -06:00
|
|
|
|
2021-06-25 12:47:03 +10:00
|
|
|
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305) && !defined(NO_CHAPOL_AEAD)
|
2021-11-10 11:30:24 -08:00
|
|
|
/* Check that the max implicit iv size is sufficient */
|
2016-01-29 09:38:13 -07:00
|
|
|
#if (AEAD_MAX_IMP_SZ < 12) /* CHACHA20_IMP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_IMP_SZ is too small for ChaCha20
|
|
|
|
|
#endif
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 12) /* CHACHA20_IMP_IV_SZ */
|
|
|
|
|
#error MAX_WRITE_IV_SZ is too small for ChaCha20
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_chacha) {
|
2014-07-01 14:16:44 -06:00
|
|
|
int chachaRet;
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc && enc->chacha == NULL)
|
2014-09-25 16:19:50 -06:00
|
|
|
enc->chacha =
|
|
|
|
|
(ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc && enc->chacha == NULL)
|
2014-07-01 14:16:44 -06:00
|
|
|
return MEMORY_E;
|
2022-06-13 16:21:41 +10:00
|
|
|
#ifdef WOLFSSL_CHECK_MEM_ZERO
|
|
|
|
|
if (enc) {
|
|
|
|
|
wc_MemZero_Add("SSL keys enc chacha", enc->chacha, sizeof(ChaCha));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec && dec->chacha == NULL)
|
2014-07-01 14:16:44 -06:00
|
|
|
dec->chacha =
|
|
|
|
|
(ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec && dec->chacha == NULL)
|
2014-07-01 14:16:44 -06:00
|
|
|
return MEMORY_E;
|
2022-06-13 16:21:41 +10:00
|
|
|
#ifdef WOLFSSL_CHECK_MEM_ZERO
|
|
|
|
|
if (dec) {
|
|
|
|
|
wc_MemZero_Add("SSL keys dec chacha", dec->chacha, sizeof(ChaCha));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-30 10:30:54 -07:00
|
|
|
chachaRet = wc_Chacha_SetKey(enc->chacha, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
CHACHA20_IMP_IV_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (chachaRet != 0) return chachaRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-30 10:30:54 -07:00
|
|
|
chachaRet = wc_Chacha_SetKey(dec->chacha, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
CHACHA20_IMP_IV_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (chachaRet != 0) return chachaRet;
|
|
|
|
|
}
|
2014-07-01 14:16:44 -06:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-30 10:30:54 -07:00
|
|
|
chachaRet = wc_Chacha_SetKey(enc->chacha, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
CHACHA20_IMP_IV_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (chachaRet != 0) return chachaRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-30 10:30:54 -07:00
|
|
|
chachaRet = wc_Chacha_SetKey(dec->chacha, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
CHACHA20_IMP_IV_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (chachaRet != 0) return chachaRet;
|
|
|
|
|
}
|
2014-07-01 14:16:44 -06:00
|
|
|
}
|
|
|
|
|
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2014-07-01 14:16:44 -06:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* HAVE_CHACHA && HAVE_POLY1305 */
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef BUILD_DES3
|
2016-01-29 09:38:13 -07:00
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 8) /* DES_IV_SIZE */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for 3DES
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-18 14:23:33 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_triple_des) {
|
2014-03-24 13:37:52 -07:00
|
|
|
int desRet = 0;
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (enc) {
|
|
|
|
|
if (enc->des3 == NULL)
|
|
|
|
|
enc->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (enc->des3 == NULL)
|
|
|
|
|
return MEMORY_E;
|
2017-04-25 11:10:36 -07:00
|
|
|
XMEMSET(enc->des3, 0, sizeof(Des3));
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (dec->des3 == NULL)
|
|
|
|
|
dec->des3 = (Des3*)XMALLOC(sizeof(Des3), heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (dec->des3 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
XMEMSET(dec->des3, 0, sizeof(Des3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_Des3Init(enc->des3, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Des3Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
2013-02-01 12:21:38 -08:00
|
|
|
}
|
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (dec) {
|
|
|
|
|
if (wc_Des3Init(dec->des3, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Des3Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2015-01-02 14:56:58 -07:00
|
|
|
desRet = wc_Des3_SetKey(enc->des3, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
keys->client_write_IV, DES_ENCRYPTION);
|
|
|
|
|
if (desRet != 0) return desRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2015-01-02 14:56:58 -07:00
|
|
|
desRet = wc_Des3_SetKey(dec->des3, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
keys->server_write_IV, DES_DECRYPTION);
|
|
|
|
|
if (desRet != 0) return desRet;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2015-01-02 14:56:58 -07:00
|
|
|
desRet = wc_Des3_SetKey(enc->des3, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
keys->server_write_IV, DES_ENCRYPTION);
|
|
|
|
|
if (desRet != 0) return desRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2015-01-02 14:56:58 -07:00
|
|
|
desRet = wc_Des3_SetKey(dec->des3, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
keys->client_write_IV, DES_DECRYPTION);
|
|
|
|
|
if (desRet != 0) return desRet;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* BUILD_DES3 */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
#ifdef BUILD_AES
|
2016-01-29 09:38:13 -07:00
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 16) /* AES_IV_SIZE */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for AES
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_aes) {
|
2014-03-19 13:56:11 -07:00
|
|
|
int aesRet = 0;
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (enc) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AesFree(enc->aes);
|
|
|
|
|
}
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(enc->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AesFree(dec->aes);
|
|
|
|
|
}
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(dec->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
2013-02-01 12:21:38 -08:00
|
|
|
}
|
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (dec) {
|
|
|
|
|
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-31 13:54:57 -07:00
|
|
|
aesRet = wc_AesSetKey(enc->aes, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->client_write_IV,
|
|
|
|
|
AES_ENCRYPTION);
|
|
|
|
|
if (aesRet != 0) return aesRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-31 13:54:57 -07:00
|
|
|
aesRet = wc_AesSetKey(dec->aes, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->server_write_IV,
|
|
|
|
|
AES_DECRYPTION);
|
|
|
|
|
if (aesRet != 0) return aesRet;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-31 13:54:57 -07:00
|
|
|
aesRet = wc_AesSetKey(enc->aes, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->server_write_IV,
|
|
|
|
|
AES_ENCRYPTION);
|
|
|
|
|
if (aesRet != 0) return aesRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-31 13:54:57 -07:00
|
|
|
aesRet = wc_AesSetKey(dec->aes, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->client_write_IV,
|
|
|
|
|
AES_DECRYPTION);
|
|
|
|
|
if (aesRet != 0) return aesRet;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* BUILD_AES */
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2012-06-26 09:30:48 -07:00
|
|
|
#ifdef BUILD_AESGCM
|
2016-01-29 09:38:13 -07:00
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (AEAD_MAX_IMP_SZ < 4) /* AESGCM_IMP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_IMP_SZ too small for AESGCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (AEAD_MAX_EXP_SZ < 8) /* AESGCM_EXP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_EXP_SZ too small for AESGCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 4) /* AESGCM_IMP_IV_SZ */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for AESGCM
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_aes_gcm) {
|
2014-10-27 15:52:22 -07:00
|
|
|
int gcmRet;
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (enc) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AesFree(enc->aes);
|
|
|
|
|
}
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(enc->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AesFree(dec->aes);
|
|
|
|
|
}
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(dec->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-05 12:30:51 -07:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-31 13:54:57 -07:00
|
|
|
gcmRet = wc_AesGcmSetKey(enc->aes, keys->client_write_key,
|
2014-10-27 15:52:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
2016-11-24 01:31:07 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2019-07-08 16:28:35 -06:00
|
|
|
#if !defined(NO_PUBLIC_GCM_SET_IV) && \
|
|
|
|
|
((!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
|
|
|
|
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
2019-07-26 08:26:55 +10:00
|
|
|
if (!tls13) {
|
2019-02-14 11:52:31 -08:00
|
|
|
gcmRet = wc_AesGcmSetIV(enc->aes, AESGCM_NONCE_SZ,
|
|
|
|
|
keys->client_write_IV, AESGCM_IMP_IV_SZ, rng);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
}
|
2019-02-13 11:22:56 -08:00
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-31 13:54:57 -07:00
|
|
|
gcmRet = wc_AesGcmSetKey(dec->aes, keys->server_write_key,
|
2014-10-27 15:52:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
2016-11-24 01:31:07 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
2012-06-26 09:30:48 -07:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-31 13:54:57 -07:00
|
|
|
gcmRet = wc_AesGcmSetKey(enc->aes, keys->server_write_key,
|
2014-10-27 15:52:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
2016-11-24 01:31:07 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2019-07-08 16:28:35 -06:00
|
|
|
#if !defined(NO_PUBLIC_GCM_SET_IV) && \
|
|
|
|
|
((!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
|
|
|
|
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
2019-07-26 08:26:55 +10:00
|
|
|
if (!tls13) {
|
2019-02-14 11:52:31 -08:00
|
|
|
gcmRet = wc_AesGcmSetIV(enc->aes, AESGCM_NONCE_SZ,
|
|
|
|
|
keys->server_write_IV, AESGCM_IMP_IV_SZ, rng);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
}
|
2019-02-13 11:22:56 -08:00
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-31 13:54:57 -07:00
|
|
|
gcmRet = wc_AesGcmSetKey(dec->aes, keys->client_write_key,
|
2014-10-27 15:52:22 -07:00
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
2016-11-24 01:31:07 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
2013-01-15 15:20:30 -08:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2013-01-15 15:20:30 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* BUILD_AESGCM */
|
2013-01-15 15:20:30 -08:00
|
|
|
|
|
|
|
|
#ifdef HAVE_AESCCM
|
2016-01-29 09:38:13 -07:00
|
|
|
/* check that buffer sizes are sufficient (CCM is same size as GCM) */
|
|
|
|
|
#if (AEAD_MAX_IMP_SZ < 4) /* AESGCM_IMP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_IMP_SZ too small for AESCCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (AEAD_MAX_EXP_SZ < 8) /* AESGCM_EXP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_EXP_SZ too small for AESCCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 4) /* AESGCM_IMP_IV_SZ */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for AESCCM
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_aes_ccm) {
|
2016-10-12 10:02:53 -06:00
|
|
|
int CcmRet;
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
if (enc) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (enc->aes == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AesFree(enc->aes);
|
|
|
|
|
}
|
|
|
|
|
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(enc->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL) {
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
dec->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER);
|
2021-12-29 14:43:43 +01:00
|
|
|
if (dec->aes == NULL)
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
return MEMORY_E;
|
2021-12-29 14:43:43 +01:00
|
|
|
} else {
|
|
|
|
|
wc_AesFree(dec->aes);
|
|
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
XMEMSET(dec->aes, 0, sizeof(Aes));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_AesInit(enc->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (wc_AesInit(dec->aes, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AesInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-15 15:20:30 -08:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2016-10-12 10:02:53 -06:00
|
|
|
CcmRet = wc_AesCcmSetKey(enc->aes, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
2017-06-12 14:21:43 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2019-07-08 16:28:35 -06:00
|
|
|
#if !defined(NO_PUBLIC_CCM_SET_NONCE) && \
|
|
|
|
|
((!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
|
|
|
|
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
2019-07-26 08:26:55 +10:00
|
|
|
if (!tls13) {
|
2019-02-14 11:52:31 -08:00
|
|
|
CcmRet = wc_AesCcmSetNonce(enc->aes, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
if (CcmRet != 0) return CcmRet;
|
2019-02-13 10:13:14 -08:00
|
|
|
}
|
2019-02-13 11:22:56 -08:00
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
|
|
|
|
if (dec) {
|
2016-10-12 10:02:53 -06:00
|
|
|
CcmRet = wc_AesCcmSetKey(dec->aes, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
2017-06-12 14:21:43 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
2013-01-15 15:20:30 -08:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2016-10-12 10:02:53 -06:00
|
|
|
CcmRet = wc_AesCcmSetKey(enc->aes, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
2017-06-12 14:21:43 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2019-07-08 16:28:35 -06:00
|
|
|
#if !defined(NO_PUBLIC_CCM_SET_NONCE) && \
|
|
|
|
|
((!defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)) || \
|
|
|
|
|
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2)))
|
2019-07-26 08:26:55 +10:00
|
|
|
if (!tls13) {
|
2019-02-14 11:52:31 -08:00
|
|
|
CcmRet = wc_AesCcmSetNonce(enc->aes, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
if (CcmRet != 0) return CcmRet;
|
2019-02-13 10:13:14 -08:00
|
|
|
}
|
2019-02-13 11:22:56 -08:00
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
|
|
|
|
if (dec) {
|
2016-10-12 10:02:53 -06:00
|
|
|
CcmRet = wc_AesCcmSetKey(dec->aes, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
2017-06-12 14:21:43 +10:00
|
|
|
AEAD_MAX_IMP_SZ);
|
2014-09-24 10:12:22 -07:00
|
|
|
}
|
2012-06-26 09:30:48 -07:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2012-06-26 09:30:48 -07:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* HAVE_AESCCM */
|
2012-06-26 09:30:48 -07:00
|
|
|
|
2023-07-06 13:05:39 -04:00
|
|
|
#ifdef HAVE_ARIA
|
|
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 16) /* AES_IV_SIZE */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for AES
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_aria_gcm) {
|
|
|
|
|
int ret = 0;
|
|
|
|
|
MC_ALGID algo;
|
|
|
|
|
|
|
|
|
|
switch(specs->key_size) {
|
|
|
|
|
case ARIA_128_KEY_SIZE:
|
|
|
|
|
algo = MC_ALGID_ARIA_128BITKEY;
|
|
|
|
|
break;
|
|
|
|
|
case ARIA_192_KEY_SIZE:
|
|
|
|
|
algo = MC_ALGID_ARIA_192BITKEY;
|
|
|
|
|
break;
|
|
|
|
|
case ARIA_256_KEY_SIZE:
|
|
|
|
|
algo = MC_ALGID_ARIA_256BITKEY;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return WOLFSSL_NOT_IMPLEMENTED; /* This should never happen */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (enc->aria == NULL) {
|
|
|
|
|
enc->aria = (wc_Aria*)XMALLOC(sizeof(wc_Aria), heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (enc->aria == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AriaFreeCrypt(enc->aria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(enc->aria, 0, sizeof(wc_Aria));
|
|
|
|
|
if (wc_AriaInitCrypt(enc->aria, algo) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AriaInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (dec->aria == NULL) {
|
|
|
|
|
dec->aria = (wc_Aria*)XMALLOC(sizeof(wc_Aria), heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (dec->aria == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_AriaFreeCrypt(dec->aria);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(dec->aria, 0, sizeof(wc_Aria));
|
|
|
|
|
if (wc_AriaInitCrypt(dec->aria, algo) != 0) {
|
|
|
|
|
WOLFSSL_MSG("AriaInit failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
if (enc) {
|
|
|
|
|
ret = wc_AriaSetKey(enc->aria, keys->client_write_key);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
if (!tls13) {
|
|
|
|
|
ret = wc_AriaGcmSetIV(enc->aria, AESGCM_NONCE_SZ,
|
|
|
|
|
keys->client_write_IV, AESGCM_IMP_IV_SZ, rng);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
ret = wc_AriaSetKey(dec->aria, keys->server_write_key);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (enc) {
|
|
|
|
|
ret = wc_AriaSetKey(enc->aria, keys->server_write_key);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
if (!tls13) {
|
|
|
|
|
ret = wc_AriaGcmSetIV(enc->aria, AESGCM_NONCE_SZ,
|
|
|
|
|
keys->server_write_IV, AESGCM_IMP_IV_SZ, rng);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
ret = wc_AriaSetKey(dec->aria, keys->client_write_key);
|
|
|
|
|
if (ret != 0) return ret;
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_ARIA */
|
|
|
|
|
|
2013-01-21 10:53:42 -08:00
|
|
|
#ifdef HAVE_CAMELLIA
|
2016-01-29 09:38:13 -07:00
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 16) /* CAMELLIA_IV_SIZE */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for CAMELLIA
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_camellia) {
|
2014-04-03 12:22:48 -03:00
|
|
|
int camRet;
|
|
|
|
|
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc && enc->cam == NULL)
|
2013-05-21 16:21:49 -07:00
|
|
|
enc->cam =
|
2024-11-22 19:27:56 -06:00
|
|
|
(wc_Camellia*)XMALLOC(sizeof(wc_Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc && enc->cam == NULL)
|
2013-01-21 10:53:42 -08:00
|
|
|
return MEMORY_E;
|
2014-04-03 12:22:48 -03:00
|
|
|
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec && dec->cam == NULL)
|
2013-05-21 16:21:49 -07:00
|
|
|
dec->cam =
|
2024-11-22 19:27:56 -06:00
|
|
|
(wc_Camellia*)XMALLOC(sizeof(wc_Camellia), heap, DYNAMIC_TYPE_CIPHER);
|
2014-09-24 10:12:22 -07:00
|
|
|
if (dec && dec->cam == NULL)
|
2013-01-21 10:53:42 -08:00
|
|
|
return MEMORY_E;
|
2014-04-03 12:22:48 -03:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-30 14:13:57 -07:00
|
|
|
camRet = wc_CamelliaSetKey(enc->cam, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->client_write_IV);
|
|
|
|
|
if (camRet != 0) return camRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-30 14:13:57 -07:00
|
|
|
camRet = wc_CamelliaSetKey(dec->cam, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->server_write_IV);
|
|
|
|
|
if (camRet != 0) return camRet;
|
|
|
|
|
}
|
2013-01-21 10:53:42 -08:00
|
|
|
}
|
|
|
|
|
else {
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc) {
|
2014-12-30 14:13:57 -07:00
|
|
|
camRet = wc_CamelliaSetKey(enc->cam, keys->server_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->server_write_IV);
|
|
|
|
|
if (camRet != 0) return camRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2014-12-30 14:13:57 -07:00
|
|
|
camRet = wc_CamelliaSetKey(dec->cam, keys->client_write_key,
|
2014-09-24 10:12:22 -07:00
|
|
|
specs->key_size, keys->client_write_IV);
|
|
|
|
|
if (camRet != 0) return camRet;
|
|
|
|
|
}
|
2013-01-21 10:53:42 -08:00
|
|
|
}
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2013-01-21 10:53:42 -08:00
|
|
|
}
|
Intel QuickAssist (QAT) support and async enhancements/fixes:
* Adds ./configure "--with-intelqa=../QAT1.6”, port files, memory management and README.md (see wolfcrypt/src/port/intel/).
* Added Intel QAT support for RSA public/private (CRT/non-CRT), AES CBC/GCM, ECDH/ECDSA, DH, DES3, SHA, SHA224, SHA256, SHA384, SHA512, MD5 and HMAC.
* wolfSSL async enabled all client and server: PKI, Encrypt/Decrypt, Hashing/HMAC and Certificate Sign/Verify.
* wolfSSL async support in functions: Encrypt, Decrypt, VerifyMAC, BuildMessage, ConfirmSignature, DoCertificate, ParseCertRelative, and MakeSignature.
* wolfCrypt test and benchmark async support added for all HW acceleration.
* wolfCrypt benchmark multi-threading support.
* Added QuickAssist memory overrides for XMALLOC, XFREE and XREALLOC. XREALLOC determines if existing pointer needs reallocated for NUMA.
* Refactor to make sure “heap” is available for async dev init.
* Added async support for all examples for connect, accept, read and write.
* Added new WC_BIGINT (in wolfmath.c) for async hardware support.
* Added async simulator tests for DES3 CBC, AES CBC/GCM.
* Added QAT standalone build for unit testing.
* Added int return code to SHA and MD5 functions.
* Refactor of the async stack variable handling, so async operations have generic args buffer area and cleanup function pointer.
* Combined duplicate code for async push/pop handling.
* Refactor internal.c to add AllocKey / FreeKey.
* Refactor of hash init/free in TLS to use InitHashes and FreeHashes.
* Refactor of the async event->context to use WOLF_EVENT_TYPE_ASYNC_WOLFSSL for WOLFSSL* and WOLF_EVENT_TYPE_ASYNC_WOLFCRYPT for WC_ASYNC_DEV*.
* Suppress error message for WC_PENDING_E.
* Implemented "wolfSSL_EVP_MD_CTX_init" to do memset.
* Cleanup of the openssl compat CTX sizes when async is enabled.
* Cleanup of AES, DES3, DH, SHA, MD5, DES3, DH, HMAC, MD5 for consistency and readability.
* Cleanup of the OPAQUE_LEN.
* Cleanup to use ENCRYPT_LEN instead of sizeof(ssl->arrays.preMasterSecret).
* Changed ssl->arrays.preMasterSecret to use XMALLOC (accelerates HW operations)
* Reduce verbosity with debug enabled for "GetMyVersion", "wolfSSL Using RSA OAEP padding" and "wolfSSL Using RSA PKCSV15 padding".
* Updated RSA un-padding error message so its different than one above it for better debugging.
* Added QAT async enables for each algorithm.
* Refactor of the async init to use _ex.
* Added WC_ASYNC_THRESH_NONE to allow bypass of the async thresholds for testing.
* Reformatted the benchmark results:
PKI: "RSA 2048 private HW 18522 ops took 1.003 sec, avg 0.054 ms, 18467.763 ops/sec"
Crypto/Hashing: SHA-256 SW 350 megs took 1.009 seconds, 346.946 MB/s Cycles per byte = 9.87
* Added min execution time for all benchmarks.
* Moved wc_*GetHash and wc_*RestorePos to appropriate files so use of isCopy flag is local.
* Fix for ECC sign status sometimes being invalid due to uninitialized ECC digest in benchmark.
* Added new DECLARE_VAR/FREE_VAR and DECLARE_ARRAY/FREE_ARRAY macros for helping setup test/benchmark variables to accelerate async.
* Added NO_SW_BENCH option to only run HW bench.
* Added support for PRNG to use hardware SHA256 if _wc devId provided.
* Fix to prevent curve tests from running against wrong curve sizes. Changed wc_ecc_set_curve to match on exact size.
* Added the wc_*GetHash calls to the wolfCrypt tests.
* Added async hardware start/stop to wolfSSL init/cleanup.
* Refactor to add wc_*Copy for hashing context (for async), which replaces wc_*RestorePos.
* Fixes for building with TI hashing (including: SHA224, missing new API’s and building with dummy build for non hw testing). Note: We need to add build test for this `./configure CFLAGS="-DWOLFSSL_TI_HASH -DTI_DUMMY_BUILD”`.
* Added arg checks on wc_*GetHash and wc_*Copy.
* Cleanup of the BuildMD5, BuildSHA, BuildMD5_CertVerify and BuildSHA_CertVerify functions.
* Added new ./configure --enable-asyncthreads, to allow enable/disable of the async threading support. If --enable-asynccrypt set this will be enabled by default if pthread is supported. Allows multi-threaded benchmarks with async simulator.
* Added checks for all hashing to verify valid ->buffLen.
* Fix for SHA512 scan-build warning about un-initialized “W_X”.
* Fix for valgrind un-initialized use of buffer in AllocDer (der->buffer) and BuildTlsFinished handshake_hash.
* Refactor of the benchmarking to use common function for start, check and finish of the stats.
* Fixed issue with ECC cache loading in multi-threading.
* Fix bug with AESNI not aligned code that assumes XMALLOC is 16-byte aligned.
* Added new WC_ASYNC_NO_… options to allow disabling of individual async algorithms. New defines are: WC_ASYNC_NO_CRYPT, WC_ASYNC_NO_PKI and WC_ASYNC_NO_HASH. Additionally each algorithm has a WC_ASYNC_NO_[ALGO] define.
* Added “wolfSSL_GetAllocators” API and fixed the wolfCrypt memcb_test so it restores callback pointers after test is complete (fixes issue with using custom allocators and test breaking it).
2017-04-07 15:46:32 -07:00
|
|
|
#endif /* HAVE_CAMELLIA */
|
2013-01-21 10:53:42 -08:00
|
|
|
|
2023-02-10 11:48:59 +10:00
|
|
|
#ifdef WOLFSSL_SM4_CBC
|
|
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 16) /* AES_IV_SIZE */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for SM4_CBC
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_sm4_cbc) {
|
|
|
|
|
int sm4Ret = 0;
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (enc->sm4 == NULL) {
|
|
|
|
|
enc->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (enc->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wc_Sm4Free(enc->sm4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(enc->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (dec->sm4 == NULL) {
|
|
|
|
|
dec->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (dec->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wc_Sm4Free(dec->sm4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(dec->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_Sm4Init(enc->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (wc_Sm4Init(dec->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
if (enc) {
|
|
|
|
|
sm4Ret = wc_Sm4SetKey(enc->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
sm4Ret = wc_Sm4SetIV(enc->sm4, keys->client_write_IV);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
sm4Ret = wc_Sm4SetKey(dec->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
sm4Ret = wc_Sm4SetIV(dec->sm4, keys->server_write_IV);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (enc) {
|
|
|
|
|
sm4Ret = wc_Sm4SetKey(enc->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
sm4Ret = wc_Sm4SetIV(enc->sm4, keys->server_write_IV);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
sm4Ret = wc_Sm4SetKey(dec->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
sm4Ret = wc_Sm4SetIV(dec->sm4, keys->client_write_IV);
|
|
|
|
|
if (sm4Ret != 0) return sm4Ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_SM4_CBC */
|
|
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_SM4_GCM
|
|
|
|
|
/* check that buffer sizes are sufficient */
|
|
|
|
|
#if (AEAD_MAX_IMP_SZ < 4) /* SM4-GCM_IMP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_IMP_SZ too small for SM4-GCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (AEAD_MAX_EXP_SZ < 8) /* SM4-GCM_EXP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_EXP_SZ too small for SM4-GCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 4) /* SM4-GCM_IMP_IV_SZ */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for SM4-GCM
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_sm4_gcm) {
|
|
|
|
|
int gcmRet;
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (enc->sm4 == NULL) {
|
|
|
|
|
enc->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (enc->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_Sm4Free(enc->sm4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(enc->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (dec->sm4 == NULL) {
|
|
|
|
|
dec->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (dec->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_Sm4Free(dec->sm4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(dec->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_Sm4Init(enc->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (wc_Sm4Init(dec->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
if (enc) {
|
|
|
|
|
gcmRet = wc_Sm4GcmSetKey(enc->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
gcmRet = wc_Sm4GcmSetKey(dec->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (enc) {
|
|
|
|
|
gcmRet = wc_Sm4GcmSetKey(enc->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
gcmRet = wc_Sm4GcmSetKey(dec->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (gcmRet != 0) return gcmRet;
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_SM4_GCM */
|
|
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_SM4_CCM
|
|
|
|
|
/* check that buffer sizes are sufficient (CCM is same size as GCM) */
|
|
|
|
|
#if (AEAD_MAX_IMP_SZ < 4) /* SM4-CCM_IMP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_IMP_SZ too small for SM4-CCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (AEAD_MAX_EXP_SZ < 8) /* SM4-CCM_EXP_IV_SZ */
|
|
|
|
|
#error AEAD_MAX_EXP_SZ too small for SM4-CCM
|
|
|
|
|
#endif
|
|
|
|
|
#if (MAX_WRITE_IV_SZ < 4) /* SM4-CCM_IMP_IV_SZ */
|
|
|
|
|
#error MAX_WRITE_IV_SZ too small for SM4-CCM
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_sm4_ccm) {
|
|
|
|
|
int CcmRet;
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (enc->sm4 == NULL) {
|
|
|
|
|
enc->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (enc->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_Sm4Free(enc->sm4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMEMSET(enc->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (dec->sm4 == NULL) {
|
|
|
|
|
dec->sm4 = (wc_Sm4*)XMALLOC(sizeof(wc_Sm4), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (dec->sm4 == NULL)
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
} else {
|
|
|
|
|
wc_Sm4Free(dec->sm4);
|
|
|
|
|
}
|
|
|
|
|
XMEMSET(dec->sm4, 0, sizeof(wc_Sm4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc) {
|
|
|
|
|
if (wc_Sm4Init(enc->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
if (wc_Sm4Init(dec->sm4, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Sm4Init failed in SetKeys");
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
if (enc) {
|
|
|
|
|
CcmRet = wc_Sm4SetKey(enc->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
CcmRet = wc_Sm4SetKey(dec->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (enc) {
|
|
|
|
|
CcmRet = wc_Sm4SetKey(enc->sm4, keys->server_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
|
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
CcmRet = wc_Sm4SetKey(dec->sm4, keys->client_write_key,
|
|
|
|
|
specs->key_size);
|
|
|
|
|
if (CcmRet != 0) {
|
|
|
|
|
return CcmRet;
|
|
|
|
|
}
|
|
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
|
|
|
|
AEAD_MAX_IMP_SZ);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_SM4_CCM */
|
|
|
|
|
|
2012-10-19 10:37:21 -07:00
|
|
|
#ifdef HAVE_NULL_CIPHER
|
2014-12-19 11:27:01 -07:00
|
|
|
if (specs->bulk_cipher_algorithm == wolfssl_cipher_null) {
|
2019-07-26 08:26:55 +10:00
|
|
|
#ifdef WOLFSSL_TLS13
|
|
|
|
|
if (tls13) {
|
|
|
|
|
int hmacRet;
|
|
|
|
|
int hashType = WC_HASH_TYPE_NONE;
|
|
|
|
|
|
|
|
|
|
switch (specs->mac_algorithm) {
|
|
|
|
|
case sha256_mac:
|
|
|
|
|
hashType = WC_SHA256;
|
|
|
|
|
break;
|
|
|
|
|
case sha384_mac:
|
|
|
|
|
hashType = WC_SHA384;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enc && enc->hmac == NULL) {
|
|
|
|
|
enc->hmac = (Hmac*)XMALLOC(sizeof(Hmac), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
2020-04-08 09:46:22 +10:00
|
|
|
if (enc->hmac == NULL)
|
|
|
|
|
return MEMORY_E;
|
2019-07-26 08:26:55 +10:00
|
|
|
|
2021-01-15 11:27:26 +10:00
|
|
|
if (wc_HmacInit(enc->hmac, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("HmacInit failed in SetKeys");
|
|
|
|
|
XFREE(enc->hmac, heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
enc->hmac = NULL;
|
|
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-26 08:26:55 +10:00
|
|
|
if (dec && dec->hmac == NULL) {
|
|
|
|
|
dec->hmac = (Hmac*)XMALLOC(sizeof(Hmac), heap,
|
|
|
|
|
DYNAMIC_TYPE_CIPHER);
|
2020-04-08 09:46:22 +10:00
|
|
|
if (dec->hmac == NULL)
|
|
|
|
|
return MEMORY_E;
|
2019-07-26 08:26:55 +10:00
|
|
|
|
|
|
|
|
if (wc_HmacInit(dec->hmac, heap, devId) != 0) {
|
|
|
|
|
WOLFSSL_MSG("HmacInit failed in SetKeys");
|
2021-01-15 11:27:26 +10:00
|
|
|
XFREE(dec->hmac, heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
dec->hmac = NULL;
|
2019-07-26 08:26:55 +10:00
|
|
|
return ASYNC_INIT_E;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
if (enc) {
|
2020-05-05 10:05:20 +10:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV,
|
|
|
|
|
HMAC_NONCE_SZ);
|
2019-07-26 08:26:55 +10:00
|
|
|
hmacRet = wc_HmacSetKey(enc->hmac, hashType,
|
|
|
|
|
keys->client_write_key, specs->key_size);
|
|
|
|
|
if (hmacRet != 0) return hmacRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2020-05-05 10:05:20 +10:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->server_write_IV,
|
|
|
|
|
HMAC_NONCE_SZ);
|
2019-07-26 08:26:55 +10:00
|
|
|
hmacRet = wc_HmacSetKey(dec->hmac, hashType,
|
|
|
|
|
keys->server_write_key, specs->key_size);
|
|
|
|
|
if (hmacRet != 0) return hmacRet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (enc) {
|
2020-05-05 10:05:20 +10:00
|
|
|
XMEMCPY(keys->aead_enc_imp_IV, keys->server_write_IV,
|
|
|
|
|
HMAC_NONCE_SZ);
|
2019-07-26 08:26:55 +10:00
|
|
|
hmacRet = wc_HmacSetKey(enc->hmac, hashType,
|
|
|
|
|
keys->server_write_key, specs->key_size);
|
|
|
|
|
if (hmacRet != 0) return hmacRet;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
2020-05-05 10:05:20 +10:00
|
|
|
XMEMCPY(keys->aead_dec_imp_IV, keys->client_write_IV,
|
|
|
|
|
HMAC_NONCE_SZ);
|
2019-07-26 08:26:55 +10:00
|
|
|
hmacRet = wc_HmacSetKey(dec->hmac, hashType,
|
|
|
|
|
keys->client_write_key, specs->key_size);
|
|
|
|
|
if (hmacRet != 0) return hmacRet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-09-24 10:12:22 -07:00
|
|
|
if (enc)
|
|
|
|
|
enc->setup = 1;
|
|
|
|
|
if (dec)
|
|
|
|
|
dec->setup = 1;
|
2012-10-19 10:37:21 -07:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-09-19 16:02:27 -07:00
|
|
|
if (enc) {
|
|
|
|
|
keys->sequence_number_hi = 0;
|
|
|
|
|
keys->sequence_number_lo = 0;
|
|
|
|
|
}
|
|
|
|
|
if (dec) {
|
|
|
|
|
keys->peer_sequence_number_hi = 0;
|
|
|
|
|
keys->peer_sequence_number_lo = 0;
|
|
|
|
|
}
|
2012-10-29 15:39:42 -07:00
|
|
|
(void)side;
|
|
|
|
|
(void)heap;
|
|
|
|
|
(void)enc;
|
|
|
|
|
(void)dec;
|
|
|
|
|
(void)specs;
|
2013-02-04 13:11:21 -08:00
|
|
|
(void)devId;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-25 16:19:50 -06:00
|
|
|
#ifdef HAVE_ONE_TIME_AUTH
|
|
|
|
|
/* set one time authentication keys */
|
|
|
|
|
static int SetAuthKeys(OneTimeAuth* authentication, Keys* keys,
|
|
|
|
|
CipherSpecs* specs, void* heap, int devId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_POLY1305
|
|
|
|
|
/* set up memory space for poly1305 */
|
|
|
|
|
if (authentication && authentication->poly1305 == NULL)
|
|
|
|
|
authentication->poly1305 =
|
|
|
|
|
(Poly1305*)XMALLOC(sizeof(Poly1305), heap, DYNAMIC_TYPE_CIPHER);
|
|
|
|
|
if (authentication && authentication->poly1305 == NULL)
|
|
|
|
|
return MEMORY_E;
|
2022-06-13 16:21:41 +10:00
|
|
|
#ifdef WOLFSSL_CHECK_MEM_ZERO
|
|
|
|
|
wc_MemZero_Add("SSL auth keys poly1305", authentication->poly1305,
|
|
|
|
|
sizeof(Poly1305));
|
|
|
|
|
#endif
|
2015-01-08 15:33:44 -07:00
|
|
|
if (authentication)
|
|
|
|
|
authentication->setup = 1;
|
2014-09-25 16:19:50 -06:00
|
|
|
#endif
|
2017-03-28 19:10:19 -07:00
|
|
|
(void)authentication;
|
2014-09-25 16:19:50 -06:00
|
|
|
(void)heap;
|
|
|
|
|
(void)keys;
|
|
|
|
|
(void)specs;
|
|
|
|
|
(void)devId;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_ONE_TIME_AUTH */
|
|
|
|
|
|
2017-01-06 11:06:01 -07:00
|
|
|
#ifdef HAVE_SECURE_RENEGOTIATION
|
|
|
|
|
/* function name is for cache_status++
|
|
|
|
|
* This function was added because of error incrementing enum type when
|
|
|
|
|
* compiling with a C++ compiler.
|
|
|
|
|
*/
|
|
|
|
|
static void CacheStatusPP(SecureRenegotiation* cache)
|
|
|
|
|
{
|
|
|
|
|
switch (cache->cache_status) {
|
|
|
|
|
case SCR_CACHE_NULL:
|
|
|
|
|
cache->cache_status = SCR_CACHE_NEEDED;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SCR_CACHE_NEEDED:
|
|
|
|
|
cache->cache_status = SCR_CACHE_COPY;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SCR_CACHE_COPY:
|
|
|
|
|
cache->cache_status = SCR_CACHE_PARTIAL;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SCR_CACHE_PARTIAL:
|
|
|
|
|
cache->cache_status = SCR_CACHE_COMPLETE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SCR_CACHE_COMPLETE:
|
|
|
|
|
WOLFSSL_MSG("SCR Cache state Complete");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
WOLFSSL_MSG("Unknown cache state!!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_SECURE_RENEGOTIATION */
|
|
|
|
|
|
2014-09-25 16:19:50 -06:00
|
|
|
|
2015-01-28 11:18:13 -07:00
|
|
|
/* Set wc_encrypt/wc_decrypt or both sides of key setup
|
|
|
|
|
* note: use wc_encrypt to avoid shadowing global encrypt
|
|
|
|
|
* declared in unistd.h
|
|
|
|
|
*/
|
2014-12-19 11:27:01 -07:00
|
|
|
int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2019-01-18 14:08:58 -08:00
|
|
|
int ret, copy = 0;
|
2015-01-28 11:18:13 -07:00
|
|
|
Ciphers* wc_encrypt = NULL;
|
|
|
|
|
Ciphers* wc_decrypt = NULL;
|
2014-09-24 18:48:23 -07:00
|
|
|
Keys* keys = &ssl->keys;
|
|
|
|
|
|
|
|
|
|
(void)copy;
|
2013-02-01 12:21:38 -08:00
|
|
|
|
2014-09-24 18:48:23 -07:00
|
|
|
#ifdef HAVE_SECURE_RENEGOTIATION
|
2021-10-15 18:55:30 +02:00
|
|
|
if (ssl->secure_renegotiation &&
|
|
|
|
|
ssl->secure_renegotiation->cache_status != SCR_CACHE_NULL) {
|
2014-09-24 18:48:23 -07:00
|
|
|
keys = &ssl->secure_renegotiation->tmp_keys;
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
/* For DTLS, copy is done in StoreKeys */
|
|
|
|
|
if (!ssl->options.dtls)
|
|
|
|
|
#endif
|
|
|
|
|
copy = 1;
|
2014-09-24 18:48:23 -07:00
|
|
|
}
|
|
|
|
|
#endif /* HAVE_SECURE_RENEGOTIATION */
|
|
|
|
|
|
2014-09-24 11:27:13 -07:00
|
|
|
switch (side) {
|
|
|
|
|
case ENCRYPT_SIDE_ONLY:
|
2017-07-03 18:29:15 +10:00
|
|
|
#ifdef WOLFSSL_DEBUG_TLS
|
2017-06-19 11:37:10 +10:00
|
|
|
WOLFSSL_MSG("Provisioning ENCRYPT key");
|
|
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->client_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->server_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2017-07-03 18:29:15 +10:00
|
|
|
#endif
|
2015-01-28 11:18:13 -07:00
|
|
|
wc_encrypt = &ssl->encrypt;
|
2014-09-24 11:27:13 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DECRYPT_SIDE_ONLY:
|
2017-07-03 18:29:15 +10:00
|
|
|
#ifdef WOLFSSL_DEBUG_TLS
|
2017-06-19 11:37:10 +10:00
|
|
|
WOLFSSL_MSG("Provisioning DECRYPT key");
|
|
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->server_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->client_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2017-07-03 18:29:15 +10:00
|
|
|
#endif
|
2015-01-28 11:18:13 -07:00
|
|
|
wc_decrypt = &ssl->decrypt;
|
2014-09-24 11:27:13 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ENCRYPT_AND_DECRYPT_SIDE:
|
2017-07-03 18:29:15 +10:00
|
|
|
#ifdef WOLFSSL_DEBUG_TLS
|
2017-06-19 11:37:10 +10:00
|
|
|
WOLFSSL_MSG("Provisioning ENCRYPT key");
|
|
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->client_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->server_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
WOLFSSL_MSG("Provisioning DECRYPT key");
|
|
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->server_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2021-03-22 22:42:49 +01:00
|
|
|
WOLFSSL_BUFFER(keys->client_write_key, ssl->specs.key_size);
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2017-07-03 18:29:15 +10:00
|
|
|
#endif
|
2015-01-28 11:18:13 -07:00
|
|
|
wc_encrypt = &ssl->encrypt;
|
|
|
|
|
wc_decrypt = &ssl->decrypt;
|
2014-09-24 11:27:13 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return BAD_FUNC_ARG;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-25 16:19:50 -06:00
|
|
|
#ifdef HAVE_ONE_TIME_AUTH
|
2015-03-27 15:38:01 -07:00
|
|
|
if (!ssl->auth.setup && ssl->specs.bulk_cipher_algorithm == wolfssl_chacha){
|
2019-01-18 14:08:58 -08:00
|
|
|
ret = SetAuthKeys(&ssl->auth, keys, &ssl->specs, ssl->heap, ssl->devId);
|
2014-09-25 16:19:50 -06:00
|
|
|
if (ret != 0)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-20 10:15:57 +09:00
|
|
|
#if !defined(NO_CERTS) && defined(HAVE_PK_CALLBACKS)
|
|
|
|
|
ret = PROTOCOLCB_UNAVAILABLE;
|
2021-11-24 19:11:16 +09:00
|
|
|
if (ssl->ctx->EncryptKeysCb) {
|
|
|
|
|
void* ctx = wolfSSL_GetEncryptKeysCtx(ssl);
|
2025-05-23 13:53:38 +09:00
|
|
|
#if defined(WOLFSSL_RENESAS_FSPSM_TLS)
|
|
|
|
|
FSPSM_ST* cbInfo = (FSPSM_ST*)ctx;
|
2025-07-17 18:16:40 +09:00
|
|
|
cbInfo->internal->side = side;
|
2025-06-05 20:56:06 +09:00
|
|
|
#elif defined(WOLFSSL_RENESAS_TSIP_TLS)
|
|
|
|
|
TsipUserCtx* cbInfo = (TsipUserCtx*)ctx;
|
2025-07-12 09:49:09 +09:00
|
|
|
cbInfo->internal->key_side = side;
|
2025-05-23 13:53:38 +09:00
|
|
|
#endif
|
2021-11-24 19:11:16 +09:00
|
|
|
ret = ssl->ctx->EncryptKeysCb(ssl, ctx);
|
2021-10-30 20:21:21 +09:00
|
|
|
}
|
2024-06-08 16:39:53 -05:00
|
|
|
if (!ssl->ctx->EncryptKeysCb ||
|
|
|
|
|
ret == WC_NO_ERR_TRACE(PROTOCOLCB_UNAVAILABLE))
|
2021-10-30 20:21:21 +09:00
|
|
|
#endif
|
jumbo patch of fixes for clang-tidy gripes (with some bug fixes).
defect/gripe statistics:
configured --enable-all --enable-sp-math-all --enable-intelasm
with LLVM 13 clang-tidy -checks=readability-*,bugprone-*,misc-no-recursion,misc-misplaced-const,misc-redundant-expression,misc-unused-parameters,misc-unused-using-decls,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-optin.performance.Padding,-readability-braces-around-statements,-readability-function-size,-readability-function-cognitive-complexity,-bugprone-suspicious-include,-bugprone-easily-swappable-parameters,-readability-isolate-declaration,-readability-magic-numbers,-readability-else-after-return,-bugprone-reserved-identifier,-readability-suspicious-call-argument,-bugprone-suspicious-string-compare,-bugprone-branch-clone,-misc-redundant-expression,-readability-non-const-parameter,-readability-redundant-control-flow,-readability-misleading-indentation,-bugprone-narrowing-conversions,-bugprone-implicit-widening-of-multiplication-result
[note these figures don't reflect additional defects fixed in this commit for --enable-smallstack, --enable-fips, --enable-async, --enable-asn=template, and --enable-fastmath, and --disable-fastmath]
pre-patch warning count per file, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 6 wolfssl/tests/suites.c
clang-analyzer-security.insecureAPI.strcpy 2 wolfssl/testsuite/testsuite.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/server/server.c
bugprone-suspicious-missing-comma 3 wolfssl/examples/client/client.c
readability-redundant-preprocessor 2 wolfssl/wolfcrypt/src/asn.c
readability-redundant-preprocessor 1 wolfssl/wolfcrypt/src/rsa.c
readability-redundant-preprocessor 9 wolfssl/src/ssl.c
readability-redundant-preprocessor 2 wolfssl/src/tls13.c
readability-redundant-preprocessor 18 wolfssl/tests/api.c
readability-redundant-preprocessor 3 wolfssl/src/internal.c
readability-redundant-preprocessor 10 wolfssl/wolfcrypt/test/test.c
readability-named-parameter 1 wolfssl/wolfcrypt/benchmark/benchmark.c
readability-named-parameter 7 wolfssl/src/internal.c
readability-named-parameter 1 wolfssl/wolfcrypt/src/ecc.c
readability-named-parameter 1 wolfssl/testsuite/testsuite.c
readability-named-parameter 11 wolfssl/wolfcrypt/src/ge_operations.c
misc-no-recursion 3 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 4 wolfssl/wolfcrypt/src/asn.c
readability-uppercase-literal-suffix 1 wolfssl/src/ssl.c
readability-uppercase-literal-suffix 13 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-too-small-loop-variable 1 wolfssl/wolfcrypt/src/rsa.c
bugprone-too-small-loop-variable 2 wolfssl/wolfcrypt/src/sha3.c
bugprone-too-small-loop-variable 4 wolfssl/wolfcrypt/src/idea.c
bugprone-signed-char-misuse 2 wolfssl/src/ssl.c
bugprone-signed-char-misuse 3 wolfssl/wolfcrypt/src/sp_int.c
bugprone-signed-char-misuse 3 wolfssl/examples/client/client.c
bugprone-macro-parentheses 19 wolfssl/wolfcrypt/src/aes.c
bugprone-macro-parentheses 109 wolfssl/wolfcrypt/src/camellia.c
bugprone-macro-parentheses 1 wolfssl/src/tls.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/md4.c
bugprone-macro-parentheses 2 wolfssl/wolfcrypt/src/asn.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2b.c
bugprone-macro-parentheses 257 wolfssl/wolfcrypt/src/sha3.c
bugprone-macro-parentheses 15 wolfssl/src/ssl.c
bugprone-macro-parentheses 1 wolfssl/wolfcrypt/src/sha.c
bugprone-macro-parentheses 8 wolfssl/tests/api.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/sp_int.c
bugprone-macro-parentheses 6 wolfssl/wolfcrypt/benchmark/benchmark.c
bugprone-macro-parentheses 38 wolfssl/wolfcrypt/src/hc128.c
bugprone-macro-parentheses 12 wolfssl/wolfcrypt/src/md5.c
bugprone-macro-parentheses 10 wolfssl/wolfcrypt/src/sha256.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/test/test.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/ecc.c
bugprone-macro-parentheses 2 wolfssl/tests/suites.c
bugprone-macro-parentheses 4 wolfssl/wolfcrypt/src/cpuid.c
bugprone-macro-parentheses 26 wolfssl/wolfcrypt/src/blake2s.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/sha512.c
bugprone-macro-parentheses 3 wolfssl/wolfcrypt/src/poly1305.c
bugprone-macro-parentheses 24 wolfssl/wolfcrypt/src/ripemd.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/src/internal.c
readability-inconsistent-declaration-parameter-name 1 wolfssl/testsuite/testsuite.c
pre-patch warning count summaries, with suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-suspicious-missing-comma 6
readability-redundant-preprocessor 45
readability-named-parameter 21
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-too-small-loop-variable 7
bugprone-signed-char-misuse 8
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
pre-patch warning count summaries, without suppressions:
clang-analyzer-security.insecureAPI.strcpy 8
bugprone-branch-clone 152
readability-non-const-parameter 118
bugprone-suspicious-missing-comma 6
bugprone-suspicious-include 52
readability-magic-numbers 22423
readability-redundant-preprocessor 45
readability-named-parameter 21
readability-function-cognitive-complexity 845
readability-else-after-return 398
bugprone-implicit-widening-of-multiplication-result 595
readability-function-size 21
readability-isolate-declaration 1090
misc-redundant-expression 2
bugprone-narrowing-conversions 994
misc-no-recursion 3
readability-uppercase-literal-suffix 18
bugprone-reserved-identifier 56
readability-suspicious-call-argument 74
bugprone-too-small-loop-variable 7
bugprone-easily-swappable-parameters 437
bugprone-signed-char-misuse 8
readability-misleading-indentation 94
bugprone-macro-parentheses 601
readability-inconsistent-declaration-parameter-name 2
bugprone-suspicious-string-compare 495
readability-redundant-control-flow 20
readability-braces-around-statements 11483
clang-analyzer-valist.Uninitialized 1
clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling 3502
2022-01-19 23:09:50 -06:00
|
|
|
{
|
|
|
|
|
ret = SetKeys(wc_encrypt, wc_decrypt, keys, &ssl->specs, ssl->options.side,
|
|
|
|
|
ssl->heap, ssl->devId, ssl->rng, ssl->options.tls1_3);
|
|
|
|
|
}
|
2014-09-24 18:48:23 -07:00
|
|
|
|
2022-05-20 09:59:29 +02:00
|
|
|
#ifdef WOLFSSL_DTLS13
|
|
|
|
|
if (ret == 0 && ssl->options.dtls && IsAtLeastTLSv1_3(ssl->version))
|
|
|
|
|
ret = Dtls13SetRecordNumberKeys(ssl, side);
|
|
|
|
|
#endif /* WOLFSSL_DTLS13 */
|
2022-08-08 13:24:00 +02:00
|
|
|
#ifdef WOLFSSL_QUIC
|
|
|
|
|
if (ret == 0 && WOLFSSL_IS_QUIC(ssl)) {
|
|
|
|
|
ret = wolfSSL_quic_keys_active(ssl, side);
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_QUIC */
|
2022-05-20 09:59:29 +02:00
|
|
|
|
2014-09-24 18:48:23 -07:00
|
|
|
#ifdef HAVE_SECURE_RENEGOTIATION
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
2022-05-20 09:59:34 +02:00
|
|
|
if (ret == 0 && ssl->options.dtls && !ssl->options.tls1_3) {
|
2020-05-19 14:11:05 +02:00
|
|
|
if (wc_encrypt)
|
|
|
|
|
wc_encrypt->src = keys == &ssl->keys ? KEYS : SCR;
|
|
|
|
|
if (wc_decrypt)
|
|
|
|
|
wc_decrypt->src = keys == &ssl->keys ? KEYS : SCR;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-24 18:48:23 -07:00
|
|
|
if (copy) {
|
|
|
|
|
int clientCopy = 0;
|
|
|
|
|
|
2021-10-18 14:38:47 +02:00
|
|
|
/* Sanity check that keys == ssl->secure_renegotiation->tmp_keys.
|
|
|
|
|
* Otherwise the memcpy calls would copy overlapping memory
|
|
|
|
|
* and cause UB. Fail early. */
|
|
|
|
|
if (keys == &ssl->keys)
|
|
|
|
|
return BAD_FUNC_ARG;
|
|
|
|
|
|
2015-01-28 11:18:13 -07:00
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END && wc_encrypt)
|
2014-09-24 18:48:23 -07:00
|
|
|
clientCopy = 1;
|
2015-01-28 11:18:13 -07:00
|
|
|
else if (ssl->options.side == WOLFSSL_SERVER_END && wc_decrypt)
|
2014-09-24 18:48:23 -07:00
|
|
|
clientCopy = 1;
|
|
|
|
|
|
|
|
|
|
if (clientCopy) {
|
2018-07-25 11:22:48 +10:00
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2014-09-24 18:48:23 -07:00
|
|
|
XMEMCPY(ssl->keys.client_write_MAC_secret,
|
2018-01-11 09:52:49 -08:00
|
|
|
keys->client_write_MAC_secret, WC_MAX_DIGEST_SIZE);
|
2018-07-25 11:22:48 +10:00
|
|
|
#endif
|
2014-09-24 18:48:23 -07:00
|
|
|
XMEMCPY(ssl->keys.client_write_key,
|
|
|
|
|
keys->client_write_key, AES_256_KEY_SIZE);
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->client_write_IV, MAX_WRITE_IV_SZ);
|
2014-09-24 18:48:23 -07:00
|
|
|
} else {
|
2018-07-25 11:22:48 +10:00
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2014-09-24 18:48:23 -07:00
|
|
|
XMEMCPY(ssl->keys.server_write_MAC_secret,
|
2018-01-11 09:52:49 -08:00
|
|
|
keys->server_write_MAC_secret, WC_MAX_DIGEST_SIZE);
|
2018-07-25 11:22:48 +10:00
|
|
|
#endif
|
2014-09-24 18:48:23 -07:00
|
|
|
XMEMCPY(ssl->keys.server_write_key,
|
|
|
|
|
keys->server_write_key, AES_256_KEY_SIZE);
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->server_write_IV, MAX_WRITE_IV_SZ);
|
2014-09-24 18:48:23 -07:00
|
|
|
}
|
2015-01-28 11:18:13 -07:00
|
|
|
if (wc_encrypt) {
|
2016-09-19 17:31:20 -07:00
|
|
|
ssl->keys.sequence_number_hi = keys->sequence_number_hi;
|
|
|
|
|
ssl->keys.sequence_number_lo = keys->sequence_number_lo;
|
2014-09-24 18:48:23 -07:00
|
|
|
#ifdef HAVE_AEAD
|
|
|
|
|
if (ssl->specs.cipher_type == aead) {
|
|
|
|
|
/* Initialize the AES-GCM/CCM explicit IV to a zero. */
|
|
|
|
|
XMEMCPY(ssl->keys.aead_exp_IV, keys->aead_exp_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
AEAD_MAX_EXP_SZ);
|
2015-04-05 09:13:11 -07:00
|
|
|
|
|
|
|
|
/* Initialize encrypt implicit IV by encrypt side */
|
|
|
|
|
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
|
|
|
|
XMEMCPY(ssl->keys.aead_enc_imp_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->client_write_IV, AEAD_MAX_IMP_SZ);
|
2015-04-05 09:13:11 -07:00
|
|
|
} else {
|
|
|
|
|
XMEMCPY(ssl->keys.aead_enc_imp_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->server_write_IV, AEAD_MAX_IMP_SZ);
|
2015-04-05 09:13:11 -07:00
|
|
|
}
|
2014-09-24 18:48:23 -07:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2015-04-05 09:13:11 -07:00
|
|
|
if (wc_decrypt) {
|
2016-09-19 16:02:27 -07:00
|
|
|
ssl->keys.peer_sequence_number_hi = keys->peer_sequence_number_hi;
|
|
|
|
|
ssl->keys.peer_sequence_number_lo = keys->peer_sequence_number_lo;
|
2015-04-05 09:13:11 -07:00
|
|
|
#ifdef HAVE_AEAD
|
|
|
|
|
if (ssl->specs.cipher_type == aead) {
|
|
|
|
|
/* Initialize decrypt implicit IV by decrypt side */
|
|
|
|
|
if (ssl->options.side == WOLFSSL_SERVER_END) {
|
|
|
|
|
XMEMCPY(ssl->keys.aead_dec_imp_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->client_write_IV, AEAD_MAX_IMP_SZ);
|
2015-04-05 09:13:11 -07:00
|
|
|
} else {
|
|
|
|
|
XMEMCPY(ssl->keys.aead_dec_imp_IV,
|
2016-01-29 09:38:13 -07:00
|
|
|
keys->server_write_IV, AEAD_MAX_IMP_SZ);
|
2015-04-05 09:13:11 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2017-01-06 11:06:01 -07:00
|
|
|
CacheStatusPP(ssl->secure_renegotiation);
|
2014-09-24 18:48:23 -07:00
|
|
|
}
|
|
|
|
|
#endif /* HAVE_SECURE_RENEGOTIATION */
|
|
|
|
|
|
|
|
|
|
return ret;
|
2014-09-24 11:27:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TLS can call too */
|
2017-06-19 11:37:10 +10:00
|
|
|
int StoreKeys(WOLFSSL* ssl, const byte* keyData, int side)
|
2014-09-24 11:27:13 -07:00
|
|
|
{
|
2024-05-08 10:14:53 -04:00
|
|
|
size_t sz;
|
|
|
|
|
int i = 0;
|
2014-09-24 18:48:23 -07:00
|
|
|
Keys* keys = &ssl->keys;
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
/* In case of DTLS, ssl->keys is updated here */
|
|
|
|
|
int scr_copy = 0;
|
|
|
|
|
#endif
|
2014-09-24 18:48:23 -07:00
|
|
|
|
|
|
|
|
#ifdef HAVE_SECURE_RENEGOTIATION
|
2020-05-21 13:39:17 +02:00
|
|
|
if (ssl->secure_renegotiation &&
|
2020-05-19 14:11:05 +02:00
|
|
|
ssl->secure_renegotiation->cache_status == SCR_CACHE_NEEDED) {
|
2014-09-24 18:48:23 -07:00
|
|
|
keys = &ssl->secure_renegotiation->tmp_keys;
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
2020-05-21 13:39:17 +02:00
|
|
|
if (ssl->options.dtls) {
|
|
|
|
|
/* epoch is incremented after StoreKeys is called */
|
|
|
|
|
ssl->secure_renegotiation->tmp_keys.dtls_epoch = ssl->keys.dtls_epoch + 1;
|
|
|
|
|
/* we only need to copy keys on second and future renegotiations */
|
|
|
|
|
if (ssl->keys.dtls_epoch > 1)
|
|
|
|
|
scr_copy = 1;
|
|
|
|
|
ssl->encrypt.src = KEYS_NOT_SET;
|
|
|
|
|
ssl->decrypt.src = KEYS_NOT_SET;
|
|
|
|
|
}
|
2020-05-19 14:11:05 +02:00
|
|
|
#endif
|
2017-01-06 11:06:01 -07:00
|
|
|
CacheStatusPP(ssl->secure_renegotiation);
|
2014-09-24 18:48:23 -07:00
|
|
|
}
|
|
|
|
|
#endif /* HAVE_SECURE_RENEGOTIATION */
|
2014-09-24 11:27:13 -07:00
|
|
|
|
2017-01-03 14:35:31 -08:00
|
|
|
#ifdef WOLFSSL_MULTICAST
|
2017-07-19 14:01:29 -07:00
|
|
|
if (ssl->options.haveMcast) {
|
|
|
|
|
/* Use the same keys for encrypt and decrypt. */
|
|
|
|
|
if (ssl->specs.cipher_type != aead) {
|
|
|
|
|
sz = ssl->specs.hash_size;
|
2018-07-25 11:22:48 +10:00
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2020-05-19 14:11:05 +02:00
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy) {
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_MAC_secret,
|
|
|
|
|
keys->client_write_MAC_secret, sz);
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_MAC_secret,
|
|
|
|
|
keys->server_write_MAC_secret, sz);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-07-19 14:01:29 -07:00
|
|
|
XMEMCPY(keys->client_write_MAC_secret,&keyData[i], sz);
|
|
|
|
|
XMEMCPY(keys->server_write_MAC_secret,&keyData[i], sz);
|
2018-07-25 11:22:48 +10:00
|
|
|
#endif
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-07-19 14:01:29 -07:00
|
|
|
}
|
|
|
|
|
sz = ssl->specs.key_size;
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy) {
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_key,
|
|
|
|
|
keys->client_write_key, sz);
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_key,
|
|
|
|
|
keys->server_write_key, sz);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-07-19 14:01:29 -07:00
|
|
|
XMEMCPY(keys->client_write_key, &keyData[i], sz);
|
|
|
|
|
XMEMCPY(keys->server_write_key, &keyData[i], sz);
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-07-19 14:01:29 -07:00
|
|
|
|
|
|
|
|
sz = ssl->specs.iv_size;
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy) {
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_IV,
|
|
|
|
|
keys->client_write_IV, sz);
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_IV,
|
|
|
|
|
keys->server_write_IV, sz);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-07-19 14:01:29 -07:00
|
|
|
XMEMCPY(keys->client_write_IV, &keyData[i], sz);
|
|
|
|
|
XMEMCPY(keys->server_write_IV, &keyData[i], sz);
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_AEAD
|
|
|
|
|
if (ssl->specs.cipher_type == aead) {
|
|
|
|
|
/* Initialize the AES-GCM/CCM explicit IV to a zero. */
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy) {
|
|
|
|
|
XMEMCPY(ssl->keys.aead_exp_IV,
|
|
|
|
|
keys->aead_exp_IV, AEAD_MAX_EXP_SZ);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-07-19 14:01:29 -07:00
|
|
|
XMEMSET(keys->aead_exp_IV, 0, AEAD_MAX_EXP_SZ);
|
|
|
|
|
}
|
|
|
|
|
#endif /* HAVE_AEAD */
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_MULTICAST */
|
2017-01-03 14:35:31 -08:00
|
|
|
|
2012-06-26 15:51:40 -07:00
|
|
|
if (ssl->specs.cipher_type != aead) {
|
|
|
|
|
sz = ssl->specs.hash_size;
|
2017-06-19 11:37:10 +10:00
|
|
|
if (side & PROVISION_CLIENT) {
|
2018-07-25 11:22:48 +10:00
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_MAC_secret,
|
|
|
|
|
keys->client_write_MAC_secret, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->client_write_MAC_secret,&keyData[i], sz);
|
2018-07-25 11:22:48 +10:00
|
|
|
#endif
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
if (side & PROVISION_SERVER) {
|
2018-07-25 11:22:48 +10:00
|
|
|
#ifndef WOLFSSL_AEAD_ONLY
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_MAC_secret,
|
|
|
|
|
keys->server_write_MAC_secret, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->server_write_MAC_secret,&keyData[i], sz);
|
2018-07-25 11:22:48 +10:00
|
|
|
#endif
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2012-06-26 15:51:40 -07:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
sz = ssl->specs.key_size;
|
2017-06-19 11:37:10 +10:00
|
|
|
if (side & PROVISION_CLIENT) {
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_key,
|
|
|
|
|
keys->client_write_key, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->client_write_key, &keyData[i], sz);
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
|
|
|
|
if (side & PROVISION_SERVER) {
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_key,
|
|
|
|
|
keys->server_write_key, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->server_write_key, &keyData[i], sz);
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
sz = ssl->specs.iv_size;
|
2017-06-19 11:37:10 +10:00
|
|
|
if (side & PROVISION_CLIENT) {
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.client_write_IV,
|
|
|
|
|
keys->client_write_IV, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->client_write_IV, &keyData[i], sz);
|
2024-05-08 10:14:53 -04:00
|
|
|
i += (int)sz;
|
2017-06-19 11:37:10 +10:00
|
|
|
}
|
2020-05-19 14:11:05 +02:00
|
|
|
if (side & PROVISION_SERVER) {
|
|
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
|
|
|
|
XMEMCPY(ssl->keys.server_write_IV,
|
|
|
|
|
keys->server_write_IV, sz);
|
|
|
|
|
#endif
|
2017-06-19 11:37:10 +10:00
|
|
|
XMEMCPY(keys->server_write_IV, &keyData[i], sz);
|
2020-05-19 14:11:05 +02:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2013-01-14 15:59:53 -08:00
|
|
|
#ifdef HAVE_AEAD
|
|
|
|
|
if (ssl->specs.cipher_type == aead) {
|
2013-08-27 10:44:04 -07:00
|
|
|
/* Initialize the AES-GCM/CCM explicit IV to a zero. */
|
2020-05-19 14:11:05 +02:00
|
|
|
#ifdef WOLFSSL_DTLS
|
|
|
|
|
if (scr_copy)
|
2020-06-04 21:05:07 -07:00
|
|
|
XMEMMOVE(ssl->keys.aead_exp_IV,
|
2020-05-19 14:11:05 +02:00
|
|
|
keys->aead_exp_IV, AEAD_MAX_EXP_SZ);
|
|
|
|
|
#endif
|
2016-01-29 09:38:13 -07:00
|
|
|
XMEMSET(keys->aead_exp_IV, 0, AEAD_MAX_EXP_SZ);
|
2013-01-14 15:59:53 -08:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-24 11:27:13 -07:00
|
|
|
return 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
2012-11-26 18:40:43 -08:00
|
|
|
#ifndef NO_OLD_TLS
|
2014-12-19 11:27:01 -07:00
|
|
|
int DeriveKeys(WOLFSSL* ssl)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2017-04-06 14:42:42 -06:00
|
|
|
int length = 2 * ssl->specs.hash_size +
|
2014-08-05 15:26:28 -07:00
|
|
|
2 * ssl->specs.key_size +
|
|
|
|
|
2 * ssl->specs.iv_size;
|
2023-04-03 16:51:07 +10:00
|
|
|
int rounds = (length + WC_MD5_DIGEST_SIZE - 1 ) / WC_MD5_DIGEST_SIZE;
|
2014-08-05 15:26:28 -07:00
|
|
|
int ret = 0;
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
2014-08-05 15:26:28 -07:00
|
|
|
byte* shaOutput;
|
|
|
|
|
byte* md5Input;
|
|
|
|
|
byte* shaInput;
|
|
|
|
|
byte* keyData;
|
2017-09-25 18:47:36 -07:00
|
|
|
wc_Md5* md5;
|
|
|
|
|
wc_Sha* sha;
|
2014-08-05 15:26:28 -07:00
|
|
|
#else
|
2017-09-25 18:47:36 -07:00
|
|
|
byte shaOutput[WC_SHA_DIGEST_SIZE];
|
|
|
|
|
byte md5Input[SECRET_LEN + WC_SHA_DIGEST_SIZE];
|
2014-08-11 14:17:44 -07:00
|
|
|
byte shaInput[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN];
|
2017-09-25 18:47:36 -07:00
|
|
|
byte keyData[KEY_PREFIX * WC_MD5_DIGEST_SIZE];
|
|
|
|
|
wc_Md5 md5[1];
|
|
|
|
|
wc_Sha sha[1];
|
2014-08-05 15:26:28 -07:00
|
|
|
#endif
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
2017-09-25 18:47:36 -07:00
|
|
|
shaOutput = (byte*)XMALLOC(WC_SHA_DIGEST_SIZE,
|
2014-08-05 15:26:28 -07:00
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2017-09-25 18:47:36 -07:00
|
|
|
md5Input = (byte*)XMALLOC(SECRET_LEN + WC_SHA_DIGEST_SIZE,
|
2014-08-11 14:17:44 -07:00
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
shaInput = (byte*)XMALLOC(KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN,
|
|
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2017-09-25 18:47:36 -07:00
|
|
|
keyData = (byte*)XMALLOC(KEY_PREFIX * WC_MD5_DIGEST_SIZE,
|
2014-08-11 14:17:44 -07:00
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2017-09-25 18:47:36 -07:00
|
|
|
md5 = (wc_Md5*)XMALLOC(sizeof(wc_Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
sha = (wc_Sha*)XMALLOC(sizeof(wc_Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
|
|
|
|
|
keyData == NULL || md5 == NULL || sha == NULL) {
|
2024-08-06 10:20:45 -04:00
|
|
|
XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2020-05-27 13:17:31 -07:00
|
|
|
XMEMSET(shaOutput, 0, WC_SHA_DIGEST_SIZE);
|
2016-12-19 12:15:10 -08:00
|
|
|
ret = wc_InitMd5(md5);
|
2017-04-06 15:47:53 -06:00
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_InitSha(sha);
|
|
|
|
|
}
|
2014-08-05 15:26:28 -07:00
|
|
|
if (ret == 0) {
|
2023-04-03 16:51:07 +10:00
|
|
|
int i;
|
|
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
XMEMCPY(md5Input, ssl->arrays->masterSecret, SECRET_LEN);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
for (i = 0; i < rounds; ++i) {
|
|
|
|
|
int j = i + 1;
|
|
|
|
|
int idx = j;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
if (!SetPrefix(shaInput, i)) {
|
|
|
|
|
ret = PREFIX_ERROR;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->masterSecret, SECRET_LEN);
|
|
|
|
|
idx += SECRET_LEN;
|
|
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN);
|
|
|
|
|
idx += RAN_LEN;
|
|
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN);
|
2017-05-16 10:04:30 -06:00
|
|
|
if (ret == 0) {
|
2017-04-07 14:15:53 -06:00
|
|
|
ret = wc_ShaUpdate(sha, shaInput,
|
2025-02-21 21:40:53 +01:00
|
|
|
(KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN) - KEY_PREFIX +
|
|
|
|
|
(word32)(j));
|
2017-04-07 14:15:53 -06:00
|
|
|
}
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_ShaFinal(sha, shaOutput);
|
|
|
|
|
}
|
2014-08-05 15:26:28 -07:00
|
|
|
|
2017-09-25 18:47:36 -07:00
|
|
|
XMEMCPY(md5Input + SECRET_LEN, shaOutput, WC_SHA_DIGEST_SIZE);
|
2017-04-07 14:15:53 -06:00
|
|
|
if (ret == 0) {
|
2017-09-25 18:47:36 -07:00
|
|
|
ret = wc_Md5Update(md5, md5Input, SECRET_LEN + WC_SHA_DIGEST_SIZE);
|
2017-04-07 14:15:53 -06:00
|
|
|
}
|
2017-04-06 15:47:53 -06:00
|
|
|
if (ret == 0) {
|
2017-09-25 18:47:36 -07:00
|
|
|
ret = wc_Md5Final(md5, keyData + i * WC_MD5_DIGEST_SIZE);
|
2017-04-06 15:47:53 -06:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
2014-08-05 15:26:28 -07:00
|
|
|
if (ret == 0)
|
2017-06-19 11:37:10 +10:00
|
|
|
ret = StoreKeys(ssl, keyData, PROVISION_CLIENT_SERVER);
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
2025-09-10 12:22:06 +10:00
|
|
|
WC_FREE_VAR_EX(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(keyData, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2014-08-05 15:26:28 -07:00
|
|
|
|
|
|
|
|
return ret;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
static int CleanPreMaster(WOLFSSL* ssl)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2025-02-21 21:40:53 +01:00
|
|
|
int i, ret, sz = (int)(ssl->arrays->preMasterSz);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
for (i = 0; i < sz; i++)
|
2012-09-14 21:19:06 -07:00
|
|
|
ssl->arrays->preMasterSecret[i] = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2025-02-21 21:40:53 +01:00
|
|
|
ret = wc_RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret,
|
|
|
|
|
(word32)(sz));
|
2014-04-14 16:28:43 -03:00
|
|
|
if (ret != 0)
|
|
|
|
|
return ret;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
|
|
|
|
for (i = 0; i < sz; i++)
|
2012-09-14 21:19:06 -07:00
|
|
|
ssl->arrays->preMasterSecret[i] = 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2018-08-21 09:03:11 +10:00
|
|
|
XFREE(ssl->arrays->preMasterSecret, ssl->heap, DYNAMIC_TYPE_SECRET);
|
|
|
|
|
ssl->arrays->preMasterSecret = NULL;
|
2019-02-19 12:49:57 -08:00
|
|
|
ssl->arrays->preMasterSz = 0;
|
2018-08-21 09:03:11 +10:00
|
|
|
|
2014-04-14 16:28:43 -03:00
|
|
|
return 0;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create and store the master secret see page 32, 6.1 */
|
2014-12-19 11:27:01 -07:00
|
|
|
static int MakeSslMasterSecret(WOLFSSL* ssl)
|
2011-02-05 11:14:47 -08:00
|
|
|
{
|
2011-02-28 12:21:06 -08:00
|
|
|
int i, ret;
|
2011-02-05 11:14:47 -08:00
|
|
|
word32 idx;
|
2012-09-14 21:19:06 -07:00
|
|
|
word32 pmsSz = ssl->arrays->preMasterSz;
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
2014-08-11 14:17:44 -07:00
|
|
|
byte* shaOutput;
|
|
|
|
|
byte* md5Input;
|
|
|
|
|
byte* shaInput;
|
2017-09-25 18:47:36 -07:00
|
|
|
wc_Md5* md5;
|
|
|
|
|
wc_Sha* sha;
|
2014-08-11 14:17:44 -07:00
|
|
|
#else
|
2017-09-25 18:47:36 -07:00
|
|
|
byte shaOutput[WC_SHA_DIGEST_SIZE];
|
|
|
|
|
byte md5Input[ENCRYPT_LEN + WC_SHA_DIGEST_SIZE];
|
2014-08-11 14:17:44 -07:00
|
|
|
byte shaInput[PREFIX + ENCRYPT_LEN + 2 * RAN_LEN];
|
2017-09-25 18:47:36 -07:00
|
|
|
wc_Md5 md5[1];
|
|
|
|
|
wc_Sha sha[1];
|
2014-08-11 14:17:44 -07:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2021-10-19 16:22:39 -07:00
|
|
|
if (ssl->arrays->preMasterSecret == NULL) {
|
|
|
|
|
return BAD_FUNC_ARG;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-05 11:14:47 -08:00
|
|
|
#ifdef SHOW_SECRETS
|
|
|
|
|
{
|
2013-03-04 13:25:46 -08:00
|
|
|
word32 j;
|
2011-02-05 11:14:47 -08:00
|
|
|
printf("pre master secret: ");
|
|
|
|
|
for (j = 0; j < pmsSz; j++)
|
2012-09-14 21:19:06 -07:00
|
|
|
printf("%02x", ssl->arrays->preMasterSecret[j]);
|
2011-02-05 11:14:47 -08:00
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2015-07-07 09:55:58 -06:00
|
|
|
|
2014-12-19 11:27:01 -07:00
|
|
|
#ifdef WOLFSSL_SMALL_STACK
|
2017-09-25 18:47:36 -07:00
|
|
|
shaOutput = (byte*)XMALLOC(WC_SHA_DIGEST_SIZE,
|
2014-08-11 14:17:44 -07:00
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2017-09-25 18:47:36 -07:00
|
|
|
md5Input = (byte*)XMALLOC(ENCRYPT_LEN + WC_SHA_DIGEST_SIZE,
|
2014-08-11 14:17:44 -07:00
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
shaInput = (byte*)XMALLOC(PREFIX + ENCRYPT_LEN + 2 * RAN_LEN,
|
|
|
|
|
NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2017-09-25 18:47:36 -07:00
|
|
|
md5 = (wc_Md5*)XMALLOC(sizeof(wc_Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
sha = (wc_Sha*)XMALLOC(sizeof(wc_Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-08-11 14:17:44 -07:00
|
|
|
if (shaOutput == NULL || md5Input == NULL || shaInput == NULL ||
|
|
|
|
|
md5 == NULL || sha == NULL) {
|
2024-08-06 10:20:45 -04:00
|
|
|
XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2016-12-19 12:15:10 -08:00
|
|
|
|
2014-08-11 14:17:44 -07:00
|
|
|
return MEMORY_E;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
|
|
|
|
#endif
|
2020-05-27 13:17:31 -07:00
|
|
|
XMEMSET(shaOutput, 0, WC_SHA_DIGEST_SIZE);
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2016-12-19 12:15:10 -08:00
|
|
|
ret = wc_InitMd5(md5);
|
2017-04-06 15:47:53 -06:00
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_InitSha(sha);
|
|
|
|
|
}
|
2014-08-11 14:17:44 -07:00
|
|
|
if (ret == 0) {
|
|
|
|
|
XMEMCPY(md5Input, ssl->arrays->preMasterSecret, pmsSz);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < MASTER_ROUNDS; ++i) {
|
|
|
|
|
byte prefix[KEY_PREFIX]; /* only need PREFIX bytes but static */
|
|
|
|
|
if (!SetPrefix(prefix, i)) { /* analysis thinks will overrun */
|
|
|
|
|
ret = PREFIX_ERROR;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idx = 0;
|
2025-02-21 21:40:53 +01:00
|
|
|
XMEMCPY(shaInput, prefix, (size_t)(i + 1));
|
|
|
|
|
idx += (word32)(i + 1);
|
2014-08-11 14:17:44 -07:00
|
|
|
|
|
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->preMasterSecret, pmsSz);
|
|
|
|
|
idx += pmsSz;
|
|
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->clientRandom, RAN_LEN);
|
|
|
|
|
idx += RAN_LEN;
|
|
|
|
|
XMEMCPY(shaInput + idx, ssl->arrays->serverRandom, RAN_LEN);
|
|
|
|
|
idx += RAN_LEN;
|
2017-05-16 10:04:30 -06:00
|
|
|
if (ret == 0) {
|
2017-04-07 14:15:53 -06:00
|
|
|
ret = wc_ShaUpdate(sha, shaInput, idx);
|
|
|
|
|
}
|
|
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_ShaFinal(sha, shaOutput);
|
|
|
|
|
}
|
2014-08-11 14:17:44 -07:00
|
|
|
idx = pmsSz; /* preSz */
|
2017-09-25 18:47:36 -07:00
|
|
|
XMEMCPY(md5Input + idx, shaOutput, WC_SHA_DIGEST_SIZE);
|
|
|
|
|
idx += WC_SHA_DIGEST_SIZE;
|
2017-04-07 14:15:53 -06:00
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_Md5Update(md5, md5Input, idx);
|
|
|
|
|
}
|
2017-04-06 15:47:53 -06:00
|
|
|
if (ret == 0) {
|
|
|
|
|
ret = wc_Md5Final(md5,
|
2017-09-25 18:47:36 -07:00
|
|
|
&ssl->arrays->masterSecret[i * WC_MD5_DIGEST_SIZE]);
|
2017-04-06 15:47:53 -06:00
|
|
|
}
|
2014-08-11 14:17:44 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef SHOW_SECRETS
|
|
|
|
|
{
|
|
|
|
|
word32 j;
|
|
|
|
|
printf("master secret: ");
|
|
|
|
|
for (j = 0; j < SECRET_LEN; j++)
|
|
|
|
|
printf("%02x", ssl->arrays->masterSecret[j]);
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
|
ret = DeriveKeys(ssl);
|
2014-04-14 16:28:43 -03:00
|
|
|
}
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2025-09-10 12:22:06 +10:00
|
|
|
WC_FREE_VAR_EX(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
|
|
|
|
WC_FREE_VAR_EX(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
2015-07-07 09:55:58 -06:00
|
|
|
|
2014-08-11 14:17:44 -07:00
|
|
|
if (ret == 0)
|
|
|
|
|
ret = CleanPreMaster(ssl);
|
|
|
|
|
else
|
|
|
|
|
CleanPreMaster(ssl);
|
|
|
|
|
|
|
|
|
|
return ret;
|
2011-02-05 11:14:47 -08:00
|
|
|
}
|
2012-11-26 18:40:43 -08:00
|
|
|
#endif
|
2011-02-05 11:14:47 -08:00
|
|
|
|
2012-09-04 16:03:45 -07:00
|
|
|
|
|
|
|
|
/* Master wrapper, doesn't use SSL stack space in TLS mode */
|
2014-12-19 11:27:01 -07:00
|
|
|
int MakeMasterSecret(WOLFSSL* ssl)
|
2012-09-04 16:03:45 -07:00
|
|
|
{
|
2015-07-07 09:55:58 -06:00
|
|
|
/* append secret to premaster : premaster | SerSi | CliSi */
|
2012-11-26 18:40:43 -08:00
|
|
|
#ifndef NO_OLD_TLS
|
2018-05-17 09:08:03 +10:00
|
|
|
if (ssl->options.tls) return MakeTlsMasterSecret(ssl);
|
2012-09-04 16:03:45 -07:00
|
|
|
return MakeSslMasterSecret(ssl);
|
2022-07-14 11:07:46 -05:00
|
|
|
#elif !defined(WOLFSSL_NO_TLS12) && !defined(NO_TLS)
|
2018-05-17 09:08:03 +10:00
|
|
|
return MakeTlsMasterSecret(ssl);
|
|
|
|
|
#else
|
|
|
|
|
(void)ssl;
|
|
|
|
|
return 0;
|
2012-11-26 18:40:43 -08:00
|
|
|
#endif
|
2012-09-04 16:03:45 -07:00
|
|
|
}
|
|
|
|
|
|
2024-12-10 14:10:15 -08:00
|
|
|
#endif /* !WOLFCRYPT_ONLY && !NO_TLS */
|