mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Externals: Update mbedtls to 2.28.0
This commit is contained in:
174
Externals/mbedtls/library/cipher_wrap.c
vendored
174
Externals/mbedtls/library/cipher_wrap.c
vendored
@ -5,7 +5,7 @@
|
||||
*
|
||||
* \author Adriaan de Jong <dejong@fox-it.com>
|
||||
*
|
||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -19,19 +19,14 @@
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
#include "common.h"
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_C)
|
||||
|
||||
#include "mbedtls/cipher_internal.h"
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
#if defined(MBEDTLS_CHACHAPOLY_C)
|
||||
#include "mbedtls/chachapoly.h"
|
||||
@ -73,6 +68,10 @@
|
||||
#include "mbedtls/ccm.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_NIST_KW_C)
|
||||
#include "mbedtls/nist_kw.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
#include <string.h>
|
||||
#endif
|
||||
@ -754,7 +753,7 @@ static const mbedtls_cipher_info_t camellia_128_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"CAMELLIA-128-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&camellia_info
|
||||
@ -765,7 +764,7 @@ static const mbedtls_cipher_info_t camellia_192_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
192,
|
||||
"CAMELLIA-192-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&camellia_info
|
||||
@ -776,7 +775,7 @@ static const mbedtls_cipher_info_t camellia_256_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
256,
|
||||
"CAMELLIA-256-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&camellia_info
|
||||
@ -1130,7 +1129,7 @@ static const mbedtls_cipher_info_t aria_128_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"ARIA-128-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aria_info
|
||||
@ -1141,7 +1140,7 @@ static const mbedtls_cipher_info_t aria_192_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
192,
|
||||
"ARIA-192-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aria_info
|
||||
@ -1152,7 +1151,7 @@ static const mbedtls_cipher_info_t aria_256_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
256,
|
||||
"ARIA-256-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aria_info
|
||||
@ -1554,7 +1553,7 @@ static const mbedtls_cipher_info_t des_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
MBEDTLS_KEY_LENGTH_DES,
|
||||
"DES-ECB",
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
&des_info
|
||||
@ -1605,7 +1604,7 @@ static const mbedtls_cipher_info_t des_ede_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
MBEDTLS_KEY_LENGTH_DES_EDE,
|
||||
"DES-EDE-ECB",
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
&des_ede_info
|
||||
@ -1656,7 +1655,7 @@ static const mbedtls_cipher_info_t des_ede3_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
MBEDTLS_KEY_LENGTH_DES_EDE3,
|
||||
"DES-EDE3-ECB",
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
&des_ede3_info
|
||||
@ -1771,7 +1770,7 @@ static const mbedtls_cipher_info_t blowfish_ecb_info = {
|
||||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"BLOWFISH-ECB",
|
||||
8,
|
||||
0,
|
||||
MBEDTLS_CIPHER_VARIABLE_KEY_LEN,
|
||||
8,
|
||||
&blowfish_info
|
||||
@ -1912,7 +1911,7 @@ static int chacha20_stream_wrap( void *ctx, size_t length,
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
int ret;
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
|
||||
ret = mbedtls_chacha20_update( ctx, length, input, output );
|
||||
if( ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA )
|
||||
@ -2119,6 +2118,131 @@ static const mbedtls_cipher_info_t null_cipher_info = {
|
||||
};
|
||||
#endif /* defined(MBEDTLS_CIPHER_NULL_CIPHER) */
|
||||
|
||||
#if defined(MBEDTLS_NIST_KW_C)
|
||||
static void *kw_ctx_alloc( void )
|
||||
{
|
||||
void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_nist_kw_context ) );
|
||||
|
||||
if( ctx != NULL )
|
||||
mbedtls_nist_kw_init( (mbedtls_nist_kw_context *) ctx );
|
||||
|
||||
return( ctx );
|
||||
}
|
||||
|
||||
static void kw_ctx_free( void *ctx )
|
||||
{
|
||||
mbedtls_nist_kw_free( ctx );
|
||||
mbedtls_free( ctx );
|
||||
}
|
||||
|
||||
static int kw_aes_setkey_wrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen )
|
||||
{
|
||||
return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
|
||||
MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 1 );
|
||||
}
|
||||
|
||||
static int kw_aes_setkey_unwrap( void *ctx, const unsigned char *key,
|
||||
unsigned int key_bitlen )
|
||||
{
|
||||
return mbedtls_nist_kw_setkey( (mbedtls_nist_kw_context *) ctx,
|
||||
MBEDTLS_CIPHER_ID_AES, key, key_bitlen, 0 );
|
||||
}
|
||||
|
||||
static const mbedtls_cipher_base_t kw_aes_info = {
|
||||
MBEDTLS_CIPHER_ID_AES,
|
||||
NULL,
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CBC)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_OFB)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_CTR)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_XTS)
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(MBEDTLS_CIPHER_MODE_STREAM)
|
||||
NULL,
|
||||
#endif
|
||||
kw_aes_setkey_wrap,
|
||||
kw_aes_setkey_unwrap,
|
||||
kw_ctx_alloc,
|
||||
kw_ctx_free,
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_128_nist_kw_info = {
|
||||
MBEDTLS_CIPHER_AES_128_KW,
|
||||
MBEDTLS_MODE_KW,
|
||||
128,
|
||||
"AES-128-KW",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_192_nist_kw_info = {
|
||||
MBEDTLS_CIPHER_AES_192_KW,
|
||||
MBEDTLS_MODE_KW,
|
||||
192,
|
||||
"AES-192-KW",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_256_nist_kw_info = {
|
||||
MBEDTLS_CIPHER_AES_256_KW,
|
||||
MBEDTLS_MODE_KW,
|
||||
256,
|
||||
"AES-256-KW",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_128_nist_kwp_info = {
|
||||
MBEDTLS_CIPHER_AES_128_KWP,
|
||||
MBEDTLS_MODE_KWP,
|
||||
128,
|
||||
"AES-128-KWP",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_192_nist_kwp_info = {
|
||||
MBEDTLS_CIPHER_AES_192_KWP,
|
||||
MBEDTLS_MODE_KWP,
|
||||
192,
|
||||
"AES-192-KWP",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
|
||||
static const mbedtls_cipher_info_t aes_256_nist_kwp_info = {
|
||||
MBEDTLS_CIPHER_AES_256_KWP,
|
||||
MBEDTLS_MODE_KWP,
|
||||
256,
|
||||
"AES-256-KWP",
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&kw_aes_info
|
||||
};
|
||||
#endif /* MBEDTLS_NIST_KW_C */
|
||||
|
||||
const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
{
|
||||
#if defined(MBEDTLS_AES_C)
|
||||
@ -2259,6 +2383,15 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
{ MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info },
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_NIST_KW_C)
|
||||
{ MBEDTLS_CIPHER_AES_128_KW, &aes_128_nist_kw_info },
|
||||
{ MBEDTLS_CIPHER_AES_192_KW, &aes_192_nist_kw_info },
|
||||
{ MBEDTLS_CIPHER_AES_256_KW, &aes_256_nist_kw_info },
|
||||
{ MBEDTLS_CIPHER_AES_128_KWP, &aes_128_nist_kwp_info },
|
||||
{ MBEDTLS_CIPHER_AES_192_KWP, &aes_192_nist_kwp_info },
|
||||
{ MBEDTLS_CIPHER_AES_256_KWP, &aes_256_nist_kwp_info },
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CIPHER_NULL_CIPHER)
|
||||
{ MBEDTLS_CIPHER_NULL, &null_cipher_info },
|
||||
#endif /* MBEDTLS_CIPHER_NULL_CIPHER */
|
||||
@ -2266,7 +2399,8 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] =
|
||||
{ MBEDTLS_CIPHER_NONE, NULL }
|
||||
};
|
||||
|
||||
#define NUM_CIPHERS sizeof mbedtls_cipher_definitions / sizeof mbedtls_cipher_definitions[0]
|
||||
#define NUM_CIPHERS ( sizeof(mbedtls_cipher_definitions) / \
|
||||
sizeof(mbedtls_cipher_definitions[0]) )
|
||||
int mbedtls_cipher_supported[NUM_CIPHERS];
|
||||
|
||||
#endif /* MBEDTLS_CIPHER_C */
|
||||
|
Reference in New Issue
Block a user