Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
c7673b02
Commit
c7673b02
authored
Mar 12, 2018
by
Luiz Felipe Silva
Browse files
Merge remote-tracking branch 'upstream/dev' into dev
parents
ba9a938e
5c8af3c4
Changes
114
Hide whitespace changes
Inline
Side-by-side
app/include/mbedtls/des.h
View file @
c7673b02
...
...
@@ -3,6 +3,11 @@
*
* \brief DES block cipher
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -19,6 +24,7 @@
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*
*/
#ifndef MBEDTLS_DES_H
#define MBEDTLS_DES_H
...
...
@@ -36,6 +42,7 @@
#define MBEDTLS_DES_DECRYPT 0
#define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH -0x0032
/**< The data input has an invalid length. */
#define MBEDTLS_ERR_DES_HW_ACCEL_FAILED -0x0033
/**< DES hardware accelerator failed. */
#define MBEDTLS_DES_KEY_SIZE 8
...
...
@@ -49,6 +56,10 @@ extern "C" {
/**
* \brief DES context structure
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
typedef
struct
{
...
...
@@ -69,6 +80,10 @@ mbedtls_des3_context;
* \brief Initialize DES context
*
* \param ctx DES context to be initialized
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
void
mbedtls_des_init
(
mbedtls_des_context
*
ctx
);
...
...
@@ -76,6 +91,10 @@ void mbedtls_des_init( mbedtls_des_context *ctx );
* \brief Clear DES context
*
* \param ctx DES context to be cleared
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
void
mbedtls_des_free
(
mbedtls_des_context
*
ctx
);
...
...
@@ -100,6 +119,10 @@ void mbedtls_des3_free( mbedtls_des3_context *ctx );
* a parity bit to allow verification.
*
* \param key 8-byte secret key
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
void
mbedtls_des_key_set_parity
(
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
@@ -112,6 +135,10 @@ void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0 is parity was ok, 1 if parity was not correct.
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_key_check_key_parity
(
const
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
@@ -121,6 +148,10 @@ int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SI
* \param key 8-byte secret key
*
* \return 0 if no weak key was found, 1 if a weak key was identified.
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_key_check_weak
(
const
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
@@ -131,6 +162,10 @@ int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_setkey_enc
(
mbedtls_des_context
*
ctx
,
const
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
@@ -141,6 +176,10 @@ int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MB
* \param key 8-byte secret key
*
* \return 0
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_setkey_dec
(
mbedtls_des_context
*
ctx
,
const
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
@@ -196,6 +235,10 @@ int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx,
* \param output 64-bit output block
*
* \return 0 if successful
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_crypt_ecb
(
mbedtls_des_context
*
ctx
,
const
unsigned
char
input
[
8
],
...
...
@@ -219,6 +262,10 @@ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx,
* \param iv initialization vector (updated after use)
* \param input buffer holding the input data
* \param output buffer holding the output data
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
int
mbedtls_des_crypt_cbc
(
mbedtls_des_context
*
ctx
,
int
mode
,
...
...
@@ -277,6 +324,10 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx,
*
* \param SK Round keys
* \param key Base key
*
* \warning DES is considered a weak cipher and its use constitutes a
* security risk. We recommend considering stronger ciphers
* instead.
*/
void
mbedtls_des_setkey
(
uint32_t
SK
[
32
],
const
unsigned
char
key
[
MBEDTLS_DES_KEY_SIZE
]
);
...
...
app/include/mbedtls/dhm.h
View file @
c7673b02
/**
* \file dhm.h
*
* \brief Diffie-Hellman-Merkle key exchange
* \brief Diffie-Hellman-Merkle key exchange
.
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* <em>RFC-3526: More Modular Exponential (MODP) Diffie-Hellman groups for
* Internet Key Exchange (IKE)</em> defines a number of standardized
* Diffie-Hellman groups for IKE.
*
* <em>RFC-5114: Additional Diffie-Hellman Groups for Use with IETF
* Standards</em> defines a number of standardized Diffie-Hellman
* groups that can be used.
*
* \warning The security of the DHM key exchange relies on the proper choice
* of prime modulus - optimally, it should be a safe prime. The usage
* of non-safe primes both decreases the difficulty of the underlying
* discrete logarithm problem and can lead to small subgroup attacks
* leaking private exponent bits when invalid public keys are used
* and not detected. This is especially relevant if the same DHM
* parameters are reused for multiple key exchanges as in static DHM,
* while the criticality of small-subgroup attacks is lower for
* ephemeral DHM.
*
* \warning For performance reasons, the code does neither perform primality
* nor safe primality tests, nor the expensive checks for invalid
* subgroups. Moreover, even if these were performed, non-standardized
* primes cannot be trusted because of the possibility of backdoors
* that can't be effectively checked for.
*
* \warning Diffie-Hellman-Merkle is therefore a security risk when not using
* standardized primes generated using a trustworthy ("nothing up
* my sleeve") method, such as the RFC 3526 / 7919 primes. In the TLS
* protocol, DH parameters need to be negotiated, so using the default
* primes systematically is not always an option. If possible, use
* Elliptic Curve Diffie-Hellman (ECDH), which has better performance,
* and for which the TLS protocol mandates the use of standard
* parameters.
*
*/
/*
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
...
@@ -18,17 +53,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of
m
bed TLS (https://tls.mbed.org)
* This file is part of
M
bed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_DHM_H
#define MBEDTLS_DHM_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "bignum.h"
#if !defined(MBEDTLS_DHM_ALT)
/*
* DHM Error codes
*/
#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080
/**< Bad input parameters
to function
. */
#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080
/**< Bad input parameters. */
#define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100
/**< Reading of the DHM parameters failed. */
#define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180
/**< Making of the DHM parameters failed. */
#define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200
/**< Reading of the public values failed. */
...
...
@@ -36,167 +78,85 @@
#define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300
/**< Calculation of the DHM secret failed. */
#define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380
/**< The ASN.1 data is not formatted correctly. */
#define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400
/**< Allocation of memory failed. */
#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480
/**< Read/write of file failed. */
/**
* RFC 3526 defines a number of standardized Diffie-Hellman groups
* for IKE.
* RFC 5114 defines a number of standardized Diffie-Hellman groups
* that can be used.
*
* Some are included here for convenience.
*
* Included are:
* RFC 3526 3. 2048-bit MODP Group
* RFC 3526 4. 3072-bit MODP Group
* RFC 3526 5. 4096-bit MODP Group
* RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup
*/
#define MBEDTLS_DHM_RFC3526_MODP_2048_P \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AACAA68FFFFFFFFFFFFFFFF"
#define MBEDTLS_DHM_RFC3526_MODP_2048_G "02"
#define MBEDTLS_DHM_RFC3526_MODP_3072_P \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
"ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
"ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
"F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
"BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
"43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
#define MBEDTLS_DHM_RFC3526_MODP_3072_G "02"
#define MBEDTLS_DHM_RFC3526_MODP_4096_P \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
"ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
"ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
"F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
"BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
"43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
"88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
"2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
"287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
"1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
"93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
"FFFFFFFFFFFFFFFF"
#define MBEDTLS_DHM_RFC3526_MODP_4096_G "02"
#define MBEDTLS_DHM_RFC5114_MODP_2048_P \
"AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \
"B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \
"EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \
"9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \
"C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \
"B3BF8A317091883681286130BC8985DB1602E714415D9330" \
"278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \
"CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \
"BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \
"C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \
"CF9DE5384E71B81C0AC4DFFE0C10E64F"
#define MBEDTLS_DHM_RFC5114_MODP_2048_G \
"AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF"\
"74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA"\
"AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7"\
"C17669101999024AF4D027275AC1348BB8A762D0521BC98A"\
"E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE"\
"F180EB34118E98D119529A45D6F834566E3025E316A330EF"\
"BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB"\
"10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381"\
"B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269"\
"EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179"\
"81BC087F2A7065B384B890D3191F2BFA"
#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480
/**< Read or write of file failed. */
#define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500
/**< DHM hardware accelerator failed. */
#define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580
/**< Setting the modulus and generator failed. */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief DHM context structure
* \brief
The
DHM context structure
.
*/
typedef
struct
{
size_t
len
;
/*!< size(P) in chars
*/
mbedtls_mpi
P
;
/*!< prime modulus
*/
mbedtls_mpi
G
;
/*!< generator
*/
mbedtls_mpi
X
;
/*!< secret value
*/
mbedtls_mpi
GX
;
/*!<
self =
G^X mod
P
*/
mbedtls_mpi
GY
;
/*!< peer = G^Y mod
P
*/
mbedtls_mpi
K
;
/*!<
key = GY^X mod P
*/
mbedtls_mpi
RP
;
/*!< cached R^2 mod
P
*/
mbedtls_mpi
Vi
;
/*!< blinding value
*/
mbedtls_mpi
Vf
;
/*!< un
-
blinding value */
mbedtls_mpi
pX
;
/*!< previous
X
*/
size_t
len
;
/*!< The size of \p P in Bytes.
*/
mbedtls_mpi
P
;
/*!<
The
prime modulus
.
*/
mbedtls_mpi
G
;
/*!<
The
generator
.
*/
mbedtls_mpi
X
;
/*!<
Our
secret value
.
*/
mbedtls_mpi
GX
;
/*!<
Our public key = \c
G^X mod
\c P.
*/
mbedtls_mpi
GY
;
/*!<
The public key of the
peer =
\c
G^Y mod
\c P.
*/
mbedtls_mpi
K
;
/*!<
The shared secret = \c G^(XY) mod \c P.
*/
mbedtls_mpi
RP
;
/*!<
The
cached
value = \c
R^2 mod
\c P.
*/
mbedtls_mpi
Vi
;
/*!<
The
blinding value
.
*/
mbedtls_mpi
Vf
;
/*!<
The
unblinding value
.
*/
mbedtls_mpi
pX
;
/*!<
The
previous
\c X.
*/
}
mbedtls_dhm_context
;
/**
* \brief
I
nitialize DHM context
* \brief
This function i
nitialize
s the
DHM context
.
*
* \param ctx DHM context to
be
initialize
d
* \param ctx
The
DHM context to initialize
.
*/
void
mbedtls_dhm_init
(
mbedtls_dhm_context
*
ctx
);
/**
* \brief
P
arse the ServerKeyExchange parameters
* \brief
This function p
arse
s
the ServerKeyExchange parameters
.
*
* \param ctx DHM context
* \param p &(start of input buffer)
* \param end end of buffer
* \param ctx The DHM context.
* \param p On input, *p must be the start of the input buffer.
* On output, *p is updated to point to the end of the data
* that has been read. On success, this is the first byte
* past the end of the ServerKeyExchange parameters.
* On error, this is the point at which an error has been
* detected, which is usually not useful except to debug
* failures.
* \param end The end of the input buffer.
*
* \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
* \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*/
int
mbedtls_dhm_read_params
(
mbedtls_dhm_context
*
ctx
,
unsigned
char
**
p
,
const
unsigned
char
*
end
);
/**
* \brief Setup and write the ServerKeyExchange parameters
* \brief This function sets up and writes the ServerKeyExchange
* parameters.
*
* \param ctx DHM context
* \param x_size private value size in
b
ytes
* \param o
utput destination buffer
* \param o
len number of chars written
* \param f_rng RNG function
* \param p_rng RNG parameter
* \param ctx
The
DHM context
.
* \param x_size
The
private value size in
B
ytes
.
* \param o
len The number of characters written.
* \param o
utput The destination buffer.
* \param f_rng
The
RNG function
.
* \param p_rng
The
RNG parameter
.
*
* \note This function assumes that ctx->P and ctx->G
* have already been properly set (for example
* using mbedtls_mpi_read_string or mbedtls_mpi_read_binary).
* \note The destination buffer must be large enough to hold
* the reduced binary presentation of the modulus, the generator
* and the public key, each wrapped with a 2-byte length field.
* It is the responsibility of the caller to ensure that enough
* space is available. Refer to \c mbedtls_mpi_size to computing
* the byte-size of an MPI.
*
* \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
* \note This function assumes that \c ctx->P and \c ctx->G
* have already been properly set. For that, use
* mbedtls_dhm_set_group() below in conjunction with
* mbedtls_mpi_read_binary() and mbedtls_mpi_read_string().
*
* \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*/
int
mbedtls_dhm_make_params
(
mbedtls_dhm_context
*
ctx
,
int
x_size
,
unsigned
char
*
output
,
size_t
*
olen
,
...
...
@@ -204,28 +164,54 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size,
void
*
p_rng
);
/**
* \brief Import the peer's public value G^Y
* \brief Set prime modulus and generator
*
* \param ctx The DHM context.
* \param P The MPI holding DHM prime modulus.
* \param G The MPI holding DHM generator.
*
* \param ctx DHM context
* \param input input buffer
* \param ilen size of buffer
* \note This function can be used to set P, G
* in preparation for \c mbedtls_dhm_make_params.
*
* \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
* \return \c 0 if successful, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*/
int
mbedtls_dhm_set_group
(
mbedtls_dhm_context
*
ctx
,
const
mbedtls_mpi
*
P
,
const
mbedtls_mpi
*
G
);
/**
* \brief This function imports the public value G^Y of the peer.
*
* \param ctx The DHM context.
* \param input The input buffer.
* \param ilen The size of the input buffer.
*
* \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*/
int
mbedtls_dhm_read_public
(
mbedtls_dhm_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief Create own private value X and export G^X
* \brief This function creates its own private value \c X and
* exports \c G^X.
*
* \param ctx The DHM context.
* \param x_size The private value size in Bytes.
* \param output The destination buffer.
* \param olen The length of the destination buffer. Must be at least
equal to ctx->len (the size of \c P).
* \param f_rng The RNG function.
* \param p_rng The RNG parameter.
*
* \param ctx DHM context
* \param x_size private value size in bytes
* \param output destination buffer
* \param olen must be at least equal to the size of P, ctx->len
* \param f_rng RNG function
* \param p_rng RNG parameter
* \note The destination buffer will always be fully written
* so as to contain a big-endian presentation of G^X mod P.
* If it is larger than ctx->len, it will accordingly be
* padded with zero-bytes in the beginning.
*
* \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
* \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*/
int
mbedtls_dhm_make_public
(
mbedtls_dhm_context
*
ctx
,
int
x_size
,
unsigned
char
*
output
,
size_t
olen
,
...
...
@@ -233,22 +219,25 @@ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size,
void
*
p_rng
);
/**
* \brief Derive and export the shared secret (G^Y)^X mod P
*
* \param ctx DHM context
* \param output destination buffer
* \param output_size size of the destination buffer
* \param olen on exit, holds the actual number of bytes written
* \param f_rng RNG function, for blinding purposes
* \param p_rng RNG parameter
*
* \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
*
* \note If non-NULL, f_rng is used to blind the input as
* countermeasure against timing attacks. Blinding is
* automatically used if and only if our secret value X is
* re-used and costs nothing otherwise, so it is recommended
* to always pass a non-NULL f_rng argument.
* \brief This function derives and exports the shared secret
* \c (G^Y)^X mod \c P.
*
* \param ctx The DHM context.
* \param output The destination buffer.
* \param output_size The size of the destination buffer. Must be at least
* the size of ctx->len.
* \param olen On exit, holds the actual number of Bytes written.
* \param f_rng The RNG function, for blinding purposes.
* \param p_rng The RNG parameter.
*
* \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
* on failure.
*
* \note If non-NULL, \p f_rng is used to blind the input as
* a countermeasure against timing attacks. Blinding is used
* only if our secret value \p X is re-used and omitted
* otherwise. Therefore, we recommend always passing a
* non-NULL \p f_rng argument.
*/
int
mbedtls_dhm_calc_secret
(
mbedtls_dhm_context
*
ctx
,
unsigned
char
*
output
,
size_t
output_size
,
size_t
*
olen
,
...
...
@@ -256,23 +245,24 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx,
void
*
p_rng
);
/**
* \brief
F
ree and clear the components of a DHM key
* \brief
This function f
ree
s
and clear
s
the components of a DHM key
.
*
* \param ctx DHM context to free and clear
* \param ctx
The
DHM context to free and clear
.
*/
void
mbedtls_dhm_free
(
mbedtls_dhm_context
*
ctx
);
#if defined(MBEDTLS_ASN1_PARSE_C)
/** \ingroup x509_module */
/**
* \brief
P
arse DHM parameters in PEM or DER format
* \brief
This function p
arse
s
DHM parameters in PEM or DER format
.
*
* \param dhm DHM context to
be
initialize
d
* \param dhmin input buffer
* \param dhminlen size of the buffer
*
(including the terminating null b
yte for PEM data
)
* \param dhm
The
DHM context to initialize
.
* \param dhmin
The
input buffer
.
* \param dhminlen
The
size of the buffer
, including the terminating null
*
B
yte for PEM data
.
*
* \return 0 if successful, or a specific DHM or PEM error code
* \return \c 0 on success, or a specific DHM or PEM error code
* on failure.
*/
int
mbedtls_dhm_parse_dhm
(
mbedtls_dhm_context
*
dhm
,
const
unsigned
char
*
dhmin
,
size_t
dhminlen
);
...
...
@@ -280,21 +270,34 @@ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin,
#if defined(MBEDTLS_FS_IO)
/** \ingroup x509_module */
/**
* \brief
L
oad and parse DHM parameters
* \brief
This function l
oad
s
and parse
s
DHM parameters
from a file.
*
* \param dhm DHM context to
be initialized
* \param path filename to read the DHM
P
arameters from
* \param dhm
The
DHM context to
load the parameters to.
* \param path
The
filename to read the DHM
p
arameters from
.
*
* \return 0 if successful, or a specific DHM or PEM error code
* \return \c 0 on success, or a specific DHM or PEM error code
* on failure.
*/
int
mbedtls_dhm_parse_dhmfile
(
mbedtls_dhm_context
*
dhm
,
const
char
*
path
);
#endif
/* MBEDTLS_FS_IO */
#endif
/* MBEDTLS_ASN1_PARSE_C */
#ifdef __cplusplus
}
#endif
#else
/* MBEDTLS_DHM_ALT */
#include "dhm_alt.h"
#endif
/* MBEDTLS_DHM_ALT */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief
C
heckup routine
* \brief
The DMH c
heckup routine
.
*
* \return
0 if
success
ful
, or
1 if the test
fail
ed
* \return
\c 0 on
success, or
\c 1 on
fail
ure.
*/
int
mbedtls_dhm_self_test
(
int
verbose
);
...
...
@@ -302,4 +305,757 @@ int mbedtls_dhm_self_test( int verbose );
}
#endif
/**
* RFC 3526, RFC 5114 and RFC 7919 standardize a number of
* Diffie-Hellman groups, some of which are included here
* for use within the SSL/TLS module and the user's convenience
* when configuring the Diffie-Hellman parameters by hand
* through \c mbedtls_ssl_conf_dh_param.
*
* The following lists the source of the above groups in the standards:
* - RFC 5114 section 2.2: 2048-bit MODP Group with 224-bit Prime Order Subgroup
* - RFC 3526 section 3: 2048-bit MODP Group
* - RFC 3526 section 4: 3072-bit MODP Group
* - RFC 3526 section 5: 4096-bit MODP Group
* - RFC 7919 section A.1: ffdhe2048
* - RFC 7919 section A.2: ffdhe3072
* - RFC 7919 section A.3: ffdhe4096
* - RFC 7919 section A.4: ffdhe6144
* - RFC 7919 section A.5: ffdhe8192
*
* The constants with suffix "_p" denote the chosen prime moduli, while
* the constants with suffix "_g" denote the chosen generator
* of the associated prime field.
*
* The constants further suffixed with "_bin" are provided in binary format,
* while all other constants represent null-terminated strings holding the
* hexadecimal presentation of the respective numbers.
*
* The primes from RFC 3526 and RFC 7919 have been generating by the following
* trust-worthy procedure:
* - Fix N in { 2048, 3072, 4096, 6144, 8192 } and consider the N-bit number
* the first and last 64 bits are all 1, and the remaining N - 128 bits of
* which are 0x7ff...ff.
* - Add the smallest multiple of the first N - 129 bits of the binary expansion
* of pi (for RFC 5236) or e (for RFC 7919) to this intermediate bit-string
* such that the resulting integer is a safe-prime.
* - The result is the respective RFC 3526 / 7919 prime, and the corresponding
* generator is always chosen to be 2 (which is a square for these prime,
* hence the corresponding subgroup has order (p-1)/2 and avoids leaking a
* bit in the private exponent).
*
*/
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
MBEDTLS_DEPRECATED
typedef
char
const
*
mbedtls_deprecated_constant_t
;
#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
( (mbedtls_deprecated_constant_t) ( VAL ) )
#else
#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
#endif
/* ! MBEDTLS_DEPRECATED_WARNING */
/**
* \warning The origin of the primes in RFC 5114 is not documented and
* their use therefore constitutes a security risk!
*
* \deprecated The hex-encoded primes from RFC 5114 are deprecated and are
* likely to be removed in a future version of the library without
* replacement.
*/
/**
* The hexadecimal presentation of the prime underlying the
* 2048-bit MODP Group with 224-bit Prime Order Subgroup, as defined
* in <em>RFC-5114: Additional Diffie-Hellman Groups for Use with
* IETF Standards</em>.
*/
#define MBEDTLS_DHM_RFC5114_MODP_P \
MBEDTLS_DEPRECATED_STRING_CONSTANT( \
"AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \
"B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \
"EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \
"9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \
"C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \
"B3BF8A317091883681286130BC8985DB1602E714415D9330" \
"278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \
"CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \
"BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \
"C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \
"CF9DE5384E71B81C0AC4DFFE0C10E64F" )
/**
* The hexadecimal presentation of the chosen generator of the 2048-bit MODP
* Group with 224-bit Prime Order Subgroup, as defined in <em>RFC-5114:
* Additional Diffie-Hellman Groups for Use with IETF Standards</em>.
*/
#define MBEDTLS_DHM_RFC5114_MODP_2048_G \
MBEDTLS_DEPRECATED_STRING_CONSTANT( \
"AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF" \
"74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA" \
"AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7" \
"C17669101999024AF4D027275AC1348BB8A762D0521BC98A" \
"E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE" \
"F180EB34118E98D119529A45D6F834566E3025E316A330EF" \
"BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB" \
"10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381" \
"B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269" \
"EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179" \
"81BC087F2A7065B384B890D3191F2BFA" )
/**
* The hexadecimal presentation of the prime underlying the 2048-bit MODP
* Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*
* \deprecated The hex-encoded primes from RFC 3625 are deprecated and
* superseded by the corresponding macros providing them as
* binary constants. Their hex-encoded constants are likely
* to be removed in a future version of the library.
*
*/
#define MBEDTLS_DHM_RFC3526_MODP_2048_P \
MBEDTLS_DEPRECATED_STRING_CONSTANT( \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AACAA68FFFFFFFFFFFFFFFF" )
/**
* The hexadecimal presentation of the chosen generator of the 2048-bit MODP
* Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*/
#define MBEDTLS_DHM_RFC3526_MODP_2048_G \
MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
/**
* The hexadecimal presentation of the prime underlying the 3072-bit MODP
* Group, as defined in <em>RFC-3072: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*/
#define MBEDTLS_DHM_RFC3526_MODP_3072_P \
MBEDTLS_DEPRECATED_STRING_CONSTANT( \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
"ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
"ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
"F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
"BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
"43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF" )
/**
* The hexadecimal presentation of the chosen generator of the 3072-bit MODP
* Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*/
#define MBEDTLS_DHM_RFC3526_MODP_3072_G \
MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
/**
* The hexadecimal presentation of the prime underlying the 4096-bit MODP
* Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*/
#define MBEDTLS_DHM_RFC3526_MODP_4096_P \
MBEDTLS_DEPRECATED_STRING_CONSTANT( \
"FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
"29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
"EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
"E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
"EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
"C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
"83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
"670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
"E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
"DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
"15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
"ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
"ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
"F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
"BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
"43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
"88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
"2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
"287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
"1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
"93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
"FFFFFFFFFFFFFFFF" )
/**
* The hexadecimal presentation of the chosen generator of the 4096-bit MODP
* Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
* Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
*/
#define MBEDTLS_DHM_RFC3526_MODP_4096_G \
MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
#endif
/* MBEDTLS_DEPRECATED_REMOVED */
/*
* Trustworthy DHM parameters in binary form
*/
#define MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN { \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \
0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \
0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \
0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, \
0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, \
0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, \
0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, \
0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, \
0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, \
0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, \
0xAE, 0x9F, 0x24, 0x11, 0x7C, 0x4B, 0x1F, 0xE6, \
0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D, \
0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, \
0x98, 0xDA, 0x48, 0x36, 0x1C, 0x55, 0xD3, 0x9A, \
0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F, \
0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, \
0x1C, 0x62, 0xF3, 0x56, 0x20, 0x85, 0x52, 0xBB, \
0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D, \
0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, \
0xF1, 0x74, 0x6C, 0x08, 0xCA, 0x18, 0x21, 0x7C, \
0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B, \
0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, \
0x9B, 0x27, 0x83, 0xA2, 0xEC, 0x07, 0xA2, 0x8F, \
0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9, \
0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, \
0x39, 0x95, 0x49, 0x7C, 0xEA, 0x95, 0x6A, 0xE5, \
0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, \
0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
#define MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN { 0x02 }
#define MBEDTLS_DHM_RFC3526_MODP_3072_P_BIN { \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \
0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \
0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \
0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \
0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \
0xE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xEA, 0x95, 0x6A, 0xE5, \
0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10, \
0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAA, 0xC4, 0x2D, \
0xAD, 0x33, 0x17, 0x0D, 0x04, 0x50, 0x7A, 0x33, \
0xA8, 0x55, 0x21, 0xAB, 0xDF, 0x1C, 0xBA, 0x64, \
0xEC, 0xFB, 0x85, 0x04, 0x58, 0xDB, 0xEF, 0x0A, \
0x8A, 0xEA, 0x71, 0x57, 0x5D, 0x06, 0x0C, 0x7D, \
0xB3, 0x97, 0x0F, 0x85, 0xA6, 0xE1, 0xE4, 0xC7, \
0xAB, 0xF5, 0xAE, 0x8C, 0xDB, 0x09, 0x33, 0xD7, \
0x1E, 0x8C, 0x94, 0xE0, 0x4A, 0x25, 0x61, 0x9D, \
0xCE, 0xE3, 0xD2, 0x26, 0x1A, 0xD2, 0xEE, 0x6B, \
0xF1, 0x2F, 0xFA, 0x06, 0xD9, 0x8A, 0x08, 0x64, \
0xD8, 0x76, 0x02, 0x73, 0x3E, 0xC8, 0x6A, 0x64, \
0x52, 0x1F, 0x2B, 0x18, 0x17, 0x7B, 0x20, 0x0C, \
0xBB, 0xE1, 0x17, 0x57, 0x7A, 0x61, 0x5D, 0x6C, \
0x77, 0x09, 0x88, 0xC0, 0xBA, 0xD9, 0x46, 0xE2, \
0x08, 0xE2, 0x4F, 0xA0, 0x74, 0xE5, 0xAB, 0x31, \
0x43, 0xDB, 0x5B, 0xFC, 0xE0, 0xFD, 0x10, 0x8E, \
0x4B, 0x82, 0xD1, 0x20, 0xA9, 0x3A, 0xD2, 0xCA, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
#define MBEDTLS_DHM_RFC3526_MODP_3072_G_BIN { 0x02 }
#define MBEDTLS_DHM_RFC3526_MODP_4096_P_BIN { \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
0x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C, 0x38, 0x26, 0xE5, 0x2C, \
0x51, 0xAA, 0x69, 0x1E, 0x0E, 0x42, 0x3C, 0xFC, \
0x99, 0xE9, 0xE3, 0x16, 0x50, 0xC1, 0x21, 0x7B, \
0x62, 0x48, 0x16, 0xCD, 0xAD, 0x9A, 0x95, 0xF9, \
0xD5, 0xB8, 0x01, 0x94, 0x88, 0xD9, 0xC0, 0xA0, \
0xA1, 0xFE, 0x30, 0x75, 0xA5, 0x77, 0xE2, 0x31, \
0x83, 0xF8, 0x1D, 0x4A, 0x3F, 0x2F, 0xA4, 0x57, \
0x1E, 0xFC, 0x8C, 0xE0, 0xBA, 0x8A, 0x4F, 0xE8, \
0xB6, 0x85, 0x5D, 0xFE, 0x72, 0xB0, 0xA6, 0x6E, \
0xDE, 0xD2, 0xFB, 0xAB, 0xFB, 0xE5, 0x8A, 0x30, \
0xFA, 0xFA, 0xBE, 0x1C, 0x5D, 0x71, 0xA8, 0x7E, \
0x2F, 0x74, 0x1E, 0xF8, 0xC1, 0xFE, 0x86, 0xFE, \
0xA6, 0xBB, 0xFD, 0xE5, 0x30, 0x67, 0x7F, 0x0D, \
0x97, 0xD1, 0x1D, 0x49, 0xF7, 0xA8, 0x44, 0x3D, \
0x08, 0x22, 0xE5, 0x06, 0xA9, 0xF4, 0x61, 0x4E, \
0x01, 0x1E, 0x2A, 0x94, 0x83, 0x8F, 0xF8, 0x8C, \
0xD6, 0x8C, 0x8B, 0xB7, 0xC5, 0xC6, 0x42, 0x4C, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
#define MBEDTLS_DHM_RFC7919_FFDHE8192_G_BIN { 0x02 }
#endif
/* dhm.h */
app/include/mbedtls/ecdh.h
View file @
c7673b02
/**
* \file ecdh.h
*
* \brief Elliptic
c
urve Diffie-Hellman
* \brief
The
Elliptic
C
urve Diffie-Hellman
(ECDH) protocol APIs.
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* ECDH is an anonymous key agreement protocol allowing two parties to
* establish a shared secret over an insecure channel. Each party must have an
* elliptic-curve public–private key pair.
*
* For more information, see <em>NIST SP 800-56A Rev. 2: Recommendation for
* Pair-Wise Key Establishment Schemes Using Discrete Logarithm
* Cryptography</em>.
*/
/*
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
...
@@ -18,8 +27,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of
m
bed TLS (https://tls.mbed.org)
* This file is part of
M
bed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_ECDH_H
#define MBEDTLS_ECDH_H
...
...
@@ -30,7 +40,9 @@ extern "C" {
#endif
/**
* When importing from an EC key, select if it is our key or the peer's key
* Defines the source of the imported EC key:
* <ul><li>Our key.</li>
* <li>The key of the peer.</li></ul>
*/
typedef
enum
{
...
...
@@ -39,56 +51,67 @@ typedef enum
}
mbedtls_ecdh_side
;
/**
* \brief ECDH context structure
* \brief
The
ECDH context structure
.
*/
typedef
struct
{
mbedtls_ecp_group
grp
;
/*!< elliptic curve used
*/
mbedtls_mpi
d
;
/*!<
our secret value (private key)
*/
mbedtls_ecp_point
Q
;
/*!<
our public valu
e
(
public key
)
*/
mbedtls_ecp_point
Qp
;
/*!<
peer's public value (public key)
*/
mbedtls_mpi
z
;
/*!< shared secret
*/
int
point_format
;
/*!< format f
or
point export in TLS messages
*/
mbedtls_ecp_point
Vi
;
/*!< blinding value
(for later)
*/
mbedtls_ecp_point
Vf
;
/*!< un
-
blinding value
(for later)
*/
mbedtls_mpi
_d
;
/*!< previous
d (for later)
*/
mbedtls_ecp_group
grp
;
/*!<
The
elliptic curve used
.
*/
mbedtls_mpi
d
;
/*!<
The private key.
*/
mbedtls_ecp_point
Q
;
/*!<
Th
e public key
.
*/
mbedtls_ecp_point
Qp
;
/*!<
The value of the public key of the peer.
*/
mbedtls_mpi
z
;
/*!<
The
shared secret
.
*/
int
point_format
;
/*!<
The
format
o
f point export in TLS messages
.
*/
mbedtls_ecp_point
Vi
;
/*!<
The
blinding value
.
*/
mbedtls_ecp_point
Vf
;
/*!<
The
unblinding value
.
*/
mbedtls_mpi
_d
;
/*!<
The
previous
\p d.
*/
}
mbedtls_ecdh_context
;
/**
* \brief
G
enerate a
public key.
*
Raw function that only does the core computation
.
* \brief
This function g
enerate
s
a
n ECDH keypair on an elliptic
*
curve
.
*
* \param grp ECP group
* \param d Destination MPI (secret exponent, aka private key)
* \param Q Destination point (public key)
* \param f_rng RNG function
* \param p_rng RNG parameter
* This function performs the first of two core computations
* implemented during the ECDH key exchange. The second core
* computation is performed by mbedtls_ecdh_compute_shared().
*
* \return 0 if successful,
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
* \param grp The ECP group.
* \param d The destination MPI (private key).
* \param Q The destination point (public key).
* \param f_rng The RNG function.
* \param p_rng The RNG parameter.
*
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or
* \c MBEDTLS_MPI_XXX error code on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdh_gen_public
(
mbedtls_ecp_group
*
grp
,
mbedtls_mpi
*
d
,
mbedtls_ecp_point
*
Q
,
int
(
*
f_rng
)(
void
*
,
unsigned
char
*
,
size_t
),
void
*
p_rng
);
/**
* \brief Compute shared secret
* Raw function that only does the core computation.
* \brief This function computes the shared secret.
*
* This function performs the second of two core computations
* implemented during the ECDH key exchange. The first core
* computation is performed by mbedtls_ecdh_gen_public().
*
* \param grp ECP group
* \param z
D
estination MPI (shared secret)
* \param Q
P
ublic key from other party
* \param d Our secret exponent (private key)
* \param f_rng RNG function
(see notes)
* \param p_rng RNG parameter
* \param grp
The
ECP group
.
* \param z
The d
estination MPI (shared secret)
.
* \param Q
The p
ublic key from
an
other party
.
* \param d Our secret exponent (private key)
.
* \param f_rng
The
RNG function
.
* \param p_rng
The
RNG parameter
.
*
* \return
0 if
success
ful,
*
or a MBEDTLS_ERR_ECP_XXX or
MBEDTLS_MPI_XXX error code
* \return
\c 0 on
success
, or an \c MBEDTLS_ERR_ECP_XXX or
*
\c
MBEDTLS_MPI_XXX error code
on failure.
*
* \note If f_rng is not NULL, it is used to implement
* \see ecp.h
*
* \note If \p f_rng is not NULL, it is used to implement
* countermeasures against potential elaborate timing
* attacks, see
\c
mbedtls_ecp_mul()
for details
.
* attacks
. For more information
, see mbedtls_ecp_mul().
*/
int
mbedtls_ecdh_compute_shared
(
mbedtls_ecp_group
*
grp
,
mbedtls_mpi
*
z
,
const
mbedtls_ecp_point
*
Q
,
const
mbedtls_mpi
*
d
,
...
...
@@ -96,34 +119,41 @@ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z,
void
*
p_rng
);
/**
* \brief
Initialize
context
* \brief
This function initializes an ECDH
context
.
*
* \param ctx
C
ontext to initialize
* \param ctx
The ECDH c
ontext to initialize
.
*/
void
mbedtls_ecdh_init
(
mbedtls_ecdh_context
*
ctx
);
/**
* \brief
Free
context
* \brief
This function frees a
context
.
*
* \param ctx
C
ontext to free
* \param ctx
The c
ontext to free
.
*/
void
mbedtls_ecdh_free
(
mbedtls_ecdh_context
*
ctx
);
/**
* \brief Generate a public key and a TLS ServerKeyExchange payload.
* (First function used by a TLS server for ECDHE.)
* \brief This function generates a public key and a TLS
* ServerKeyExchange payload.
*
* This is the first function used by a TLS server for ECDHE
* ciphersuites.
*
* \param ctx The ECDH context.
* \param olen The number of characters written.
* \param buf The destination buffer.
* \param blen The length of the destination buffer.
* \param f_rng The RNG function.
* \param p_rng The RNG parameter.
*
* \param ctx ECDH context
* \param olen number of chars written
* \param buf destination buffer
* \param blen length of buffer
* \param f_rng RNG function
* \param p_rng RNG parameter
* \note This function assumes that the ECP group (grp) of the
* \p ctx context has already been properly set,
* for example, using mbedtls_ecp_group_load().
*
* \
note
This function assumes that ctx->grp has already been
*
properly set (for example using mbedtls_ecp_group_load)
.
* \
return
\c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
*
on failure
.
*
* \
return
0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \
see
ecp.h
*/
int
mbedtls_ecdh_make_params
(
mbedtls_ecdh_context
*
ctx
,
size_t
*
olen
,
unsigned
char
*
buf
,
size_t
blen
,
...
...
@@ -131,45 +161,63 @@ int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
void
*
p_rng
);
/**
* \brief Parse and procress a TLS ServerKeyExhange payload.
* (First function used by a TLS client for ECDHE.)
* \brief This function parses and processes a TLS ServerKeyExhange
* payload.
*
* This is the first function used by a TLS client for ECDHE
* ciphersuites.
*
* \param ctx The ECDH context.
* \param buf The pointer to the start of the input buffer.
* \param end The address for one Byte past the end of the buffer.
*
* \param ctx ECDH context
* \param buf pointer to start of input buffer
* \param end one past end of buffer
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
* on failure.
*
* \
return
0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \
see
ecp.h
*/
int
mbedtls_ecdh_read_params
(
mbedtls_ecdh_context
*
ctx
,
const
unsigned
char
**
buf
,
const
unsigned
char
*
end
);
/**
* \brief Setup an ECDH context from an EC key.
* (Used by clients and servers in place of the
* ServerKeyEchange for static ECDH: import ECDH parameters
* from a certificate's EC key information.)
* \brief This function sets up an ECDH context from an EC key.
*
*
\param ctx ECDH constext to set
*
\param key EC key to use
*
\param side Is it our key (1) or the pe
er
'
s
key (0) ?
*
It is used by clients and servers in place of the
*
ServerKeyEchange for static ECDH, and imports ECDH
*
paramet
ers
from the EC key information of a certificate.
*
* \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \param ctx The ECDH context to set up.
* \param key The EC key to use.
* \param side Defines the source of the key:
* <ul><li>1: Our key.</li>
<li>0: The key of the peer.</li></ul>
*
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
* on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdh_get_params
(
mbedtls_ecdh_context
*
ctx
,
const
mbedtls_ecp_keypair
*
key
,
mbedtls_ecdh_side
side
);
/**
* \brief Generate a public key and a TLS ClientKeyExchange payload.
* (Second function used by a TLS client for ECDH(E).)
* \brief This function generates a public key and a TLS
* ClientKeyExchange payload.
*
* This is the second function used by a TLS client for ECDH(E)
* ciphersuites.
*
* \param ctx ECDH context
* \param olen number of
b
ytes
actually
written
* \param buf destination buffer
* \param blen size of destination buffer
* \param f_rng RNG function
* \param p_rng RNG parameter
* \param ctx
The
ECDH context
.
* \param olen
The
number of
B
ytes written
.
* \param buf
The
destination buffer
.
* \param blen
The
size of
the
destination buffer
.
* \param f_rng
The
RNG function
.
* \param p_rng
The
RNG parameter
.
*
* \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
* on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdh_make_public
(
mbedtls_ecdh_context
*
ctx
,
size_t
*
olen
,
unsigned
char
*
buf
,
size_t
blen
,
...
...
@@ -177,30 +225,45 @@ int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
void
*
p_rng
);
/**
* \brief Parse and process a TLS ClientKeyExchange payload.
* (Second function used by a TLS server for ECDH(E).)
* \brief This function parses and processes a TLS ClientKeyExchange
* payload.
*
* This is the second function used by a TLS server for ECDH(E)
* ciphersuites.
*
* \param ctx
ECDH context
* \param buf
start of input buffer
* \param blen
length of input buffer
* \param ctx
The
ECDH context
.
* \param buf
The
start of
the
input buffer
.
* \param blen
The
length of
the
input buffer
.
*
* \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
* on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdh_read_public
(
mbedtls_ecdh_context
*
ctx
,
const
unsigned
char
*
buf
,
size_t
blen
);
/**
* \brief Derive and export the shared secret.
* (Last function used by both TLS client en servers.)
* \brief This function derives and exports the shared secret.
*
* This is the last function used by both TLS client
* and servers.
*
* \param ctx The ECDH context.
* \param olen The number of Bytes written.
* \param buf The destination buffer.
* \param blen The length of the destination buffer.
* \param f_rng The RNG function.
* \param p_rng The RNG parameter.
*
* \param ctx ECDH context
* \param olen number of bytes written
* \param buf destination buffer
* \param blen buffer length
* \param f_rng RNG function, see notes for \c mbedtls_ecdh_compute_shared()
* \param p_rng RNG parameter
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
* on failure.
*
* \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
* \see ecp.h
*
* \note If \p f_rng is not NULL, it is used to implement
* countermeasures against potential elaborate timing
* attacks. For more information, see mbedtls_ecp_mul().
*/
int
mbedtls_ecdh_calc_secret
(
mbedtls_ecdh_context
*
ctx
,
size_t
*
olen
,
unsigned
char
*
buf
,
size_t
blen
,
...
...
app/include/mbedtls/ecdsa.h
View file @
c7673b02
/**
* \file ecdsa.h
*
* \brief Elliptic
c
urve D
SA
* \brief
The
Elliptic
C
urve D
igital Signature Algorithm (ECDSA).
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* ECDSA is defined in <em>Standards for Efficient Cryptography Group (SECG):
* SEC1 Elliptic Curve Cryptography</em>.
* The use of ECDSA for TLS is defined in <em>RFC-4492: Elliptic Curve
* Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS)</em>.
*
*/
/*
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
...
@@ -18,8 +25,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of
m
bed TLS (https://tls.mbed.org)
* This file is part of
M
bed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_ECDSA_H
#define MBEDTLS_ECDSA_H
...
...
@@ -27,7 +35,7 @@
#include "md.h"
/*
* RFC
4492 page 20:
* RFC
-
4492 page 20:
*
* Ecdsa-Sig-Value ::= SEQUENCE {
* r INTEGER,
...
...
@@ -43,11 +51,11 @@
#if MBEDTLS_ECP_MAX_BYTES > 124
#error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN"
#endif
/**
M
axim
um
size of an ECDSA signature in
b
ytes */
/**
The m
axim
al
size of an ECDSA signature in
B
ytes
.
*/
#define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) )
/**
* \brief ECDSA context structure
* \brief
The
ECDSA context structure
.
*/
typedef
mbedtls_ecp_keypair
mbedtls_ecdsa_context
;
...
...
@@ -56,25 +64,30 @@ extern "C" {
#endif
/**
* \brief Compute ECDSA signature of a previously hashed message
* \brief This function computes the ECDSA signature of a
* previously-hashed message.
*
* \note The deterministic version is usually prefered.
* \note The deterministic version is usually prefer
r
ed.
*
* \param grp ECP group
* \param r
F
irst output integer
* \param s
S
econd output integer
* \param d
P
rivate signing key
* \param buf
M
essage hash
* \param blen
L
ength of buf
* \param f_rng RNG function
* \param p_rng RNG parameter
* \param grp
The
ECP group
.
* \param r
The f
irst output integer
.
* \param s
The s
econd output integer
.
* \param d
The p
rivate signing key
.
* \param buf
The m
essage hash
.
* \param blen
The l
ength of
\p
buf
.
* \param f_rng
The
RNG function
.
* \param p_rng
The
RNG parameter
.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.3 step 5.
* bitlength of the group order, then the hash is truncated
* as defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.3, step 5.
*
* \return 0 if successful,
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX
* or \c MBEDTLS_MPI_XXX error code on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_sign
(
mbedtls_ecp_group
*
grp
,
mbedtls_mpi
*
r
,
mbedtls_mpi
*
s
,
const
mbedtls_mpi
*
d
,
const
unsigned
char
*
buf
,
size_t
blen
,
...
...
@@ -82,23 +95,31 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
/**
* \brief Compute ECDSA signature of a previously hashed message,
* deterministic version (RFC 6979).
*
* \param grp ECP group
* \param r First output integer
* \param s Second output integer
* \param d Private signing key
* \param buf Message hash
* \param blen Length of buf
* \param md_alg MD algorithm used to hash the message
* \brief This function computes the ECDSA signature of a
* previously-hashed message, deterministic version.
* For more information, see <em>RFC-6979: Deterministic
* Usage of the Digital Signature Algorithm (DSA) and Elliptic
* Curve Digital Signature Algorithm (ECDSA)</em>.
*
* \param grp The ECP group.
* \param r The first output integer.
* \param s The second output integer.
* \param d The private signing key.
* \param buf The message hash.
* \param blen The length of \p buf.
* \param md_alg The MD algorithm used to hash the message.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.3 step 5.
* defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.3, step 5.
*
* \return 0 if successful,
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
* \return \c 0 on success,
* or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX
* error code on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_sign_det
(
mbedtls_ecp_group
*
grp
,
mbedtls_mpi
*
r
,
mbedtls_mpi
*
s
,
const
mbedtls_mpi
*
d
,
const
unsigned
char
*
buf
,
size_t
blen
,
...
...
@@ -106,55 +127,73 @@ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi
#endif
/* MBEDTLS_ECDSA_DETERMINISTIC */
/**
* \brief Verify ECDSA signature of a previously hashed message
* \brief This function verifies the ECDSA signature of a
* previously-hashed message.
*
* \param grp ECP group
* \param buf
M
essage hash
* \param blen
L
ength of buf
* \param Q
P
ublic key to use for verification
* \param r
F
irst integer of the signature
* \param s
S
econd integer of the signature
* \param grp
The
ECP group
.
* \param buf
The m
essage hash
.
* \param blen
The l
ength of
\p
buf
.
* \param Q
The p
ublic key to use for verification
.
* \param r
The f
irst integer of the signature
.
* \param s
The s
econd integer of the signature
.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.4 step 3.
* defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.4, step 3.
*
* \return \c 0 on success,
* #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
* or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX
* error code on failure for any other reason.
*
* \return 0 if successful,
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
* \see ecp.h
*/
int
mbedtls_ecdsa_verify
(
mbedtls_ecp_group
*
grp
,
const
unsigned
char
*
buf
,
size_t
blen
,
const
mbedtls_ecp_point
*
Q
,
const
mbedtls_mpi
*
r
,
const
mbedtls_mpi
*
s
);
/**
* \brief Compute ECDSA signature and write it to buffer,
* serialized as defined in RFC 4492 page 20.
* (Not thread-safe to use same context in multiple threads)
*
* \note The deterministic version (RFC 6979) is used if
* MBEDTLS_ECDSA_DETERMINISTIC is defined.
*
* \param ctx ECDSA context
* \param md_alg Algorithm that was used to hash the message
* \param hash Message hash
* \param hlen Length of hash
* \param sig Buffer that will hold the signature
* \param slen Length of the signature written
* \param f_rng RNG function
* \param p_rng RNG parameter
*
* \note The "sig" buffer must be at least as large as twice the
* size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
* curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
* \brief This function computes the ECDSA signature and writes it
* to a buffer, serialized as defined in <em>RFC-4492:
* Elliptic Curve Cryptography (ECC) Cipher Suites for
* Transport Layer Security (TLS)</em>.
*
* \warning It is not thread-safe to use the same context in
* multiple threads.
*
* \note The deterministic version is used if
* #MBEDTLS_ECDSA_DETERMINISTIC is defined. For more
* information, see <em>RFC-6979: Deterministic Usage
* of the Digital Signature Algorithm (DSA) and Elliptic
* Curve Digital Signature Algorithm (ECDSA)</em>.
*
* \param ctx The ECDSA context.
* \param md_alg The message digest that was used to hash the message.
* \param hash The message hash.
* \param hlen The length of the hash.
* \param sig The buffer that holds the signature.
* \param slen The length of the signature written.
* \param f_rng The RNG function.
* \param p_rng The RNG parameter.
*
* \note The \p sig buffer must be at least twice as large as the
* size of the curve used, plus 9. For example, 73 Bytes if
* a 256-bit curve is used. A buffer length of
* #MBEDTLS_ECDSA_MAX_LEN is always safe.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.3 step 5.
* defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.3, step 5.
*
* \return 0 if successful,
* or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
* MBEDTLS_ERR_ASN1_XXX error code
* \return \c 0 on success,
* or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or
* \c MBEDTLS_ERR_ASN1_XXX error code on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_write_signature
(
mbedtls_ecdsa_context
*
ctx
,
mbedtls_md_type_t
md_alg
,
const
unsigned
char
*
hash
,
size_t
hlen
,
...
...
@@ -170,31 +209,43 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief Compute ECDSA signature and write it to buffer,
* serialized as defined in RFC 4492 page 20.
* Deterministic version, RFC 6979.
* (Not thread-safe to use same context in multiple threads)
* \brief This function computes an ECDSA signature and writes it to a buffer,
* serialized as defined in <em>RFC-4492: Elliptic Curve Cryptography
* (ECC) Cipher Suites for Transport Layer Security (TLS)</em>.
*
* The deterministic version is defined in <em>RFC-6979:
* Deterministic Usage of the Digital Signature Algorithm (DSA) and
* Elliptic Curve Digital Signature Algorithm (ECDSA)</em>.
*
* \warning It is not thread-safe to use the same context in
* multiple threads.
*
* \deprecated Superseded by mbedtls_ecdsa_write_signature() in 2.0.0
*
* \param ctx ECDSA context
* \param hash Message hash
* \param hlen
L
ength of hash
* \param sig
B
uffer that
will
hold the signature
* \param slen
L
ength of the signature written
* \param md_alg MD algorithm used to hash the message
* \param ctx
The
ECDSA context
.
* \param hash
The
Message hash
.
* \param hlen
The l
ength of
the
hash
.
* \param sig
The b
uffer that hold
s
the signature
.
* \param slen
The l
ength of the signature written
.
* \param md_alg
The
MD algorithm used to hash the message
.
*
* \note The "sig" buffer must be at least as large as twice the
* size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
* curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
* \note The \p sig buffer must be at least twice as large as the
* size of the curve used, plus 9. For example, 73 Bytes if a
* 256-bit curve is used. A buffer length of
* #MBEDTLS_ECDSA_MAX_LEN is always safe.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.3 step 5.
* defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.3, step 5.
*
* \return 0 if successful,
* or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
* MBEDTLS_ERR_ASN1_XXX error code
* \return \c 0 on success,
* or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or
* \c MBEDTLS_ERR_ASN1_XXX error code on failure.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_write_signature_det
(
mbedtls_ecdsa_context
*
ctx
,
const
unsigned
char
*
hash
,
size_t
hlen
,
...
...
@@ -205,63 +256,74 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
#endif
/* MBEDTLS_ECDSA_DETERMINISTIC */
/**
* \brief
R
ead and verif
y
an ECDSA signature
* \brief
This function r
ead
s
and verif
ies
an ECDSA signature
.
*
* \param ctx ECDSA context
* \param hash
M
essage hash
* \param hlen
S
ize of hash
* \param sig
S
ignature to read and verify
* \param slen
S
ize of sig
* \param ctx
The
ECDSA context
.
* \param hash
The m
essage hash
.
* \param hlen
The s
ize of
the
hash
.
* \param sig
The s
ignature to read and verify
.
* \param slen
The s
ize of
\p
sig
.
*
* \note If the bitlength of the message hash is larger than the
* bitlength of the group order, then the hash is truncated as
* prescribed by SEC1 4.1.4 step 3.
*
* \return 0 if successful,
* MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
* MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
* valid but its actual length is less than siglen,
* or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code
* defined in <em>Standards for Efficient Cryptography Group
* (SECG): SEC1 Elliptic Curve Cryptography</em>, section
* 4.1.4, step 3.
*
* \return \c 0 on success,
* #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
* #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
* valid but its actual length is less than \p siglen,
* or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX
* error code on failure for any other reason.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_read_signature
(
mbedtls_ecdsa_context
*
ctx
,
const
unsigned
char
*
hash
,
size_t
hlen
,
const
unsigned
char
*
sig
,
size_t
slen
);
/**
* \brief
G
enerate an ECDSA keypair on the given curve
* \brief
This function g
enerate
s
an ECDSA keypair on the given curve
.
*
* \param ctx ECDSA context
in which
the keypair
should be stored
* \param gid
Group (
elliptic curve
)
to use. One of the various
* MBEDTLS_ECP_DP_XXX macros depending on configuration.
* \param f_rng RNG function
* \param p_rng RNG parameter
* \param ctx
The
ECDSA context
to store
the keypair
in.
* \param gid
The
elliptic curve to use. One of the various
*
\c
MBEDTLS_ECP_DP_XXX macros depending on configuration.
* \param f_rng
The
RNG function
.
* \param p_rng
The
RNG parameter
.
*
* \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code.
* \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on
* failure.
*
* \see ecp.h
*/
int
mbedtls_ecdsa_genkey
(
mbedtls_ecdsa_context
*
ctx
,
mbedtls_ecp_group_id
gid
,
int
(
*
f_rng
)(
void
*
,
unsigned
char
*
,
size_t
),
void
*
p_rng
);
/**
* \brief Set an ECDSA context from an EC key pair
* \brief This function sets an ECDSA context from an EC key pair.
*
* \param ctx The ECDSA context to set.
* \param key The EC key to use.
*
* \
param ctx ECDSA context to set
*
\param key EC key to use
* \
return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on
*
failure.
*
* \
return
0 on success, or a MBEDTLS_ERR_ECP_XXX code.
* \
see
ecp.h
*/
int
mbedtls_ecdsa_from_keypair
(
mbedtls_ecdsa_context
*
ctx
,
const
mbedtls_ecp_keypair
*
key
);
/**
* \brief
Initialize
context
* \brief
This function initializes an ECDSA
context
.
*
* \param ctx
C
ontext to initialize
* \param ctx
The ECDSA c
ontext to initialize
.
*/
void
mbedtls_ecdsa_init
(
mbedtls_ecdsa_context
*
ctx
);
/**
* \brief
Free
context
* \brief
This function frees an ECDSA
context
.
*
* \param ctx
C
ontext to free
* \param ctx
The ECDSA c
ontext to free
.
*/
void
mbedtls_ecdsa_free
(
mbedtls_ecdsa_context
*
ctx
);
...
...
app/include/mbedtls/ecjpake.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file ecjpake.h
*
* \brief Elliptic curve J-PAKE
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -43,6 +44,8 @@
#include "ecp.h"
#include "md.h"
#if !defined(MBEDTLS_ECJPAKE_ALT)
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -222,17 +225,31 @@ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx,
*/
void
mbedtls_ecjpake_free
(
mbedtls_ecjpake_context
*
ctx
);
#ifdef __cplusplus
}
#endif
#else
/* MBEDTLS_ECJPAKE_ALT */
#include "ecjpake_alt.h"
#endif
/* MBEDTLS_ECJPAKE_ALT */
#if defined(MBEDTLS_SELF_TEST)
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if a test failed
*/
int
mbedtls_ecjpake_self_test
(
int
verbose
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/* MBEDTLS_SELF_TEST */
#endif
/* ecjpake.h */
app/include/mbedtls/ecp.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file ecp.h
*
* \brief Elliptic curves over GF(p)
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -36,6 +37,7 @@
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00
/**< Generation of random value, such as (ephemeral) key, failed. */
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80
/**< Invalid private or public key. */
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00
/**< Signature is valid but shorter than the user-supplied length. */
#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80
/**< ECP hardware accelerator failed. */
#if !defined(MBEDTLS_ECP_ALT)
/*
...
...
app/include/mbedtls/ecp_internal.h
View file @
c7673b02
...
...
@@ -3,7 +3,8 @@
*
* \brief Function declarations for alternative implementation of elliptic curve
* point arithmetic.
*
*/
/*
* Copyright (C) 2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
app/include/mbedtls/entropy.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file entropy.h
*
* \brief Entropy accumulator implementation
*
*/
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -121,6 +122,7 @@ mbedtls_entropy_source_state;
*/
typedef
struct
{
int
accumulator_started
;
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
mbedtls_sha512_context
accumulator
;
#else
...
...
app/include/mbedtls/entropy_poll.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file entropy_poll.h
*
* \brief Platform-specific and custom entropy polling functions
*
*/
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
app/include/mbedtls/error.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file error.h
*
* \brief Error to string translation
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -49,23 +50,32 @@
*
* Module Nr Codes assigned
* MPI 7 0x0002-0x0010
* GCM
2
0x0012-0x0014
* BLOWFISH
2
0x0016-0x0018
* GCM
3
0x0012-0x0014
0x0013-0x0013
* BLOWFISH
3
0x0016-0x0018
0x0017-0x0017
* THREADING 3 0x001A-0x001E
* AES
2
0x0020-0x0022
* CAMELLIA
2
0x0024-0x0026
* XTEA
1
0x0028-0x0028
* AES
4
0x0020-0x0022
0x0023-0x0025
* CAMELLIA
3
0x0024-0x0026
0x0027-0x0027
* XTEA
2
0x0028-0x0028
0x0029-0x0029
* BASE64 2 0x002A-0x002C
* OID 1 0x002E-0x002E 0x000B-0x000B
* PADLOCK 1 0x0030-0x0030
* DES
1
0x0032-0x0032
* DES
2
0x0032-0x0032
0x0033-0x0033
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
* NET 11 0x0042-0x0052 0x0043-0x0045
* ASN1 7 0x0060-0x006C
* CMAC 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
* HMAC_DRBG 4 0x0003-0x0009
* CCM 2 0x000D-0x000F
* HMAC_DRBG 4 0x0003-0x0009
* CCM 3 0x000D-0x0011
* ARC4 1 0x0019-0x0019
* MD2 1 0x002B-0x002B
* MD4 1 0x002D-0x002D
* MD5 1 0x002F-0x002F
* RIPEMD160 1 0x0031-0x0031
* SHA1 1 0x0035-0x0035
* SHA256 1 0x0037-0x0037
* SHA512 1 0x0039-0x0039
*
* High-level module nr (3 bits - 0x0...-0x7...)
* Name ID Nr of Errors
...
...
@@ -73,12 +83,12 @@
* PKCS#12 1 4 (Started from top)
* X509 2 20
* PKCS5 2 4 (Started from top)
* DHM 3
9
* PK 3 1
4
(Started from top)
* RSA 4
9
* ECP 4
8
(Started from top)
* MD 5
4
* CIPHER 6
6
* DHM 3
11
* PK 3 1
5
(Started from top)
* RSA 4
11
* ECP 4
9
(Started from top)
* MD 5
5
* CIPHER 6
8
* SSL 6 17 (Started from top)
* SSL 7 31
*
...
...
app/include/mbedtls/gcm.h
View file @
c7673b02
/**
* \file gcm.h
*
* \brief Galois/Counter mode for 128-bit block ciphers
* \brief Galois/Counter Mode (GCM) for 128-bit block ciphers, as defined
* in <em>D. McGrew, J. Viega, The Galois/Counter Mode of Operation
* (GCM), Natl. Inst. Stand. Technol.</em>
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* For more information on GCM, see <em>NIST SP 800-38D: Recommendation for
* Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC</em>.
*
*/
/*
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
...
@@ -18,8 +25,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of
m
bed TLS (https://tls.mbed.org)
* This file is part of
M
bed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_GCM_H
#define MBEDTLS_GCM_H
...
...
@@ -31,46 +39,59 @@
#define MBEDTLS_GCM_DECRYPT 0
#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
/**< Authenticated decryption failed. */
#define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013
/**< GCM hardware accelerator failed. */
#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
/**< Bad input parameters to function. */
#if !defined(MBEDTLS_GCM_ALT)
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief GCM context structure
* \brief
The
GCM context structure
.
*/
typedef
struct
{
mbedtls_cipher_context_t
cipher_ctx
;
/*!< cipher context used */
uint64_t
HL
[
16
];
/*!< Precalculated HTable */
uint64_t
HH
[
16
];
/*!< Precalculated HTable */
uint64_t
len
;
/*!< Total data length */
uint64_t
add_len
;
/*!< Total add length */
unsigned
char
base_ectr
[
16
];
/*!< First ECTR for tag */
unsigned
char
y
[
16
];
/*!< Y working value */
unsigned
char
buf
[
16
];
/*!< buf working value */
int
mode
;
/*!< Encrypt or Decrypt */
mbedtls_cipher_context_t
cipher_ctx
;
/*!< The cipher context used. */
uint64_t
HL
[
16
];
/*!< Precalculated HTable low. */
uint64_t
HH
[
16
];
/*!< Precalculated HTable high. */
uint64_t
len
;
/*!< The total length of the encrypted data. */
uint64_t
add_len
;
/*!< The total length of the additional data. */
unsigned
char
base_ectr
[
16
];
/*!< The first ECTR for tag. */
unsigned
char
y
[
16
];
/*!< The Y working value. */
unsigned
char
buf
[
16
];
/*!< The buf working value. */
int
mode
;
/*!< The operation to perform:
#MBEDTLS_GCM_ENCRYPT or
#MBEDTLS_GCM_DECRYPT. */
}
mbedtls_gcm_context
;
/**
* \brief Initialize GCM context (just makes references valid)
* Makes the context ready for mbedtls_gcm_setkey() or
* mbedtls_gcm_free().
* \brief This function initializes the specified GCM context,
* to make references valid, and prepares the context
* for mbedtls_gcm_setkey() or mbedtls_gcm_free().
*
* The function does not bind the GCM context to a particular
* cipher, nor set the key. For this purpose, use
* mbedtls_gcm_setkey().
*
* \param ctx GCM context to initialize
* \param ctx
The
GCM context to initialize
.
*/
void
mbedtls_gcm_init
(
mbedtls_gcm_context
*
ctx
);
/**
* \brief GCM initialization (encryption)
* \brief This function associates a GCM context with a
* cipher algorithm and a key.
*
* \param ctx GCM context to be initialized
* \param cipher cipher to use (a 128-bit block cipher)
* \param key encryption key
* \param keybits must be 128, 192 or 256
* \param ctx The GCM context to initialize.
* \param cipher The 128-bit block cipher to use.
* \param key The encryption key.
* \param keybits The key size in bits. Valid options are:
* <ul><li>128 bits</li>
* <li>192 bits</li>
* <li>256 bits</li></ul>
*
* \return
0 if
success
ful
, or a cipher specific error code
* \return
\c 0 on
success, or a cipher specific error code
.
*/
int
mbedtls_gcm_setkey
(
mbedtls_gcm_context
*
ctx
,
mbedtls_cipher_id_t
cipher
,
...
...
@@ -78,26 +99,27 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
unsigned
int
keybits
);
/**
* \brief
GCM buffer
encryption
/
decryption
using a block ciph
er
* \brief
This function performs GCM
encryption
or
decryption
of a buff
er
.
*
* \note
On
encryption, the output buffer can be the same as the input buffer.
*
On
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* \note
For
encryption, the output buffer can be the same as the input buffer.
*
For
decryption, the output buffer cannot be the same as input buffer.
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
*
* \param ctx GCM context
* \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
* \param length length of the input data
* \param iv initialization vector
* \param iv_len length of IV
* \param add additional data
* \param add_len length of additional data
* \param input buffer holding the input data
* \param output buffer for holding the output data
* \param tag_len length of the tag to generate
* \param tag buffer for holding the tag
*
* \return 0 if successful
* \param ctx The GCM context to use for encryption or decryption.
* \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
* #MBEDTLS_GCM_DECRYPT.
* \param length The length of the input data. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
* \param iv The initialization vector.
* \param iv_len The length of the IV.
* \param add The buffer holding the additional data.
* \param add_len The length of the additional data.
* \param input The buffer holding the input data.
* \param output The buffer for holding the output data.
* \param tag_len The length of the tag to generate.
* \param tag The buffer for holding the tag.
*
* \return \c 0 on success.
*/
int
mbedtls_gcm_crypt_and_tag
(
mbedtls_gcm_context
*
ctx
,
int
mode
,
...
...
@@ -112,25 +134,26 @@ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx,
unsigned
char
*
tag
);
/**
* \brief GCM buffer authenticated decryption using a block cipher
* \brief This function performs a GCM authenticated decryption of a
* buffer.
*
* \note
On
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* \note
For
decryption, the output buffer cannot be the same as input buffer.
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
*
* \param ctx GCM context
* \param length length of the input data
* \param iv initialization vector
* \param iv_len length of IV
* \param add additional data
* \param add_len length of additional data
* \param tag buffer holding the tag
* \param tag_len length of the tag
* \param input buffer holding the input data
* \param output buffer for holding the output data
*
* \return 0 if successful and authenticated,
* MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match
* \param ctx
The
GCM context
.
* \param length
The
length of the input data
. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
* \param iv
The
initialization vector
.
* \param iv_len
The
length of
the
IV
.
* \param add
The buffer holding the
additional data
.
* \param add_len
The
length of
the
additional data
.
* \param tag
The
buffer holding the tag
.
* \param tag_len
The
length of the tag
.
* \param input
The
buffer holding the input data
.
* \param output
The
buffer for holding the output data
.
*
* \return 0 if successful and authenticated,
or
*
#
MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match
.
*/
int
mbedtls_gcm_auth_decrypt
(
mbedtls_gcm_context
*
ctx
,
size_t
length
,
...
...
@@ -144,16 +167,18 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx,
unsigned
char
*
output
);
/**
* \brief Generic GCM stream start function
* \brief This function starts a GCM encryption or decryption
* operation.
*
* \param ctx GCM context
* \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
* \param iv initialization vector
* \param iv_len length of IV
* \param add additional data (or NULL if length is 0)
* \param add_len length of additional data
* \param ctx The GCM context.
* \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
* #MBEDTLS_GCM_DECRYPT.
* \param iv The initialization vector.
* \param iv_len The length of the IV.
* \param add The buffer holding the additional data, or NULL if \p add_len is 0.
* \param add_len The length of the additional data. If 0, \p add is NULL.
*
* \return
0 if
success
ful
* \return
\c 0 on
success
.
*/
int
mbedtls_gcm_starts
(
mbedtls_gcm_context
*
ctx
,
int
mode
,
...
...
@@ -163,21 +188,23 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
size_t
add_len
);
/**
* \brief Generic GCM update function. Encrypts/decrypts using the
* given GCM context. Expects input to be a multiple of 16
* bytes! Only the last call before mbedtls_gcm_finish() can be less
* than 16 bytes!
* \brief This function feeds an input buffer into an ongoing GCM
* encryption or decryption operation.
*
* ` The function expects input to be a multiple of 16
* Bytes. Only the last call before calling
* mbedtls_gcm_finish() can be less than 16 Bytes.
*
* \note
On
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* \note
For
decryption, the output buffer cannot be the same as input buffer.
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
*
* \param ctx GCM context
* \param length length of the input data
* \param input buffer holding the input data
* \param output buffer for holding the output data
* \param ctx
The
GCM context
.
* \param length
The
length of the input data
. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
* \param input
The
buffer holding the input data
.
* \param output
The
buffer for holding the output data
.
*
* \return
0 if
success
ful
or MBEDTLS_ERR_GCM_BAD_INPUT
* \return
\c 0 on
success
,
or
#
MBEDTLS_ERR_GCM_BAD_INPUT
on failure.
*/
int
mbedtls_gcm_update
(
mbedtls_gcm_context
*
ctx
,
size_t
length
,
...
...
@@ -185,31 +212,46 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
unsigned
char
*
output
);
/**
* \brief Generic GCM finalisation function. Wraps up the GCM stream
* and generates the tag. The tag can have a maximum length of
* 16 bytes.
* \brief This function finishes the GCM operation and generates
* the authentication tag.
*
* \param ctx GCM context
* \param tag buffer for holding the tag
* \param tag_len length of the tag to generate (must be at least 4)
* It wraps up the GCM stream, and generates the
* tag. The tag can have a maximum length of 16 Bytes.
*
* \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT
* \param ctx The GCM context.
* \param tag The buffer for holding the tag.
* \param tag_len The length of the tag to generate. Must be at least four.
*
* \return \c 0 on success, or #MBEDTLS_ERR_GCM_BAD_INPUT on failure.
*/
int
mbedtls_gcm_finish
(
mbedtls_gcm_context
*
ctx
,
unsigned
char
*
tag
,
size_t
tag_len
);
/**
* \brief Free a GCM context and underlying cipher sub-context
* \brief This function clears a GCM context and the underlying
* cipher sub-context.
*
* \param ctx GCM context to
free
* \param ctx
The
GCM context to
clear.
*/
void
mbedtls_gcm_free
(
mbedtls_gcm_context
*
ctx
);
#ifdef __cplusplus
}
#endif
#else
/* !MBEDTLS_GCM_ALT */
#include "gcm_alt.h"
#endif
/* !MBEDTLS_GCM_ALT */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief
C
heckup routine
* \brief
The GCM c
heckup routine
.
*
* \return
0 if
success
ful
, or
1 if the test
fail
ed
* \return
\c 0 on
success, or
\c 1 on
fail
ure.
*/
int
mbedtls_gcm_self_test
(
int
verbose
);
...
...
@@ -217,4 +259,5 @@ int mbedtls_gcm_self_test( int verbose );
}
#endif
#endif
/* gcm.h */
app/include/mbedtls/havege.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file havege.h
*
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
app/include/mbedtls/hmac_drbg.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file hmac_drbg.h
*
* \brief HMAC_DRBG (NIST SP 800-90A)
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
app/include/mbedtls/md.h
View file @
c7673b02
/**
/**
* \file md.h
*
* \brief
G
eneric message
digest wrapper
* \brief
The g
eneric message
-
digest wrapper
.
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
*/
/*
* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
...
@@ -20,22 +21,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of
m
bed TLS (https://tls.mbed.org)
* This file is part of
M
bed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_MD_H
#define MBEDTLS_MD_H
#include <stddef.h>
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080
/**< The selected feature is not available. */
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100
/**< Bad input parameters to function. */
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
/**< Failed to allocate memory. */
#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200
/**< Opening or reading of file failed. */
#define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280
/**< MD hardware accelerator failed. */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief Enumeration of supported message digests
*
* \warning MD2, MD4, MD5 and SHA-1 are considered weak message digests and
* their use constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
typedef
enum
{
MBEDTLS_MD_NONE
=
0
,
MBEDTLS_MD_MD2
,
...
...
@@ -56,65 +73,79 @@ typedef enum {
#endif
/**
* Opaque struct defined in md_internal.h
* Opaque struct defined in md_internal.h
.
*/
typedef
struct
mbedtls_md_info_t
mbedtls_md_info_t
;
/**
*
G
eneric message
digest context.
*
The g
eneric message
-
digest context.
*/
typedef
struct
{
/** Information about the associated message digest */
/** Information about the associated message digest
.
*/
const
mbedtls_md_info_t
*
md_info
;
/**
D
igest-specific context */
/**
The d
igest-specific context
.
*/
void
*
md_ctx
;
/** HMAC part of the context */
/**
The
HMAC part of the context
.
*/
void
*
hmac_ctx
;
}
mbedtls_md_context_t
;
/**
* \brief Returns the list of digests supported by the generic digest module.
* \brief This function returns the list of digests supported by the
* generic digest module.
*
* \return a statically allocated array of digests, the last entry
* is 0.
* \return A statically allocated array of digests. Each element
* in the returned list is an integer belonging to the
* message-digest enumeration #mbedtls_md_type_t.
* The last entry is 0.
*/
const
int
*
mbedtls_md_list
(
void
);
/**
* \brief
R
eturns the message
digest information
associated with the
* given digest name.
* \brief
This function r
eturns the message
-
digest information
*
associated with the
given digest name.
*
* \param md_name
N
ame of the digest to search for.
* \param md_name
The n
ame of the digest to search for.
*
* \return The message
digest information associated with md_name
or
* NULL if not found.
* \return The message
-
digest information associated with
\p
md_name
,
*
or
NULL if not found.
*/
const
mbedtls_md_info_t
*
mbedtls_md_info_from_string
(
const
char
*
md_name
);
/**
* \brief
R
eturns the message
digest information
associated with the
* given digest type.
* \brief
This function r
eturns the message
-
digest information
*
associated with the
given digest type.
*
* \param md_type type of digest to search for.
* \param md_type
The
type of digest to search for.
*
* \return The message
digest information associated with md_type
or
* NULL if not found.
* \return The message
-
digest information associated with
\p
md_type
,
*
or
NULL if not found.
*/
const
mbedtls_md_info_t
*
mbedtls_md_info_from_type
(
mbedtls_md_type_t
md_type
);
/**
* \brief Initialize a md_context (as NONE)
* This should always be called first.
* Prepares the context for mbedtls_md_setup() or mbedtls_md_free().
* \brief This function initializes a message-digest context without
* binding it to a particular message-digest algorithm.
*
* This function should always be called first. It prepares the
* context for mbedtls_md_setup() for binding it to a
* message-digest algorithm.
*/
void
mbedtls_md_init
(
mbedtls_md_context_t
*
ctx
);
/**
* \brief Free and clear the internal structures of ctx.
* Can be called at any time after mbedtls_md_init().
* Mandatory once mbedtls_md_setup() has been called.
* \brief This function clears the internal structure of \p ctx and
* frees any embedded internal structure, but does not free
* \p ctx itself.
*
* If you have called mbedtls_md_setup() on \p ctx, you must
* call mbedtls_md_free() when you are no longer using the
* context.
* Calling this function if you have previously
* called mbedtls_md_init() and nothing else is optional.
* You must not call this function if you have not called
* mbedtls_md_init().
*/
void
mbedtls_md_free
(
mbedtls_md_context_t
*
ctx
);
...
...
@@ -125,220 +156,288 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx );
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief Select MD to use and allocate internal structures.
* Should be called after mbedtls_md_init() or mbedtls_md_free().
* \brief This function selects the message digest algorithm to use,
* and allocates internal structures.
*
* It should be called after mbedtls_md_init() or mbedtls_md_free().
* Makes it necessary to call mbedtls_md_free() later.
*
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
*
* \param ctx Context to set up.
* \param md_info Message digest to use.
* \param ctx The context to set up.
* \param md_info The information structure of the message-digest algorithm
* to use.
*
* \returns \c 0 on success,
*
\c
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
\c
MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
#
MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
*/
int
mbedtls_md_init_ctx
(
mbedtls_md_context_t
*
ctx
,
const
mbedtls_md_info_t
*
md_info
)
MBEDTLS_DEPRECATED
;
#undef MBEDTLS_DEPRECATED
#endif
/* MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Select MD to use and allocate internal structures.
* Should be called after mbedtls_md_init() or mbedtls_md_free().
* Makes it necessary to call mbedtls_md_free() later.
* \brief This function selects the message digest algorithm to use,
* and allocates internal structures.
*
* \param ctx Context to set up.
* \param md_info Message digest to use.
* \param hmac 0 to save some memory if HMAC will not be used,
* non-zero is HMAC is going to be used with this context.
* It should be called after mbedtls_md_init() or
* mbedtls_md_free(). Makes it necessary to call
* mbedtls_md_free() later.
*
* \param ctx The context to set up.
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param hmac <ul><li>0: HMAC is not used. Saves some memory.</li>
* <li>non-zero: HMAC is used with this context.</li></ul>
*
* \returns \c 0 on success,
*
\c
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
\c
MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
or
*
#
MBEDTLS_ERR_MD_ALLOC_FAILED
on
memory allocation failure.
*/
int
mbedtls_md_setup
(
mbedtls_md_context_t
*
ctx
,
const
mbedtls_md_info_t
*
md_info
,
int
hmac
);
/**
* \brief Clone the state of an MD context
* \brief This function clones the state of an message-digest
* context.
*
* \note You must call mbedtls_md_setup() on \c dst before calling
* this function.
*
* \note The two contexts must have
been setup to
the same type
*
(cloning from SHA-256 to SHA-512 make no sense)
.
* \note The two contexts must have the same type
,
*
for example, both are SHA-256
.
*
* \warning Only clones the MD state, not the HMAC state! (for now)
* \warning This function clones the message-digest state, not the
* HMAC state.
*
* \param dst The destination context
* \param src The context to be cloned
* \param dst The destination context
.
* \param src The context to be cloned
.
*
* \return \c 0 on success,
*
\c
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.
*/
int
mbedtls_md_clone
(
mbedtls_md_context_t
*
dst
,
const
mbedtls_md_context_t
*
src
);
/**
* \brief Returns the size of the message digest output.
* \brief This function extracts the message-digest size from the
* message-digest information structure.
*
* \param md_info message digest info
* \param md_info The information structure of the message-digest algorithm
* to use.
*
* \return size of the message
digest output in
b
ytes.
* \return
The
size of the message
-
digest output in
B
ytes.
*/
unsigned
char
mbedtls_md_get_size
(
const
mbedtls_md_info_t
*
md_info
);
/**
* \brief Returns the type of the message digest output.
* \brief This function extracts the message-digest type from the
* message-digest information structure.
*
* \param md_info message digest info
* \param md_info The information structure of the message-digest algorithm
* to use.
*
* \return type of the message digest
output
.
* \return
The
type of the message digest.
*/
mbedtls_md_type_t
mbedtls_md_get_type
(
const
mbedtls_md_info_t
*
md_info
);
/**
* \brief Returns the name of the message digest output.
* \brief This function extracts the message-digest name from the
* message-digest information structure.
*
* \param md_info message digest info
* \param md_info The information structure of the message-digest algorithm
* to use.
*
* \return name of the message digest
output
.
* \return
The
name of the message digest.
*/
const
char
*
mbedtls_md_get_name
(
const
mbedtls_md_info_t
*
md_info
);
/**
* \brief Prepare the context to digest a new message.
* Generally called after mbedtls_md_setup() or mbedtls_md_finish().
* Followed by mbedtls_md_update().
* \brief This function starts a message-digest computation.
*
* \param ctx generic message digest context.
* You must call this function after setting up the context
* with mbedtls_md_setup(), and before passing data with
* mbedtls_md_update().
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* verification fails.
* \param ctx The generic message-digest context.
*
* \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
int
mbedtls_md_starts
(
mbedtls_md_context_t
*
ctx
);
/**
* \brief Generic message digest process buffer
* Called between mbedtls_md_starts() and mbedtls_md_finish().
* May be called repeatedly.
* \brief This function feeds an input buffer into an ongoing
* message-digest computation.
*
* You must call mbedtls_md_starts() before calling this
* function. You may call this function multiple times.
* Afterwards, call mbedtls_md_finish().
*
* \param ctx
G
eneric message
digest context
* \param input buffer holding the data
l
* \param ilen length of the input data
* \param ctx
The g
eneric message
-
digest context
.
* \param input
The
buffer holding the
input
data
.
* \param ilen
The
length of the input data
.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* verification fails.
* \returns
\c
0 on success,
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
*
parameter
verification fails.
*/
int
mbedtls_md_update
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief Generic message digest final digest
* Called after mbedtls_md_update().
* Usually followed by mbedtls_md_free() or mbedtls_md_starts().
* \brief This function finishes the digest operation,
* and writes the result to the output buffer.
*
* \param ctx Generic message digest context
* \param output Generic message digest checksum result
* Call this function after a call to mbedtls_md_starts(),
* followed by any number of calls to mbedtls_md_update().
* Afterwards, you may either clear the context with
* mbedtls_md_free(), or call mbedtls_md_starts() to reuse
* the context for another digest operation with the same
* algorithm.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* verification fails.
* \param ctx The generic message-digest context.
* \param output The buffer for the generic message-digest checksum result.
*
* \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
int
mbedtls_md_finish
(
mbedtls_md_context_t
*
ctx
,
unsigned
char
*
output
);
/**
* \brief Output = message_digest( input buffer )
* \brief This function calculates the message-digest of a buffer,
* with respect to a configurable message-digest algorithm
* in a single call.
*
* The result is calculated as
* Output = message_digest(input buffer).
*
* \param md_info message digest info
* \param input buffer holding the data
* \param ilen length of the input data
* \param output Generic message digest checksum result
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param input The buffer holding the data.
* \param ilen The length of the input data.
* \param output The generic message-digest checksum result.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* verification fails.
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
*
parameter
verification fails.
*/
int
mbedtls_md
(
const
mbedtls_md_info_t
*
md_info
,
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
*
output
);
#if defined(MBEDTLS_FS_IO)
/**
* \brief Output = message_digest( file contents )
* \brief This function calculates the message-digest checksum
* result of the contents of the provided file.
*
* The result is calculated as
* Output = message_digest(file contents).
*
* \param md_info message digest info
* \param path input file name
* \param output generic message digest checksum result
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param path The input file name.
* \param output The generic message-digest checksum result.
*
* \return
0 if
success
ful
,
* MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
* MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
* \return
\c 0 on
success,
*
#
MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
or
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
\p
md_info was NULL.
*/
int
mbedtls_md_file
(
const
mbedtls_md_info_t
*
md_info
,
const
char
*
path
,
unsigned
char
*
output
);
#endif
/* MBEDTLS_FS_IO */
/**
* \brief
Set
HMAC key and prepare to
authenticate a new message.
*
Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish()
.
* \brief
This function sets the
HMAC key and prepare
s
to
*
authenticate a new message
.
*
* \param ctx HMAC context
* \param key HMAC secret key
* \param keylen length of the HMAC key in bytes
* Call this function after mbedtls_md_setup(), to use
* the MD context for an HMAC calculation, then call
* mbedtls_md_hmac_update() to provide the input data, and
* mbedtls_md_hmac_finish() to get the HMAC value.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* verification fails.
* \param ctx The message digest context containing an embedded HMAC
* context.
* \param key The HMAC secret key.
* \param keylen The length of the HMAC key in Bytes.
*
* \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
int
mbedtls_md_hmac_starts
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
key
,
size_t
keylen
);
/**
* \brief Generic HMAC process buffer.
* Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
* and mbedtls_md_hmac_finish().
* May be called repeatedly.
*
* \param ctx HMAC context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* verification fails.
* \brief This function feeds an input buffer into an ongoing HMAC
* computation.
*
* Call mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
* before calling this function.
* You may call this function multiple times to pass the
* input piecewise.
* Afterwards, call mbedtls_md_hmac_finish().
*
* \param ctx The message digest context containing an embedded HMAC
* context.
* \param input The buffer holding the input data.
* \param ilen The length of the input data.
*
* \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
int
mbedtls_md_hmac_update
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief Output HMAC.
* Called after mbedtls_md_hmac_update().
* Usually followed by mbedtls_md_hmac_reset(),
* mbedtls_md_hmac_starts(), or mbedtls_md_free().
* \brief This function finishes the HMAC operation, and writes
* the result to the output buffer.
*
* Call this function after mbedtls_md_hmac_starts() and
* mbedtls_md_hmac_update() to get the HMAC value. Afterwards
* you may either call mbedtls_md_free() to clear the context,
* or call mbedtls_md_hmac_reset() to reuse the context with
* the same HMAC key.
*
* \param ctx HMAC context
* \param output Generic HMAC checksum result
* \param ctx The message digest context containing an embedded HMAC
* context.
* \param output The generic HMAC checksum result.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* verification fails.
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
*
parameter
verification fails.
*/
int
mbedtls_md_hmac_finish
(
mbedtls_md_context_t
*
ctx
,
unsigned
char
*
output
);
/**
* \brief Prepare to authenticate a new message with the same key.
* Called after mbedtls_md_hmac_finish() and before
* mbedtls_md_hmac_update().
* \brief This function prepares to authenticate a new message with
* the same key as the previous HMAC operation.
*
* \param ctx HMAC context to be reset
* You may call this function after mbedtls_md_hmac_finish().
* Afterwards call mbedtls_md_hmac_update() to pass the new
* input.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* verification fails.
* \param ctx The message digest context containing an embedded HMAC
* context.
*
* \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
int
mbedtls_md_hmac_reset
(
mbedtls_md_context_t
*
ctx
);
/**
* \brief Output = Generic_HMAC( hmac key, input buffer )
* \brief This function calculates the full generic HMAC
* on the input buffer with the provided key.
*
* The function allocates the context, performs the
* calculation, and frees the context.
*
* The HMAC result is calculated as
* output = generic HMAC(hmac key, input buffer).
*
* \param md_info message digest info
* \param key HMAC secret key
* \param keylen length of the HMAC key in bytes
* \param input buffer holding the data
* \param ilen length of the input data
* \param output Generic HMAC-result
* \param md_info The information structure of the message-digest algorithm
* to use.
* \param key The HMAC secret key.
* \param keylen The length of the HMAC secret key in Bytes.
* \param input The buffer holding the input data.
* \param ilen The length of the input data.
* \param output The generic HMAC result.
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* verification fails.
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
*
parameter
verification fails.
*/
int
mbedtls_md_hmac
(
const
mbedtls_md_info_t
*
md_info
,
const
unsigned
char
*
key
,
size_t
keylen
,
const
unsigned
char
*
input
,
size_t
ilen
,
...
...
app/include/mbedtls/md2.h
View file @
c7673b02
...
...
@@ -3,6 +3,11 @@
*
* \brief MD2 message digest algorithm (hash function)
*
* \warning MD2 is considered a weak message digest and its use constitutes a
* security risk. We recommend considering stronger message digests
* instead.
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -19,6 +24,7 @@
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*
*/
#ifndef MBEDTLS_MD2_H
#define MBEDTLS_MD2_H
...
...
@@ -31,6 +37,13 @@
#include <stddef.h>
#define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B
/**< MD2 hardware accelerator failed */
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
#if !defined(MBEDTLS_MD2_ALT)
// Regular implementation
//
...
...
@@ -41,6 +54,11 @@ extern "C" {
/**
* \brief MD2 context structure
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
typedef
struct
{
...
...
@@ -55,6 +73,11 @@ mbedtls_md2_context;
* \brief Initialize MD2 context
*
* \param ctx MD2 context to be initialized
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_init
(
mbedtls_md2_context
*
ctx
);
...
...
@@ -62,6 +85,11 @@ void mbedtls_md2_init( mbedtls_md2_context *ctx );
* \brief Clear MD2 context
*
* \param ctx MD2 context to be cleared
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_free
(
mbedtls_md2_context
*
ctx
);
...
...
@@ -70,6 +98,11 @@ void mbedtls_md2_free( mbedtls_md2_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_clone
(
mbedtls_md2_context
*
dst
,
const
mbedtls_md2_context
*
src
);
...
...
@@ -78,25 +111,150 @@ void mbedtls_md2_clone( mbedtls_md2_context *dst,
* \brief MD2 context setup
*
* \param ctx context to be initialized
*
* \return 0 if successful
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md2_starts_ret
(
mbedtls_md2_context
*
ctx
);
/**
* \brief MD2 process buffer
*
* \param ctx MD2 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md2_update_ret
(
mbedtls_md2_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief MD2 final digest
*
* \param ctx MD2 context
* \param output MD2 checksum result
*
* \return 0 if successful
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md2_finish_ret
(
mbedtls_md2_context
*
ctx
,
unsigned
char
output
[
16
]
);
/**
* \brief MD2 process data block (internal use only)
*
* \param ctx MD2 context
*
* \return 0 if successful
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_internal_md2_process
(
mbedtls_md2_context
*
ctx
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief MD2 context setup
*
* \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0
*
* \param ctx context to be initialized
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_starts
(
mbedtls_md2_context
*
ctx
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md2_starts
(
mbedtls_md2_context
*
ctx
)
{
mbedtls_md2_starts_ret
(
ctx
);
}
/**
* \brief MD2 process buffer
*
* \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0
*
* \param ctx MD2 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input data
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_update
(
mbedtls_md2_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md2_update
(
mbedtls_md2_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
)
{
mbedtls_md2_update_ret
(
ctx
,
input
,
ilen
);
}
/**
* \brief MD2 final digest
*
* \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0
*
* \param ctx MD2 context
* \param output MD2 checksum result
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2_finish
(
mbedtls_md2_context
*
ctx
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md2_finish
(
mbedtls_md2_context
*
ctx
,
unsigned
char
output
[
16
]
)
{
mbedtls_md2_finish_ret
(
ctx
,
output
);
}
/**
* \brief MD2 process data block (internal use only)
*
* \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0
*
* \param ctx MD2 context
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md2_process
(
mbedtls_md2_context
*
ctx
)
{
mbedtls_internal_md2_process
(
ctx
);
}
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
...
...
@@ -113,22 +271,61 @@ extern "C" {
/**
* \brief Output = MD2( input buffer )
*
* \param input buffer holding the data
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD2 checksum result
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md2_ret
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief Output = MD2( input buffer )
*
* \deprecated Superseded by mbedtls_md2_ret() in 2.7.0
*
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD2 checksum result
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md2
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md2
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
)
{
mbedtls_md2_ret
(
input
,
ilen
,
output
);
}
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*
* \warning MD2 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md2_self_test
(
int
verbose
);
/* Internal use */
void
mbedtls_md2_process
(
mbedtls_md2_context
*
ctx
);
#ifdef __cplusplus
}
#endif
...
...
app/include/mbedtls/md4.h
View file @
c7673b02
...
...
@@ -3,6 +3,11 @@
*
* \brief MD4 message digest algorithm (hash function)
*
* \warning MD4 is considered a weak message digest and its use constitutes a
* security risk. We recommend considering stronger message digests
* instead.
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -19,6 +24,7 @@
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*
*/
#ifndef MBEDTLS_MD4_H
#define MBEDTLS_MD4_H
...
...
@@ -32,6 +38,13 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D
/**< MD4 hardware accelerator failed */
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
#if !defined(MBEDTLS_MD4_ALT)
// Regular implementation
//
...
...
@@ -42,6 +55,11 @@ extern "C" {
/**
* \brief MD4 context structure
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
typedef
struct
{
...
...
@@ -55,6 +73,11 @@ mbedtls_md4_context;
* \brief Initialize MD4 context
*
* \param ctx MD4 context to be initialized
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_init
(
mbedtls_md4_context
*
ctx
);
...
...
@@ -62,6 +85,11 @@ void mbedtls_md4_init( mbedtls_md4_context *ctx );
* \brief Clear MD4 context
*
* \param ctx MD4 context to be cleared
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_free
(
mbedtls_md4_context
*
ctx
);
...
...
@@ -70,6 +98,11 @@ void mbedtls_md4_free( mbedtls_md4_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_clone
(
mbedtls_md4_context
*
dst
,
const
mbedtls_md4_context
*
src
);
...
...
@@ -78,25 +111,153 @@ void mbedtls_md4_clone( mbedtls_md4_context *dst,
* \brief MD4 context setup
*
* \param ctx context to be initialized
*
* \return 0 if successful
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*/
int
mbedtls_md4_starts_ret
(
mbedtls_md4_context
*
ctx
);
/**
* \brief MD4 process buffer
*
* \param ctx MD4 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md4_update_ret
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief MD4 final digest
*
* \param ctx MD4 context
* \param output MD4 checksum result
*
* \return 0 if successful
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md4_finish_ret
(
mbedtls_md4_context
*
ctx
,
unsigned
char
output
[
16
]
);
/**
* \brief MD4 process data block (internal use only)
*
* \param ctx MD4 context
* \param data buffer holding one block of data
*
* \return 0 if successful
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_internal_md4_process
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief MD4 context setup
*
* \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0
*
* \param ctx context to be initialized
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_starts
(
mbedtls_md4_context
*
ctx
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md4_starts
(
mbedtls_md4_context
*
ctx
)
{
mbedtls_md4_starts_ret
(
ctx
);
}
/**
* \brief MD4 process buffer
*
* \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0
*
* \param ctx MD4 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input data
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_update
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md4_update
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
)
{
mbedtls_md4_update_ret
(
ctx
,
input
,
ilen
);
}
/**
* \brief MD4 final digest
*
* \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0
*
* \param ctx MD4 context
* \param output MD4 checksum result
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4_finish
(
mbedtls_md4_context
*
ctx
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md4_finish
(
mbedtls_md4_context
*
ctx
,
unsigned
char
output
[
16
]
)
{
mbedtls_md4_finish_ret
(
ctx
,
output
);
}
/**
* \brief MD4 process data block (internal use only)
*
* \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0
*
* \param ctx MD4 context
* \param data buffer holding one block of data
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md4_process
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
data
[
64
]
)
{
mbedtls_internal_md4_process
(
ctx
,
data
);
}
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
...
...
@@ -113,22 +274,63 @@ extern "C" {
/**
* \brief Output = MD4( input buffer )
*
* \param input buffer holding the data
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD4 checksum result
*
* \return 0 if successful
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md4_ret
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief Output = MD4( input buffer )
*
* \deprecated Superseded by mbedtls_md4_ret() in 2.7.0
*
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD4 checksum result
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md4
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md4
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
)
{
mbedtls_md4_ret
(
input
,
ilen
,
output
);
}
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*
* \warning MD4 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md4_self_test
(
int
verbose
);
/* Internal use */
void
mbedtls_md4_process
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#ifdef __cplusplus
}
#endif
...
...
app/include/mbedtls/md5.h
View file @
c7673b02
...
...
@@ -3,6 +3,11 @@
*
* \brief MD5 message digest algorithm (hash function)
*
* \warning MD5 is considered a weak message digest and its use constitutes a
* security risk. We recommend considering stronger message
* digests instead.
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -32,16 +37,28 @@
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F
/**< MD5 hardware accelerator failed */
#if !defined(MBEDTLS_MD5_ALT)
// Regular implementation
//
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* \brief MD5 context structure
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
typedef
struct
{
...
...
@@ -55,6 +72,11 @@ mbedtls_md5_context;
* \brief Initialize MD5 context
*
* \param ctx MD5 context to be initialized
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_init
(
mbedtls_md5_context
*
ctx
);
...
...
@@ -62,6 +84,11 @@ void mbedtls_md5_init( mbedtls_md5_context *ctx );
* \brief Clear MD5 context
*
* \param ctx MD5 context to be cleared
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_free
(
mbedtls_md5_context
*
ctx
);
...
...
@@ -70,6 +97,11 @@ void mbedtls_md5_free( mbedtls_md5_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_clone
(
mbedtls_md5_context
*
dst
,
const
mbedtls_md5_context
*
src
);
...
...
@@ -78,28 +110,154 @@ void mbedtls_md5_clone( mbedtls_md5_context *dst,
* \brief MD5 context setup
*
* \param ctx context to be initialized
*
* \return 0 if successful
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md5_starts_ret
(
mbedtls_md5_context
*
ctx
);
/**
* \brief MD5 process buffer
*
* \param ctx MD5 context
* \param input buffer holding the data
* \param ilen length of the input data
*
* \return 0 if successful
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md5_update_ret
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
* \brief MD5 final digest
*
* \param ctx MD5 context
* \param output MD5 checksum result
*
* \return 0 if successful
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md5_finish_ret
(
mbedtls_md5_context
*
ctx
,
unsigned
char
output
[
16
]
);
/**
* \brief MD5 process data block (internal use only)
*
* \param ctx MD5 context
* \param data buffer holding one block of data
*
* \return 0 if successful
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_internal_md5_process
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief MD5 context setup
*
* \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0
*
* \param ctx context to be initialized
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_starts
(
mbedtls_md5_context
*
ctx
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md5_starts
(
mbedtls_md5_context
*
ctx
)
{
mbedtls_md5_starts_ret
(
ctx
);
}
/**
* \brief MD5 process buffer
*
* \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
*
* \param ctx MD5 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input data
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_update
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md5_update
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
)
{
mbedtls_md5_update_ret
(
ctx
,
input
,
ilen
);
}
/**
* \brief MD5 final digest
*
* \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
*
* \param ctx MD5 context
* \param output MD5 checksum result
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md5_finish
(
mbedtls_md5_context
*
ctx
,
unsigned
char
output
[
16
]
)
{
mbedtls_md5_finish_ret
(
ctx
,
output
);
}
/**
* \brief MD5 process data block (internal use only)
*
* \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0
*
* \param ctx MD5 context
* \param data buffer holding one block of data
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5_finish
(
mbedtls_md5_context
*
ctx
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md5_process
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
data
[
64
]
)
{
mbedtls_internal_md5_process
(
ctx
,
data
);
}
/* Internal use */
void
mbedtls_md5_process
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
...
...
@@ -116,16 +274,60 @@ extern "C" {
/**
* \brief Output = MD5( input buffer )
*
* \param input buffer holding the data
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD5 checksum result
*
* \return 0 if successful
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md5_ret
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#if defined(MBEDTLS_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED __attribute__((deprecated))
#else
#define MBEDTLS_DEPRECATED
#endif
/**
* \brief Output = MD5( input buffer )
*
* \deprecated Superseded by mbedtls_md5_ret() in 2.7.0
*
* \param input buffer holding the data
* \param ilen length of the input data
* \param output MD5 checksum result
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
void
mbedtls_md5
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
);
MBEDTLS_DEPRECATED
static
inline
void
mbedtls_md5
(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
output
[
16
]
)
{
mbedtls_md5_ret
(
input
,
ilen
,
output
);
}
#undef MBEDTLS_DEPRECATED
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*
* \warning MD5 is considered a weak message digest and its use
* constitutes a security risk. We recommend considering
* stronger message digests instead.
*
*/
int
mbedtls_md5_self_test
(
int
verbose
);
...
...
app/include/mbedtls/md_internal.h
View file @
c7673b02
...
...
@@ -6,7 +6,8 @@
* \warning This in an internal header. Do not include directly.
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -58,17 +59,17 @@ struct mbedtls_md_info_t
int
block_size
;
/** Digest initialisation function */
void
(
*
starts_func
)(
void
*
ctx
);
int
(
*
starts_func
)(
void
*
ctx
);
/** Digest update function */
void
(
*
update_func
)(
void
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
int
(
*
update_func
)(
void
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/** Digest finalisation function */
void
(
*
finish_func
)(
void
*
ctx
,
unsigned
char
*
output
);
int
(
*
finish_func
)(
void
*
ctx
,
unsigned
char
*
output
);
/** Generic digest function */
void
(
*
digest_func
)(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
*
output
);
int
(
*
digest_func
)(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
*
output
);
/** Allocate a new context */
void
*
(
*
ctx_alloc_func
)(
void
);
...
...
@@ -80,7 +81,7 @@ struct mbedtls_md_info_t
void
(
*
clone_func
)(
void
*
dst
,
const
void
*
src
);
/** Internal use only */
void
(
*
process_func
)(
void
*
ctx
,
const
unsigned
char
*
input
);
int
(
*
process_func
)(
void
*
ctx
,
const
unsigned
char
*
input
);
};
#if defined(MBEDTLS_MD2_C)
...
...
app/include/mbedtls/memory_buffer_alloc.h
View file @
c7673b02
...
...
@@ -2,7 +2,8 @@
* \file memory_buffer_alloc.h
*
* \brief Buffer-based memory allocator
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
app/include/mbedtls/net.h
View file @
c7673b02
...
...
@@ -3,6 +3,9 @@
*
* \brief Deprecated header file that includes mbedtls/net_sockets.h
*
* \deprecated Superseded by mbedtls/net_sockets.h
*/
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
...
...
@@ -19,8 +22,6 @@
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*
* \deprecated Superseded by mbedtls/net_sockets.h
*/
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
...
...
Prev
1
2
3
4
5
6
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment