mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-12-24 17:41:01 +03:00
Merge remote-tracking branch 'origin/development' into support_cipher_encrypt_only
This commit is contained in:
@@ -6,19 +6,7 @@
|
||||
* \author Adriaan de Jong <dejong@fox-it.com>
|
||||
*
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
@@ -80,7 +68,7 @@ enum mbedtls_cipher_base_index {
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
MBEDTLS_CIPHER_BASE_INDEX_CCM_AES,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_ARIA_C)
|
||||
@@ -104,7 +92,7 @@ enum mbedtls_cipher_base_index {
|
||||
#if defined(MBEDTLS_DES_C)
|
||||
MBEDTLS_CIPHER_BASE_INDEX_DES,
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
MBEDTLS_CIPHER_BASE_INDEX_GCM_AES,
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_ARIA_C)
|
||||
@@ -572,15 +560,18 @@ static const mbedtls_cipher_info_t aes_256_xts_info = {
|
||||
};
|
||||
#endif
|
||||
#endif /* MBEDTLS_CIPHER_MODE_XTS */
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
|
||||
static int gcm_aes_setkey_wrap(void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen)
|
||||
{
|
||||
return mbedtls_gcm_setkey((mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
|
||||
key, key_bitlen);
|
||||
}
|
||||
#endif /* MBEDTLS_GCM_C && MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
static const mbedtls_cipher_base_t gcm_aes_info = {
|
||||
MBEDTLS_CIPHER_ID_AES,
|
||||
NULL,
|
||||
@@ -602,14 +593,23 @@ static const mbedtls_cipher_base_t gcm_aes_info = {
|
||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
gcm_aes_setkey_wrap,
|
||||
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
|
||||
gcm_aes_setkey_wrap,
|
||||
#endif
|
||||
gcm_ctx_alloc,
|
||||
gcm_ctx_free,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#endif /* MBEDTLS_GCM_C */
|
||||
};
|
||||
#endif /* MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
static const mbedtls_cipher_info_t aes_128_gcm_info = {
|
||||
"AES-128-GCM",
|
||||
16,
|
||||
@@ -644,16 +644,18 @@ static const mbedtls_cipher_info_t aes_256_gcm_info = {
|
||||
MBEDTLS_CIPHER_BASE_INDEX_GCM_AES
|
||||
};
|
||||
#endif
|
||||
#endif /* MBEDTLS_GCM_C */
|
||||
#endif /* MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA */
|
||||
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
|
||||
static int ccm_aes_setkey_wrap(void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen)
|
||||
{
|
||||
return mbedtls_ccm_setkey((mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_AES,
|
||||
key, key_bitlen);
|
||||
}
|
||||
#endif /* MBEDTLS_CCM_C && MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
static const mbedtls_cipher_base_t ccm_aes_info = {
|
||||
MBEDTLS_CIPHER_ID_AES,
|
||||
NULL,
|
||||
@@ -675,14 +677,23 @@ static const mbedtls_cipher_base_t ccm_aes_info = {
|
||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
ccm_aes_setkey_wrap,
|
||||
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
|
||||
ccm_aes_setkey_wrap,
|
||||
#endif
|
||||
ccm_ctx_alloc,
|
||||
ccm_ctx_free,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
};
|
||||
#endif /* MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
static const mbedtls_cipher_info_t aes_128_ccm_info = {
|
||||
"AES-128-CCM",
|
||||
16,
|
||||
@@ -717,7 +728,9 @@ static const mbedtls_cipher_info_t aes_256_ccm_info = {
|
||||
MBEDTLS_CIPHER_BASE_INDEX_CCM_AES
|
||||
};
|
||||
#endif
|
||||
#endif /* MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA */
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
static const mbedtls_cipher_info_t aes_128_ccm_star_no_tag_info = {
|
||||
"AES-128-CCM*-NO-TAG",
|
||||
16,
|
||||
@@ -752,9 +765,8 @@ static const mbedtls_cipher_info_t aes_256_ccm_star_no_tag_info = {
|
||||
MBEDTLS_CIPHER_BASE_INDEX_CCM_AES
|
||||
};
|
||||
#endif
|
||||
#endif /* MBEDTLS_CCM_C */
|
||||
#endif /* MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA */
|
||||
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
|
||||
@@ -2275,26 +2287,28 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
{ MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info },
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C)
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
{ MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info },
|
||||
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
|
||||
{ MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info },
|
||||
{ MBEDTLS_CIPHER_AES_256_GCM, &aes_256_gcm_info },
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C)
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
{ MBEDTLS_CIPHER_AES_128_CCM, &aes_128_ccm_info },
|
||||
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
|
||||
{ MBEDTLS_CIPHER_AES_192_CCM, &aes_192_ccm_info },
|
||||
{ MBEDTLS_CIPHER_AES_256_CCM, &aes_256_ccm_info },
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_STAR_NO_TAG_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
{ MBEDTLS_CIPHER_AES_128_CCM_STAR_NO_TAG, &aes_128_ccm_star_no_tag_info },
|
||||
#if !defined(MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH)
|
||||
{ MBEDTLS_CIPHER_AES_192_CCM_STAR_NO_TAG, &aes_192_ccm_star_no_tag_info },
|
||||
{ MBEDTLS_CIPHER_AES_256_CCM_STAR_NO_TAG, &aes_256_ccm_star_no_tag_info },
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_AES_C */
|
||||
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
{ MBEDTLS_CIPHER_CAMELLIA_128_ECB, &camellia_128_ecb_info },
|
||||
@@ -2417,7 +2431,7 @@ const mbedtls_cipher_base_t *mbedtls_cipher_base_lookup_table[] = {
|
||||
#if defined(MBEDTLS_CAMELLIA_C)
|
||||
[MBEDTLS_CIPHER_BASE_INDEX_CAMELLIA] = &camellia_info,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_CCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
[MBEDTLS_CIPHER_BASE_INDEX_CCM_AES] = &ccm_aes_info,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_ARIA_C)
|
||||
@@ -2441,7 +2455,7 @@ const mbedtls_cipher_base_t *mbedtls_cipher_base_lookup_table[] = {
|
||||
#if defined(MBEDTLS_DES_C)
|
||||
[MBEDTLS_CIPHER_BASE_INDEX_DES] = &des_info,
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
|
||||
#if defined(MBEDTLS_CIPHER_HAVE_GCM_AES_VIA_LEGACY_OR_USE_PSA)
|
||||
[MBEDTLS_CIPHER_BASE_INDEX_GCM_AES] = &gcm_aes_info,
|
||||
#endif
|
||||
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_ARIA_C)
|
||||
|
||||
Reference in New Issue
Block a user