Skip to content

Commit f263821

Browse files
committed
5.0.099
1 parent eb0e688 commit f263821

File tree

175 files changed

+99113
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+99113
-0
lines changed

thirdparty/user_include/mbedtls2/mbedtls/aes.h

+689
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/**
2+
* \file aesni.h
3+
*
4+
* \brief AES-NI for hardware AES acceleration on some Intel processors
5+
*
6+
* \warning These functions are only for internal use by other library
7+
* functions; you must not call them directly.
8+
*/
9+
/*
10+
* Copyright The Mbed TLS Contributors
11+
* SPDX-License-Identifier: Apache-2.0
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
14+
* not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*/
25+
#ifndef MBEDTLS_AESNI_H
26+
#define MBEDTLS_AESNI_H
27+
28+
#if !defined(MBEDTLS_CONFIG_FILE)
29+
#include "mbedtls/config.h"
30+
#else
31+
#include MBEDTLS_CONFIG_FILE
32+
#endif
33+
34+
#include "mbedtls/aes.h"
35+
36+
#define MBEDTLS_AESNI_AES 0x02000000u
37+
#define MBEDTLS_AESNI_CLMUL 0x00000002u
38+
39+
#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \
40+
( defined(__amd64__) || defined(__x86_64__) ) && \
41+
! defined(MBEDTLS_HAVE_X86_64)
42+
#define MBEDTLS_HAVE_X86_64
43+
#endif
44+
45+
#if defined(MBEDTLS_HAVE_X86_64)
46+
47+
#ifdef __cplusplus
48+
extern "C" {
49+
#endif
50+
51+
/**
52+
* \brief Internal function to detect the AES-NI feature in CPUs.
53+
*
54+
* \note This function is only for internal use by other library
55+
* functions; you must not call it directly.
56+
*
57+
* \param what The feature to detect
58+
* (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL)
59+
*
60+
* \return 1 if CPU has support for the feature, 0 otherwise
61+
*/
62+
int mbedtls_aesni_has_support( unsigned int what );
63+
64+
/**
65+
* \brief Internal AES-NI AES-ECB block encryption and decryption
66+
*
67+
* \note This function is only for internal use by other library
68+
* functions; you must not call it directly.
69+
*
70+
* \param ctx AES context
71+
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
72+
* \param input 16-byte input block
73+
* \param output 16-byte output block
74+
*
75+
* \return 0 on success (cannot fail)
76+
*/
77+
int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx,
78+
int mode,
79+
const unsigned char input[16],
80+
unsigned char output[16] );
81+
82+
/**
83+
* \brief Internal GCM multiplication: c = a * b in GF(2^128)
84+
*
85+
* \note This function is only for internal use by other library
86+
* functions; you must not call it directly.
87+
*
88+
* \param c Result
89+
* \param a First operand
90+
* \param b Second operand
91+
*
92+
* \note Both operands and result are bit strings interpreted as
93+
* elements of GF(2^128) as per the GCM spec.
94+
*/
95+
void mbedtls_aesni_gcm_mult( unsigned char c[16],
96+
const unsigned char a[16],
97+
const unsigned char b[16] );
98+
99+
/**
100+
* \brief Internal round key inversion. This function computes
101+
* decryption round keys from the encryption round keys.
102+
*
103+
* \note This function is only for internal use by other library
104+
* functions; you must not call it directly.
105+
*
106+
* \param invkey Round keys for the equivalent inverse cipher
107+
* \param fwdkey Original round keys (for encryption)
108+
* \param nr Number of rounds (that is, number of round keys minus one)
109+
*/
110+
void mbedtls_aesni_inverse_key( unsigned char *invkey,
111+
const unsigned char *fwdkey,
112+
int nr );
113+
114+
/**
115+
* \brief Internal key expansion for encryption
116+
*
117+
* \note This function is only for internal use by other library
118+
* functions; you must not call it directly.
119+
*
120+
* \param rk Destination buffer where the round keys are written
121+
* \param key Encryption key
122+
* \param bits Key size in bits (must be 128, 192 or 256)
123+
*
124+
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
125+
*/
126+
int mbedtls_aesni_setkey_enc( unsigned char *rk,
127+
const unsigned char *key,
128+
size_t bits );
129+
130+
#ifdef __cplusplus
131+
}
132+
#endif
133+
134+
#endif /* MBEDTLS_HAVE_X86_64 */
135+
136+
#endif /* MBEDTLS_AESNI_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/**
2+
* \file arc4.h
3+
*
4+
* \brief The ARCFOUR stream cipher
5+
*
6+
* \warning ARC4 is considered a weak cipher and its use constitutes a
7+
* security risk. We recommend considering stronger ciphers instead.
8+
*/
9+
/*
10+
* Copyright The Mbed TLS Contributors
11+
* SPDX-License-Identifier: Apache-2.0
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
14+
* not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
21+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*
25+
*/
26+
#ifndef MBEDTLS_ARC4_H
27+
#define MBEDTLS_ARC4_H
28+
29+
#if !defined(MBEDTLS_CONFIG_FILE)
30+
#include "mbedtls/config.h"
31+
#else
32+
#include MBEDTLS_CONFIG_FILE
33+
#endif
34+
35+
#include <stddef.h>
36+
37+
/* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */
38+
/** ARC4 hardware accelerator failed. */
39+
#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019
40+
41+
#ifdef __cplusplus
42+
extern "C" {
43+
#endif
44+
45+
#if !defined(MBEDTLS_ARC4_ALT)
46+
// Regular implementation
47+
//
48+
49+
/**
50+
* \brief ARC4 context structure
51+
*
52+
* \warning ARC4 is considered a weak cipher and its use constitutes a
53+
* security risk. We recommend considering stronger ciphers instead.
54+
*
55+
*/
56+
typedef struct mbedtls_arc4_context
57+
{
58+
int x; /*!< permutation index */
59+
int y; /*!< permutation index */
60+
unsigned char m[256]; /*!< permutation table */
61+
}
62+
mbedtls_arc4_context;
63+
64+
#else /* MBEDTLS_ARC4_ALT */
65+
#include "arc4_alt.h"
66+
#endif /* MBEDTLS_ARC4_ALT */
67+
68+
/**
69+
* \brief Initialize ARC4 context
70+
*
71+
* \param ctx ARC4 context to be initialized
72+
*
73+
* \warning ARC4 is considered a weak cipher and its use constitutes a
74+
* security risk. We recommend considering stronger ciphers
75+
* instead.
76+
*
77+
*/
78+
void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
79+
80+
/**
81+
* \brief Clear ARC4 context
82+
*
83+
* \param ctx ARC4 context to be cleared
84+
*
85+
* \warning ARC4 is considered a weak cipher and its use constitutes a
86+
* security risk. We recommend considering stronger ciphers
87+
* instead.
88+
*
89+
*/
90+
void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
91+
92+
/**
93+
* \brief ARC4 key schedule
94+
*
95+
* \param ctx ARC4 context to be setup
96+
* \param key the secret key
97+
* \param keylen length of the key, in bytes
98+
*
99+
* \warning ARC4 is considered a weak cipher and its use constitutes a
100+
* security risk. We recommend considering stronger ciphers
101+
* instead.
102+
*
103+
*/
104+
void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
105+
unsigned int keylen );
106+
107+
/**
108+
* \brief ARC4 cipher function
109+
*
110+
* \param ctx ARC4 context
111+
* \param length length of the input data
112+
* \param input buffer holding the input data
113+
* \param output buffer for the output data
114+
*
115+
* \return 0 if successful
116+
*
117+
* \warning ARC4 is considered a weak cipher and its use constitutes a
118+
* security risk. We recommend considering stronger ciphers
119+
* instead.
120+
*
121+
*/
122+
int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
123+
unsigned char *output );
124+
125+
#if defined(MBEDTLS_SELF_TEST)
126+
127+
/**
128+
* \brief Checkup routine
129+
*
130+
* \return 0 if successful, or 1 if the test failed
131+
*
132+
* \warning ARC4 is considered a weak cipher and its use constitutes a
133+
* security risk. We recommend considering stronger ciphers
134+
* instead.
135+
*
136+
*/
137+
int mbedtls_arc4_self_test( int verbose );
138+
139+
#endif /* MBEDTLS_SELF_TEST */
140+
141+
#ifdef __cplusplus
142+
}
143+
#endif
144+
145+
#endif /* arc4.h */

0 commit comments

Comments
 (0)