Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
67027c0d
Unverified
Commit
67027c0d
authored
Apr 02, 2018
by
Marcel Stör
Committed by
GitHub
Apr 02, 2018
Browse files
Merge pull request #2340 from nodemcu/dev
2.2 master snap
parents
5073c199
18f33f5f
Changes
291
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
291 of 291+
files are displayed.
Plain diff
Email patch
app/include/mbedtls/ecp_internal.h
0 → 100644
View file @
67027c0d
/**
* \file ecp_internal.h
*
* \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
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* References:
*
* [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records.
* <http://cr.yp.to/ecdh/curve25519-20060209.pdf>
*
* [2] CORON, Jean-S'ebastien. Resistance against differential power analysis
* for elliptic curve cryptosystems. In : Cryptographic Hardware and
* Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302.
* <http://link.springer.com/chapter/10.1007/3-540-48059-5_25>
*
* [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to
* render ECC resistant against Side Channel Attacks. IACR Cryptology
* ePrint Archive, 2004, vol. 2004, p. 342.
* <http://eprint.iacr.org/2004/342.pdf>
*
* [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters.
* <http://www.secg.org/sec2-v2.pdf>
*
* [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic
* Curve Cryptography.
*
* [6] Digital Signature Standard (DSS), FIPS 186-4.
* <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf>
*
* [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer
* Security (TLS), RFC 4492.
* <https://tools.ietf.org/search/rfc4492>
*
* [8] <http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html>
*
* [9] COHEN, Henri. A Course in Computational Algebraic Number Theory.
* Springer Science & Business Media, 1 Aug 2000
*/
#ifndef MBEDTLS_ECP_INTERNAL_H
#define MBEDTLS_ECP_INTERNAL_H
#if defined(MBEDTLS_ECP_INTERNAL_ALT)
/**
* \brief Indicate if the Elliptic Curve Point module extension can
* handle the group.
*
* \param grp The pointer to the elliptic curve group that will be the
* basis of the cryptographic computations.
*
* \return Non-zero if successful.
*/
unsigned
char
mbedtls_internal_ecp_grp_capable
(
const
mbedtls_ecp_group
*
grp
);
/**
* \brief Initialise the Elliptic Curve Point module extension.
*
* If mbedtls_internal_ecp_grp_capable returns true for a
* group, this function has to be able to initialise the
* module for it.
*
* This module can be a driver to a crypto hardware
* accelerator, for which this could be an initialise function.
*
* \param grp The pointer to the group the module needs to be
* initialised for.
*
* \return 0 if successful.
*/
int
mbedtls_internal_ecp_init
(
const
mbedtls_ecp_group
*
grp
);
/**
* \brief Frees and deallocates the Elliptic Curve Point module
* extension.
*
* \param grp The pointer to the group the module was initialised for.
*/
void
mbedtls_internal_ecp_free
(
const
mbedtls_ecp_group
*
grp
);
#if defined(ECP_SHORTWEIERSTRASS)
#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
/**
* \brief Randomize jacobian coordinates:
* (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l.
*
* \param grp Pointer to the group representing the curve.
*
* \param pt The point on the curve to be randomised, given with Jacobian
* coordinates.
*
* \param f_rng A function pointer to the random number generator.
*
* \param p_rng A pointer to the random number generator state.
*
* \return 0 if successful.
*/
int
mbedtls_internal_ecp_randomize_jac
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
pt
,
int
(
*
f_rng
)(
void
*
,
unsigned
char
*
,
size_t
),
void
*
p_rng
);
#endif
#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
/**
* \brief Addition: R = P + Q, mixed affine-Jacobian coordinates.
*
* The coordinates of Q must be normalized (= affine),
* but those of P don't need to. R is not normalized.
*
* This function is used only as a subrutine of
* ecp_mul_comb().
*
* Special cases: (1) P or Q is zero, (2) R is zero,
* (3) P == Q.
* None of these cases can happen as intermediate step in
* ecp_mul_comb():
* - at each step, P, Q and R are multiples of the base
* point, the factor being less than its order, so none of
* them is zero;
* - Q is an odd multiple of the base point, P an even
* multiple, due to the choice of precomputed points in the
* modified comb method.
* So branches for these cases do not leak secret information.
*
* We accept Q->Z being unset (saving memory in tables) as
* meaning 1.
*
* Cost in field operations if done by [5] 3.22:
* 1A := 8M + 3S
*
* \param grp Pointer to the group representing the curve.
*
* \param R Pointer to a point structure to hold the result.
*
* \param P Pointer to the first summand, given with Jacobian
* coordinates
*
* \param Q Pointer to the second summand, given with affine
* coordinates.
*
* \return 0 if successful.
*/
int
mbedtls_internal_ecp_add_mixed
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
R
,
const
mbedtls_ecp_point
*
P
,
const
mbedtls_ecp_point
*
Q
);
#endif
/**
* \brief Point doubling R = 2 P, Jacobian coordinates.
*
* Cost: 1D := 3M + 4S (A == 0)
* 4M + 4S (A == -3)
* 3M + 6S + 1a otherwise
* when the implementation is based on the "dbl-1998-cmo-2"
* doubling formulas in [8] and standard optimizations are
* applied when curve parameter A is one of { 0, -3 }.
*
* \param grp Pointer to the group representing the curve.
*
* \param R Pointer to a point structure to hold the result.
*
* \param P Pointer to the point that has to be doubled, given with
* Jacobian coordinates.
*
* \return 0 if successful.
*/
#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
int
mbedtls_internal_ecp_double_jac
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
R
,
const
mbedtls_ecp_point
*
P
);
#endif
/**
* \brief Normalize jacobian coordinates of an array of (pointers to)
* points.
*
* Using Montgomery's trick to perform only one inversion mod P
* the cost is:
* 1N(t) := 1I + (6t - 3)M + 1S
* (See for example Algorithm 10.3.4. in [9])
*
* This function is used only as a subrutine of
* ecp_mul_comb().
*
* Warning: fails (returning an error) if one of the points is
* zero!
* This should never happen, see choice of w in ecp_mul_comb().
*
* \param grp Pointer to the group representing the curve.
*
* \param T Array of pointers to the points to normalise.
*
* \param t_len Number of elements in the array.
*
* \return 0 if successful,
* an error if one of the points is zero.
*/
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
int
mbedtls_internal_ecp_normalize_jac_many
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
T
[],
size_t
t_len
);
#endif
/**
* \brief Normalize jacobian coordinates so that Z == 0 || Z == 1.
*
* Cost in field operations if done by [5] 3.2.1:
* 1N := 1I + 3M + 1S
*
* \param grp Pointer to the group representing the curve.
*
* \param pt pointer to the point to be normalised. This is an
* input/output parameter.
*
* \return 0 if successful.
*/
#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
int
mbedtls_internal_ecp_normalize_jac
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
pt
);
#endif
#endif
/* ECP_SHORTWEIERSTRASS */
#if defined(ECP_MONTGOMERY)
#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
int
mbedtls_internal_ecp_double_add_mxz
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
R
,
mbedtls_ecp_point
*
S
,
const
mbedtls_ecp_point
*
P
,
const
mbedtls_ecp_point
*
Q
,
const
mbedtls_mpi
*
d
);
#endif
/**
* \brief Randomize projective x/z coordinates:
* (X, Z) -> (l X, l Z) for random l
*
* \param grp pointer to the group representing the curve
*
* \param P the point on the curve to be randomised given with
* projective coordinates. This is an input/output parameter.
*
* \param f_rng a function pointer to the random number generator
*
* \param p_rng a pointer to the random number generator state
*
* \return 0 if successful
*/
#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
int
mbedtls_internal_ecp_randomize_mxz
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
P
,
int
(
*
f_rng
)(
void
*
,
unsigned
char
*
,
size_t
),
void
*
p_rng
);
#endif
/**
* \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1.
*
* \param grp pointer to the group representing the curve
*
* \param P pointer to the point to be normalised. This is an
* input/output parameter.
*
* \return 0 if successful
*/
#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
int
mbedtls_internal_ecp_normalize_mxz
(
const
mbedtls_ecp_group
*
grp
,
mbedtls_ecp_point
*
P
);
#endif
#endif
/* ECP_MONTGOMERY */
#endif
/* MBEDTLS_ECP_INTERNAL_ALT */
#endif
/* ecp_internal.h */
app/include/mbedtls/entropy.h
View file @
67027c0d
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
* \file entropy.h
* \file entropy.h
*
*
* \brief Entropy accumulator implementation
* \brief Entropy accumulator implementation
*
*/
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
@@ -121,6 +122,7 @@ mbedtls_entropy_source_state;
...
@@ -121,6 +122,7 @@ mbedtls_entropy_source_state;
*/
*/
typedef
struct
typedef
struct
{
{
int
accumulator_started
;
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
mbedtls_sha512_context
accumulator
;
mbedtls_sha512_context
accumulator
;
#else
#else
...
@@ -134,6 +136,9 @@ typedef struct
...
@@ -134,6 +136,9 @@ typedef struct
#if defined(MBEDTLS_THREADING_C)
#if defined(MBEDTLS_THREADING_C)
mbedtls_threading_mutex_t
mutex
;
/*!< mutex */
mbedtls_threading_mutex_t
mutex
;
/*!< mutex */
#endif
#endif
#if defined(MBEDTLS_ENTROPY_NV_SEED)
int
initial_entropy_run
;
#endif
}
}
mbedtls_entropy_context
;
mbedtls_entropy_context
;
...
@@ -208,6 +213,18 @@ int mbedtls_entropy_func( void *data, unsigned char *output, size_t len );
...
@@ -208,6 +213,18 @@ int mbedtls_entropy_func( void *data, unsigned char *output, size_t len );
int
mbedtls_entropy_update_manual
(
mbedtls_entropy_context
*
ctx
,
int
mbedtls_entropy_update_manual
(
mbedtls_entropy_context
*
ctx
,
const
unsigned
char
*
data
,
size_t
len
);
const
unsigned
char
*
data
,
size_t
len
);
#if defined(MBEDTLS_ENTROPY_NV_SEED)
/**
* \brief Trigger an update of the seed file in NV by using the
* current entropy pool.
*
* \param ctx Entropy context
*
* \return 0 if successful
*/
int
mbedtls_entropy_update_nv_seed
(
mbedtls_entropy_context
*
ctx
);
#endif
/* MBEDTLS_ENTROPY_NV_SEED */
#if defined(MBEDTLS_FS_IO)
#if defined(MBEDTLS_FS_IO)
/**
/**
* \brief Write a seed file
* \brief Write a seed file
...
@@ -240,9 +257,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
...
@@ -240,9 +257,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
/**
/**
* \brief Checkup routine
* \brief Checkup routine
*
*
* This module self-test also calls the entropy self-test,
* mbedtls_entropy_source_self_test();
*
* \return 0 if successful, or 1 if a test failed
* \return 0 if successful, or 1 if a test failed
*/
*/
int
mbedtls_entropy_self_test
(
int
verbose
);
int
mbedtls_entropy_self_test
(
int
verbose
);
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
/**
* \brief Checkup routine
*
* Verifies the integrity of the hardware entropy source
* provided by the function 'mbedtls_hardware_poll()'.
*
* Note this is the only hardware entropy source that is known
* at link time, and other entropy sources configured
* dynamically at runtime by the function
* mbedtls_entropy_add_source() will not be tested.
*
* \return 0 if successful, or 1 if a test failed
*/
int
mbedtls_entropy_source_self_test
(
int
verbose
);
#endif
/* MBEDTLS_ENTROPY_HARDWARE_ALT */
#endif
/* MBEDTLS_SELF_TEST */
#endif
/* MBEDTLS_SELF_TEST */
#ifdef __cplusplus
#ifdef __cplusplus
...
...
app/include/mbedtls/entropy_poll.h
View file @
67027c0d
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
* \file entropy_poll.h
* \file entropy_poll.h
*
*
* \brief Platform-specific and custom entropy polling functions
* \brief Platform-specific and custom entropy polling functions
*
*/
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
@@ -41,7 +42,17 @@ extern "C" {
...
@@ -41,7 +42,17 @@ extern "C" {
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32
/**< Minimum for platform source */
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32
/**< Minimum for platform source */
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32
/**< Minimum for HAVEGE */
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32
/**< Minimum for HAVEGE */
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4
/**< Minimum for mbedtls_timing_hardclock() */
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4
/**< Minimum for mbedtls_timing_hardclock() */
#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32
/**< Minimum for the hardware source */
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32
/**< Minimum for the hardware source */
#endif
/**
* \brief Entropy poll callback that provides 0 entropy.
*/
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
int
mbedtls_null_entropy_poll
(
void
*
data
,
unsigned
char
*
output
,
size_t
len
,
size_t
*
olen
);
#endif
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
#if !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
/**
/**
...
@@ -82,6 +93,16 @@ int mbedtls_hardware_poll( void *data,
...
@@ -82,6 +93,16 @@ int mbedtls_hardware_poll( void *data,
unsigned
char
*
output
,
size_t
len
,
size_t
*
olen
);
unsigned
char
*
output
,
size_t
len
,
size_t
*
olen
);
#endif
#endif
#if defined(MBEDTLS_ENTROPY_NV_SEED)
/**
* \brief Entropy poll callback for a non-volatile seed file
*
* \note This must accept NULL as its first argument.
*/
int
mbedtls_nv_seed_poll
(
void
*
data
,
unsigned
char
*
output
,
size_t
len
,
size_t
*
olen
);
#endif
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
app/include/mbedtls/error.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file error.h
* \file error.h
*
*
* \brief Error to string translation
* \brief Error to string translation
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -49,36 +50,45 @@
...
@@ -49,36 +50,45 @@
*
*
* Module Nr Codes assigned
* Module Nr Codes assigned
* MPI 7 0x0002-0x0010
* MPI 7 0x0002-0x0010
* GCM
2
0x0012-0x0014
* GCM
3
0x0012-0x0014
0x0013-0x0013
* BLOWFISH
2
0x0016-0x0018
* BLOWFISH
3
0x0016-0x0018
0x0017-0x0017
* THREADING 3 0x001A-0x001E
* THREADING 3 0x001A-0x001E
* AES
2
0x0020-0x0022
* AES
4
0x0020-0x0022
0x0023-0x0025
* CAMELLIA
2
0x0024-0x0026
* CAMELLIA
3
0x0024-0x0026
0x0027-0x0027
* XTEA
1
0x0028-0x0028
* XTEA
2
0x0028-0x0028
0x0029-0x0029
* BASE64 2 0x002A-0x002C
* BASE64 2 0x002A-0x002C
* OID 1 0x002E-0x002E 0x000B-0x000B
* OID 1 0x002E-0x002E 0x000B-0x000B
* PADLOCK 1 0x0030-0x0030
* PADLOCK 1 0x0030-0x0030
* DES
1
0x0032-0x0032
* DES
2
0x0032-0x0032
0x0033-0x0033
* CTR_DBRG 4 0x0034-0x003A
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
* NET 11 0x0042-0x0052 0x0043-0x0045
* NET 11 0x0042-0x0052 0x0043-0x0045
* ASN1 7 0x0060-0x006C
* ASN1 7 0x0060-0x006C
* CMAC 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
* PBKDF2 1 0x007C-0x007C
* HMAC_DRBG 4 0x0003-0x0009
* HMAC_DRBG 4 0x0003-0x0009
* CCM 2 0x000D-0x000F
* 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...)
* High-level module nr (3 bits - 0x0...-0x7...)
* Name ID Nr of Errors
* Name ID Nr of Errors
* PEM 1 9
* PEM 1 9
* PKCS#12 1 4 (Started from top)
* PKCS#12 1 4 (Started from top)
* X509 2
19
* X509 2
20
* PKCS5 2 4 (Started from top)
* PKCS5 2 4 (Started from top)
* DHM 3
9
* DHM 3
11
* PK 3 1
4
(Started from top)
* PK 3 1
5
(Started from top)
* RSA 4
9
* RSA 4
11
* ECP 4
8
(Started from top)
* ECP 4
9
(Started from top)
* MD 5
4
* MD 5
5
* CIPHER 6
6
* CIPHER 6
8
* SSL 6 17 (Started from top)
* SSL 6 17 (Started from top)
* SSL 7 31
* SSL 7 31
*
*
...
...
app/include/mbedtls/gcm.h
View file @
67027c0d
/**
/**
* \file gcm.h
* \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
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
@@ -18,8 +25,9 @@
...
@@ -18,8 +25,9 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* 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
#ifndef MBEDTLS_GCM_H
#define MBEDTLS_GCM_H
#define MBEDTLS_GCM_H
...
@@ -31,46 +39,59 @@
...
@@ -31,46 +39,59 @@
#define MBEDTLS_GCM_DECRYPT 0
#define MBEDTLS_GCM_DECRYPT 0
#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
/**< Authenticated decryption failed. */
#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. */
#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
/**< Bad input parameters to function. */
#if !defined(MBEDTLS_GCM_ALT)
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
/**
/**
* \brief GCM context structure
* \brief
The
GCM context structure
.
*/
*/
typedef
struct
{
typedef
struct
{
mbedtls_cipher_context_t
cipher_ctx
;
/*!< cipher context used */
mbedtls_cipher_context_t
cipher_ctx
;
/*!< The cipher context used. */
uint64_t
HL
[
16
];
/*!< Precalculated HTable */
uint64_t
HL
[
16
];
/*!< Precalculated HTable low. */
uint64_t
HH
[
16
];
/*!< Precalculated HTable */
uint64_t
HH
[
16
];
/*!< Precalculated HTable high. */
uint64_t
len
;
/*!< Total data length */
uint64_t
len
;
/*!< The total length of the encrypted data. */
uint64_t
add_len
;
/*!< Total add length */
uint64_t
add_len
;
/*!< The total length of the additional data. */
unsigned
char
base_ectr
[
16
];
/*!< First ECTR for tag */
unsigned
char
base_ectr
[
16
];
/*!< The first ECTR for tag. */
unsigned
char
y
[
16
];
/*!< Y working value */
unsigned
char
y
[
16
];
/*!< The Y working value. */
unsigned
char
buf
[
16
];
/*!< buf working value */
unsigned
char
buf
[
16
];
/*!< The buf working value. */
int
mode
;
/*!< Encrypt or Decrypt */
int
mode
;
/*!< The operation to perform:
#MBEDTLS_GCM_ENCRYPT or
#MBEDTLS_GCM_DECRYPT. */
}
}
mbedtls_gcm_context
;
mbedtls_gcm_context
;
/**
/**
* \brief Initialize GCM context (just makes references valid)
* \brief This function initializes the specified GCM context,
* Makes the context ready for mbedtls_gcm_setkey() or
* to make references valid, and prepares the context
* mbedtls_gcm_free().
* 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
);
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 ctx The GCM context to initialize.
* \param cipher cipher to use (a 128-bit block cipher)
* \param cipher The 128-bit block cipher to use.
* \param key encryption key
* \param key The encryption key.
* \param keybits must be 128, 192 or 256
* \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
,
int
mbedtls_gcm_setkey
(
mbedtls_gcm_context
*
ctx
,
mbedtls_cipher_id_t
cipher
,
mbedtls_cipher_id_t
cipher
,
...
@@ -78,26 +99,27 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
...
@@ -78,26 +99,27 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
unsigned
int
keybits
);
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.
* \note
For
encryption, the output buffer can be the same as the input buffer.
*
On
decryption, the output buffer cannot be the same as input buffer.
*
For
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
* behind the input buffer.
*
*
* \param ctx GCM context
* \param ctx The GCM context to use for encryption or decryption.
* \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
* \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
* \param length length of the input data
* #MBEDTLS_GCM_DECRYPT.
* \param iv initialization vector
* \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_len length of IV
* \param iv The initialization vector.
* \param add additional data
* \param iv_len The length of the IV.
* \param add_len length of additional data
* \param add The buffer holding the additional data.
* \param input buffer holding the input data
* \param add_len The length of the additional data.
* \param output buffer for holding the output data
* \param input The buffer holding the input data.
* \param tag_len length of the tag to generate
* \param output The buffer for holding the output data.
* \param tag buffer for holding the tag
* \param tag_len The length of the tag to generate.
*
* \param tag The buffer for holding the tag.
* \return 0 if successful
*
* \return \c 0 on success.
*/
*/
int
mbedtls_gcm_crypt_and_tag
(
mbedtls_gcm_context
*
ctx
,
int
mbedtls_gcm_crypt_and_tag
(
mbedtls_gcm_context
*
ctx
,
int
mode
,
int
mode
,
...
@@ -112,25 +134,26 @@ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx,
...
@@ -112,25 +134,26 @@ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx,
unsigned
char
*
tag
);
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.
* \note
For
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
* behind the input buffer.
*
*
* \param ctx GCM context
* \param ctx
The
GCM context
.
* \param length length of the input data
* \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 initialization vector
* \param iv
The
initialization vector
.
* \param iv_len length of IV
* \param iv_len
The
length of
the
IV
.
* \param add additional data
* \param add
The buffer holding the
additional data
.
* \param add_len length of additional data
* \param add_len
The
length of
the
additional data
.
* \param tag buffer holding the tag
* \param tag
The
buffer holding the tag
.
* \param tag_len length of the tag
* \param tag_len
The
length of the tag
.
* \param input buffer holding the input data
* \param input
The
buffer holding the input data
.
* \param output buffer for holding the output data
* \param output
The
buffer for holding the output data
.
*
*
* \return 0 if successful and authenticated,
* \return 0 if successful and authenticated,
or
* MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match
*
#
MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match
.
*/
*/
int
mbedtls_gcm_auth_decrypt
(
mbedtls_gcm_context
*
ctx
,
int
mbedtls_gcm_auth_decrypt
(
mbedtls_gcm_context
*
ctx
,
size_t
length
,
size_t
length
,
...
@@ -144,16 +167,18 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx,
...
@@ -144,16 +167,18 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx,
unsigned
char
*
output
);
unsigned
char
*
output
);
/**
/**
* \brief Generic GCM stream start function
* \brief This function starts a GCM encryption or decryption
* operation.
*
*
* \param ctx GCM context
* \param ctx The GCM context.
* \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
* \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
* \param iv initialization vector
* #MBEDTLS_GCM_DECRYPT.
* \param iv_len length of IV
* \param iv The initialization vector.
* \param add additional data (or NULL if length is 0)
* \param iv_len The length of the IV.
* \param add_len length of additional data
* \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
mbedtls_gcm_starts
(
mbedtls_gcm_context
*
ctx
,
int
mode
,
int
mode
,
...
@@ -163,21 +188,23 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
...
@@ -163,21 +188,23 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
size_t
add_len
);
size_t
add_len
);
/**
/**
* \brief Generic GCM update function. Encrypts/decrypts using the
* \brief This function feeds an input buffer into an ongoing GCM
* given GCM context. Expects input to be a multiple of 16
* encryption or decryption operation.
* bytes! Only the last call before mbedtls_gcm_finish() can be less
*
* than 16 bytes!
* ` 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.
* \note
For
decryption, the output buffer cannot be the same as input buffer.
* If buffers overlap, the output buffer must trail at least 8
b
ytes
* If
the
buffers overlap, the output buffer must trail at least 8
B
ytes
* behind the input buffer.
* behind the input buffer.
*
*
* \param ctx GCM context
* \param ctx
The
GCM context
.
* \param length length of the input data
* \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 buffer holding the input data
* \param input
The
buffer holding the input data
.
* \param output buffer for holding the output 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
,
int
mbedtls_gcm_update
(
mbedtls_gcm_context
*
ctx
,
size_t
length
,
size_t
length
,
...
@@ -185,31 +212,46 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
...
@@ -185,31 +212,46 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
unsigned
char
*
output
);
unsigned
char
*
output
);
/**
/**
* \brief Generic GCM finalisation function. Wraps up the GCM stream
* \brief This function finishes the GCM operation and generates
* and generates the tag. The tag can have a maximum length of
* the authentication tag.
* 16 bytes.
*
*
* \param ctx GCM context
* It wraps up the GCM stream, and generates the
* \param tag buffer for holding the tag (may be NULL if tag_len is 0)
* tag. The tag can have a maximum length of 16 Bytes.
* \param tag_len length of the tag to generate
*
*
* \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
,
int
mbedtls_gcm_finish
(
mbedtls_gcm_context
*
ctx
,
unsigned
char
*
tag
,
unsigned
char
*
tag
,
size_t
tag_len
);
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
);
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
);
int
mbedtls_gcm_self_test
(
int
verbose
);
...
@@ -217,4 +259,5 @@ int mbedtls_gcm_self_test( int verbose );
...
@@ -217,4 +259,5 @@ int mbedtls_gcm_self_test( int verbose );
}
}
#endif
#endif
#endif
/* gcm.h */
#endif
/* gcm.h */
app/include/mbedtls/havege.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file havege.h
* \file havege.h
*
*
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
...
app/include/mbedtls/hmac_drbg.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file hmac_drbg.h
* \file hmac_drbg.h
*
*
* \brief HMAC_DRBG (NIST SP 800-90A)
* \brief HMAC_DRBG (NIST SP 800-90A)
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
...
app/include/mbedtls/mbedtls_debug.h
deleted
100644 → 0
View file @
5073c199
#ifndef _MBEDTLS_DEBUG_H_
#define _MBEDTLS_DEBUG_H_
#include "osapi.h"
#define MBEDTLS_SSL_DEBUG_MSG( level, args ) os_printf args;
#define MBEDTLS_SSL_DEBUG_RET( level, ... ) os_printf (__VA_ARGS__);
#define MBEDTLS_SSL_DEBUG_BUF( level, ... ) os_printf (__VA_ARGS__);
#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
#endif
app/include/mbedtls/md.h
View file @
67027c0d
/**
/**
* \file md.h
* \file md.h
*
*
* \brief
G
eneric message
digest wrapper
* \brief
The g
eneric message
-
digest wrapper
.
*
*
* \author Adriaan de Jong <dejong@fox-it.com>
* \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
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
@@ -20,22 +21,38 @@
...
@@ -20,22 +21,38 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* 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
#ifndef MBEDTLS_MD_H
#define MBEDTLS_MD_H
#define MBEDTLS_MD_H
#include <stddef.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_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_BAD_INPUT_DATA -0x5100
/**< Bad input parameters to function. */
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180
/**< Failed to allocate memory. */
#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_FILE_IO_ERROR -0x5200
/**< Opening or reading of file failed. */
#define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280
/**< MD hardware accelerator failed. */
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#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
{
typedef
enum
{
MBEDTLS_MD_NONE
=
0
,
MBEDTLS_MD_NONE
=
0
,
MBEDTLS_MD_MD2
,
MBEDTLS_MD_MD2
,
...
@@ -56,65 +73,79 @@ typedef enum {
...
@@ -56,65 +73,79 @@ typedef enum {
#endif
#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
;
typedef
struct
mbedtls_md_info_t
mbedtls_md_info_t
;
/**
/**
*
G
eneric message
digest context.
*
The g
eneric message
-
digest context.
*/
*/
typedef
struct
{
typedef
struct
{
/** Information about the associated message digest */
/** Information about the associated message digest
.
*/
const
mbedtls_md_info_t
*
md_info
;
const
mbedtls_md_info_t
*
md_info
;
/**
D
igest-specific context */
/**
The d
igest-specific context
.
*/
void
*
md_ctx
;
void
*
md_ctx
;
/** HMAC part of the context */
/**
The
HMAC part of the context
.
*/
void
*
hmac_ctx
;
void
*
hmac_ctx
;
}
mbedtls_md_context_t
;
}
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
* \return A statically allocated array of digests. Each element
* is 0.
* 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
);
const
int
*
mbedtls_md_list
(
void
);
/**
/**
* \brief
R
eturns the message
digest information
associated with the
* \brief
This function r
eturns the message
-
digest information
* given digest name.
*
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
* \return The message
-
digest information associated with
\p
md_name
,
* NULL if not found.
*
or
NULL if not found.
*/
*/
const
mbedtls_md_info_t
*
mbedtls_md_info_from_string
(
const
char
*
md_name
);
const
mbedtls_md_info_t
*
mbedtls_md_info_from_string
(
const
char
*
md_name
);
/**
/**
* \brief
R
eturns the message
digest information
associated with the
* \brief
This function r
eturns the message
-
digest information
* given digest type.
*
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
* \return The message
-
digest information associated with
\p
md_type
,
* NULL if not found.
*
or
NULL if not found.
*/
*/
const
mbedtls_md_info_t
*
mbedtls_md_info_from_type
(
mbedtls_md_type_t
md_type
);
const
mbedtls_md_info_t
*
mbedtls_md_info_from_type
(
mbedtls_md_type_t
md_type
);
/**
/**
* \brief Initialize a md_context (as NONE)
* \brief This function initializes a message-digest context without
* This should always be called first.
* binding it to a particular message-digest algorithm.
* Prepares the context for mbedtls_md_setup() or mbedtls_md_free().
*
* 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
);
void
mbedtls_md_init
(
mbedtls_md_context_t
*
ctx
);
/**
/**
* \brief Free and clear the internal structures of ctx.
* \brief This function clears the internal structure of \p ctx and
* Can be called at any time after mbedtls_md_init().
* frees any embedded internal structure, but does not free
* Mandatory once mbedtls_md_setup() has been called.
* \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
);
void
mbedtls_md_free
(
mbedtls_md_context_t
*
ctx
);
...
@@ -125,219 +156,288 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx );
...
@@ -125,219 +156,288 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx );
#define MBEDTLS_DEPRECATED
#define MBEDTLS_DEPRECATED
#endif
#endif
/**
/**
* \brief Select MD to use and allocate internal structures.
* \brief This function selects the message digest algorithm to use,
* Should be called after mbedtls_md_init() or mbedtls_md_free().
* 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.
* Makes it necessary to call mbedtls_md_free() later.
*
*
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
*
*
* \param ctx Context to set up.
* \param ctx The context to set up.
* \param md_info Message digest to use.
* \param md_info The information structure of the message-digest algorithm
* to use.
*
*
* \returns \c 0 on success,
* \returns \c 0 on success,
*
\c
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
\c
MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation 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
;
int
mbedtls_md_init_ctx
(
mbedtls_md_context_t
*
ctx
,
const
mbedtls_md_info_t
*
md_info
)
MBEDTLS_DEPRECATED
;
#undef MBEDTLS_DEPRECATED
#undef MBEDTLS_DEPRECATED
#endif
/* MBEDTLS_DEPRECATED_REMOVED */
#endif
/* MBEDTLS_DEPRECATED_REMOVED */
/**
/**
* \brief Select MD to use and allocate internal structures.
* \brief This function selects the message digest algorithm to use,
* Should be called after mbedtls_md_init() or mbedtls_md_free().
* and allocates internal structures.
* Makes it necessary to call mbedtls_md_free() later.
*
*
* \param ctx Context to set up.
* It should be called after mbedtls_md_init() or
* \param md_info Message digest to use.
* mbedtls_md_free(). Makes it necessary to call
* \param hmac 0 to save some memory if HMAC will not be used,
* mbedtls_md_free() later.
* non-zero is HMAC is going to be used with this context.
*
* \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,
* \returns \c 0 on success,
*
\c
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
*
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
or
*
\c
MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
*
#
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
);
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
* \note The two contexts must have the same type
,
*
(cloning from SHA-256 to SHA-512 make no sense)
.
*
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 dst The destination context
.
* \param src The context to be cloned
* \param src The context to be cloned
.
*
*
* \return \c 0 on success,
* \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
,
int
mbedtls_md_clone
(
mbedtls_md_context_t
*
dst
,
const
mbedtls_md_context_t
*
src
);
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.
*/
*/
int
mbedtls_md_get_size
(
const
mbedtls_md_info_t
*
md_info
);
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
);
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
);
const
char
*
mbedtls_md_get_name
(
const
mbedtls_md_info_t
*
md_info
);
/**
/**
* \brief Prepare the context to digest a new message.
* \brief This function starts a message-digest computation.
* Generally called after mbedtls_md_setup() or mbedtls_md_finish().
* Followed by mbedtls_md_update().
*
*
* \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
* \param ctx The generic message-digest context.
* verification fails.
*
* \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* parameter verification fails.
*/
*/
int
mbedtls_md_starts
(
mbedtls_md_context_t
*
ctx
);
int
mbedtls_md_starts
(
mbedtls_md_context_t
*
ctx
);
/**
/**
* \brief Generic message digest process buffer
* \brief This function feeds an input buffer into an ongoing
* Called between mbedtls_md_starts() and mbedtls_md_finish().
* message-digest computation.
* May be called repeatedly.
*
* 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 ctx
The g
eneric message
-
digest context
.
* \param input buffer holding the data
l
* \param input
The
buffer holding the
input
data
.
* \param ilen length of the input data
* \param ilen
The
length of the input data
.
*
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* \returns
\c
0 on success,
#
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* verification fails.
*
parameter
verification fails.
*/
*/
int
mbedtls_md_update
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
int
mbedtls_md_update
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
/**
/**
* \brief Generic message digest final digest
* \brief This function finishes the digest operation,
* Called after mbedtls_md_update().
* and writes the result to the output buffer.
* Usually followed by mbedtls_md_free() or mbedtls_md_starts().
*
*
* \param ctx Generic message digest context
* Call this function after a call to mbedtls_md_starts(),
* \param output Generic message digest checksum result
* 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
* \param ctx The generic message-digest context.
* verification fails.
* \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
);
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 md_info The information structure of the message-digest algorithm
* \param input buffer holding the data
* to use.
* \param ilen length of the input data
* \param input The buffer holding the data.
* \param output Generic message digest checksum result
* \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
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* verification fails.
*
parameter
verification fails.
*/
*/
int
mbedtls_md
(
const
mbedtls_md_info_t
*
md_info
,
const
unsigned
char
*
input
,
size_t
ilen
,
int
mbedtls_md
(
const
mbedtls_md_info_t
*
md_info
,
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
*
output
);
unsigned
char
*
output
);
#if defined(MBEDTLS_FS_IO)
#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 md_info The information structure of the message-digest algorithm
* \param path input file name
* to use.
* \param output generic message digest checksum result
* \param path The input file name.
* \param output The generic message-digest checksum result.
*
*
* \return
0 if
success
ful
,
* \return
\c 0 on
success,
* MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
*
#
MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
or
* MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
*
#
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
,
int
mbedtls_md_file
(
const
mbedtls_md_info_t
*
md_info
,
const
char
*
path
,
unsigned
char
*
output
);
unsigned
char
*
output
);
#endif
/* MBEDTLS_FS_IO */
#endif
/* MBEDTLS_FS_IO */
/**
/**
* \brief
Set
HMAC key and prepare to
authenticate a new message.
* \brief
This function sets the
HMAC key and prepare
s
to
*
Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish()
.
*
authenticate a new message
.
*
*
* \param ctx HMAC context
* Call this function after mbedtls_md_setup(), to use
* \param key HMAC secret key
* the MD context for an HMAC calculation, then call
* \param keylen length of the HMAC key in bytes
* 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
* \param ctx The message digest context containing an embedded HMAC
* verification fails.
* 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
,
int
mbedtls_md_hmac_starts
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
key
,
size_t
keylen
);
size_t
keylen
);
/**
/**
* \brief Generic HMAC process buffer.
* \brief This function feeds an input buffer into an ongoing HMAC
* Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
* computation.
* and mbedtls_md_hmac_finish().
*
* May be called repeatedly.
* Call mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
*
* before calling this function.
* \param ctx HMAC context
* You may call this function multiple times to pass the
* \param input buffer holding the data
* input piecewise.
* \param ilen length of the input data
* Afterwards, call mbedtls_md_hmac_finish().
*
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
* \param ctx The message digest context containing an embedded HMAC
* verification fails.
* 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
,
int
mbedtls_md_hmac_update
(
mbedtls_md_context_t
*
ctx
,
const
unsigned
char
*
input
,
size_t
ilen
);
size_t
ilen
);
/**
/**
* \brief Output HMAC.
* \brief This function finishes the HMAC operation, and writes
* Called after mbedtls_md_hmac_update().
* the result to the output buffer.
* Usually followed my mbedtls_md_hmac_reset(), mbedtls_md_hmac_starts(),
*
* or mbedtls_md_free().
* 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 ctx The message digest context containing an embedded HMAC
* \param output Generic HMAC checksum result
* context.
* \param output The generic HMAC checksum result.
*
*
* \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if
parameter
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* verification fails.
*
parameter
verification fails.
*/
*/
int
mbedtls_md_hmac_finish
(
mbedtls_md_context_t
*
ctx
,
unsigned
char
*
output
);
int
mbedtls_md_hmac_finish
(
mbedtls_md_context_t
*
ctx
,
unsigned
char
*
output
);
/**
/**
* \brief
P
repare to authenticate a new message with
the same key.
* \brief
This function p
repare
s
to authenticate a new message with
*
Called after mbedtls_md_hmac_finish() and before mbedtls_md_hmac_update()
.
*
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
* \param ctx The message digest context containing an embedded HMAC
* verification fails.
* 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
);
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 md_info The information structure of the message-digest algorithm
* \param key HMAC secret key
* to use.
* \param keylen length of the HMAC key in bytes
* \param key The HMAC secret key.
* \param input buffer holding the data
* \param keylen The length of the HMAC secret key in Bytes.
* \param ilen length of the input data
* \param input The buffer holding the input data.
* \param output Generic HMAC-result
* \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
* \returns
\c
0 on success,
or #
MBEDTLS_ERR_MD_BAD_INPUT_DATA if
* verification fails.
*
parameter
verification fails.
*/
*/
int
mbedtls_md_hmac
(
const
mbedtls_md_info_t
*
md_info
,
const
unsigned
char
*
key
,
size_t
keylen
,
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
,
const
unsigned
char
*
input
,
size_t
ilen
,
...
...
app/include/mbedtls/md2.h
View file @
67027c0d
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
*
*
* \brief MD2 message digest algorithm (hash function)
* \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
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -19,6 +24,7 @@
...
@@ -19,6 +24,7 @@
* limitations under the License.
* limitations under the License.
*
*
* This file is part of mbed TLS (https://tls.mbed.org)
* This file is part of mbed TLS (https://tls.mbed.org)
*
*/
*/
#ifndef MBEDTLS_MD2_H
#ifndef MBEDTLS_MD2_H
#define MBEDTLS_MD2_H
#define MBEDTLS_MD2_H
...
@@ -31,6 +37,13 @@
...
@@ -31,6 +37,13 @@
#include <stddef.h>
#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)
#if !defined(MBEDTLS_MD2_ALT)
// Regular implementation
// Regular implementation
//
//
...
@@ -41,6 +54,11 @@ extern "C" {
...
@@ -41,6 +54,11 @@ extern "C" {
/**
/**
* \brief MD2 context structure
* \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
typedef
struct
{
{
...
@@ -55,6 +73,11 @@ mbedtls_md2_context;
...
@@ -55,6 +73,11 @@ mbedtls_md2_context;
* \brief Initialize MD2 context
* \brief Initialize MD2 context
*
*
* \param ctx MD2 context to be initialized
* \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
);
void
mbedtls_md2_init
(
mbedtls_md2_context
*
ctx
);
...
@@ -62,6 +85,11 @@ void mbedtls_md2_init( mbedtls_md2_context *ctx );
...
@@ -62,6 +85,11 @@ void mbedtls_md2_init( mbedtls_md2_context *ctx );
* \brief Clear MD2 context
* \brief Clear MD2 context
*
*
* \param ctx MD2 context to be cleared
* \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
);
void
mbedtls_md2_free
(
mbedtls_md2_context
*
ctx
);
...
@@ -70,6 +98,11 @@ 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 dst The destination context
* \param src The context to be cloned
* \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
,
void
mbedtls_md2_clone
(
mbedtls_md2_context
*
dst
,
const
mbedtls_md2_context
*
src
);
const
mbedtls_md2_context
*
src
);
...
@@ -78,25 +111,150 @@ void mbedtls_md2_clone( mbedtls_md2_context *dst,
...
@@ -78,25 +111,150 @@ void mbedtls_md2_clone( mbedtls_md2_context *dst,
* \brief MD2 context setup
* \brief MD2 context setup
*
*
* \param ctx context to be initialized
* \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
* \brief MD2 process buffer
*
*
* \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0
*
* \param ctx MD2 context
* \param ctx MD2 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input 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
* \brief MD2 final digest
*
*
* \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0
*
* \param ctx MD2 context
* \param ctx MD2 context
* \param output MD2 checksum result
* \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
#ifdef __cplusplus
}
}
...
@@ -113,22 +271,61 @@ extern "C" {
...
@@ -113,22 +271,61 @@ extern "C" {
/**
/**
* \brief Output = MD2( input buffer )
* \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 ilen length of the input data
* \param output MD2 checksum result
* \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
* \brief Checkup routine
*
*
* \return 0 if successful, or 1 if the test failed
* \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
);
int
mbedtls_md2_self_test
(
int
verbose
);
/* Internal use */
void
mbedtls_md2_process
(
mbedtls_md2_context
*
ctx
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
app/include/mbedtls/md4.h
View file @
67027c0d
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
*
*
* \brief MD4 message digest algorithm (hash function)
* \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
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -19,6 +24,7 @@
...
@@ -19,6 +24,7 @@
* limitations under the License.
* limitations under the License.
*
*
* This file is part of mbed TLS (https://tls.mbed.org)
* This file is part of mbed TLS (https://tls.mbed.org)
*
*/
*/
#ifndef MBEDTLS_MD4_H
#ifndef MBEDTLS_MD4_H
#define MBEDTLS_MD4_H
#define MBEDTLS_MD4_H
...
@@ -32,6 +38,13 @@
...
@@ -32,6 +38,13 @@
#include <stddef.h>
#include <stddef.h>
#include <stdint.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)
#if !defined(MBEDTLS_MD4_ALT)
// Regular implementation
// Regular implementation
//
//
...
@@ -42,6 +55,11 @@ extern "C" {
...
@@ -42,6 +55,11 @@ extern "C" {
/**
/**
* \brief MD4 context structure
* \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
typedef
struct
{
{
...
@@ -55,6 +73,11 @@ mbedtls_md4_context;
...
@@ -55,6 +73,11 @@ mbedtls_md4_context;
* \brief Initialize MD4 context
* \brief Initialize MD4 context
*
*
* \param ctx MD4 context to be initialized
* \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
);
void
mbedtls_md4_init
(
mbedtls_md4_context
*
ctx
);
...
@@ -62,6 +85,11 @@ void mbedtls_md4_init( mbedtls_md4_context *ctx );
...
@@ -62,6 +85,11 @@ void mbedtls_md4_init( mbedtls_md4_context *ctx );
* \brief Clear MD4 context
* \brief Clear MD4 context
*
*
* \param ctx MD4 context to be cleared
* \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
);
void
mbedtls_md4_free
(
mbedtls_md4_context
*
ctx
);
...
@@ -70,6 +98,11 @@ 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 dst The destination context
* \param src The context to be cloned
* \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
,
void
mbedtls_md4_clone
(
mbedtls_md4_context
*
dst
,
const
mbedtls_md4_context
*
src
);
const
mbedtls_md4_context
*
src
);
...
@@ -78,25 +111,153 @@ void mbedtls_md4_clone( mbedtls_md4_context *dst,
...
@@ -78,25 +111,153 @@ void mbedtls_md4_clone( mbedtls_md4_context *dst,
* \brief MD4 context setup
* \brief MD4 context setup
*
*
* \param ctx context to be initialized
* \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
* \brief MD4 process buffer
*
*
* \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0
*
* \param ctx MD4 context
* \param ctx MD4 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input 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
* \brief MD4 final digest
*
*
* \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0
*
* \param ctx MD4 context
* \param ctx MD4 context
* \param output MD4 checksum result
* \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
#ifdef __cplusplus
}
}
...
@@ -113,22 +274,63 @@ extern "C" {
...
@@ -113,22 +274,63 @@ extern "C" {
/**
/**
* \brief Output = MD4( input buffer )
* \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 ilen length of the input data
* \param output MD4 checksum result
* \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
* \brief Checkup routine
*
*
* \return 0 if successful, or 1 if the test failed
* \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
);
int
mbedtls_md4_self_test
(
int
verbose
);
/* Internal use */
void
mbedtls_md4_process
(
mbedtls_md4_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
app/include/mbedtls/md5.h
View file @
67027c0d
...
@@ -3,6 +3,11 @@
...
@@ -3,6 +3,11 @@
*
*
* \brief MD5 message digest algorithm (hash function)
* \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
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -32,16 +37,28 @@
...
@@ -32,16 +37,28 @@
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdint.h>
#define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F
/**< MD5 hardware accelerator failed */
#if !defined(MBEDTLS_MD5_ALT)
#if !defined(MBEDTLS_MD5_ALT)
// Regular implementation
// Regular implementation
//
//
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
#endif
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
/**
/**
* \brief MD5 context structure
* \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
typedef
struct
{
{
...
@@ -55,6 +72,11 @@ mbedtls_md5_context;
...
@@ -55,6 +72,11 @@ mbedtls_md5_context;
* \brief Initialize MD5 context
* \brief Initialize MD5 context
*
*
* \param ctx MD5 context to be initialized
* \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
);
void
mbedtls_md5_init
(
mbedtls_md5_context
*
ctx
);
...
@@ -62,6 +84,11 @@ void mbedtls_md5_init( mbedtls_md5_context *ctx );
...
@@ -62,6 +84,11 @@ void mbedtls_md5_init( mbedtls_md5_context *ctx );
* \brief Clear MD5 context
* \brief Clear MD5 context
*
*
* \param ctx MD5 context to be cleared
* \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
);
void
mbedtls_md5_free
(
mbedtls_md5_context
*
ctx
);
...
@@ -70,6 +97,11 @@ 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 dst The destination context
* \param src The context to be cloned
* \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
,
void
mbedtls_md5_clone
(
mbedtls_md5_context
*
dst
,
const
mbedtls_md5_context
*
src
);
const
mbedtls_md5_context
*
src
);
...
@@ -78,28 +110,154 @@ void mbedtls_md5_clone( mbedtls_md5_context *dst,
...
@@ -78,28 +110,154 @@ void mbedtls_md5_clone( mbedtls_md5_context *dst,
* \brief MD5 context setup
* \brief MD5 context setup
*
*
* \param ctx context to be initialized
* \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
* \brief MD5 process buffer
*
*
* \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
*
* \param ctx MD5 context
* \param ctx MD5 context
* \param input buffer holding the
data
* \param input buffer holding the data
* \param ilen length of the input 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
* \brief MD5 final digest
*
*
* \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
*
* \param ctx MD5 context
* \param ctx MD5 context
* \param output MD5 checksum result
* \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 */
#undef MBEDTLS_DEPRECATED
void
mbedtls_md5_process
(
mbedtls_md5_context
*
ctx
,
const
unsigned
char
data
[
64
]
);
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
@@ -116,16 +274,60 @@ extern "C" {
...
@@ -116,16 +274,60 @@ extern "C" {
/**
/**
* \brief Output = MD5( input buffer )
* \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 ilen length of the input data
* \param output MD5 checksum result
* \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
* \brief Checkup routine
*
*
* \return 0 if successful, or 1 if the test failed
* \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
);
int
mbedtls_md5_self_test
(
int
verbose
);
...
...
app/include/mbedtls/md_internal.h
View file @
67027c0d
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
* \warning This in an internal header. Do not include directly.
* \warning This in an internal header. Do not include directly.
*
*
* \author Adriaan de Jong <dejong@fox-it.com>
* \author Adriaan de Jong <dejong@fox-it.com>
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -58,17 +59,17 @@ struct mbedtls_md_info_t
...
@@ -58,17 +59,17 @@ struct mbedtls_md_info_t
int
block_size
;
int
block_size
;
/** Digest initialisation function */
/** Digest initialisation function */
void
(
*
starts_func
)(
void
*
ctx
);
int
(
*
starts_func
)(
void
*
ctx
);
/** Digest update function */
/** 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 */
/** Digest finalisation function */
void
(
*
finish_func
)(
void
*
ctx
,
unsigned
char
*
output
);
int
(
*
finish_func
)(
void
*
ctx
,
unsigned
char
*
output
);
/** Generic digest function */
/** Generic digest function */
void
(
*
digest_func
)(
const
unsigned
char
*
input
,
size_t
ilen
,
int
(
*
digest_func
)(
const
unsigned
char
*
input
,
size_t
ilen
,
unsigned
char
*
output
);
unsigned
char
*
output
);
/** Allocate a new context */
/** Allocate a new context */
void
*
(
*
ctx_alloc_func
)(
void
);
void
*
(
*
ctx_alloc_func
)(
void
);
...
@@ -80,7 +81,7 @@ struct mbedtls_md_info_t
...
@@ -80,7 +81,7 @@ struct mbedtls_md_info_t
void
(
*
clone_func
)(
void
*
dst
,
const
void
*
src
);
void
(
*
clone_func
)(
void
*
dst
,
const
void
*
src
);
/** Internal use only */
/** 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)
#if defined(MBEDTLS_MD2_C)
...
...
app/include/mbedtls/memory_buffer_alloc.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file memory_buffer_alloc.h
* \file memory_buffer_alloc.h
*
*
* \brief Buffer-based memory allocator
* \brief Buffer-based memory allocator
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -98,8 +99,10 @@ void mbedtls_memory_buffer_alloc_status( void );
...
@@ -98,8 +99,10 @@ void mbedtls_memory_buffer_alloc_status( void );
/**
/**
* \brief Get the peak heap usage so far
* \brief Get the peak heap usage so far
*
*
* \param max_used Peak number of bytes reauested by the application
* \param max_used Peak number of bytes in use or committed. This
* \param max_blocks Peak number of blocks reauested by the application
* includes bytes in allocated blocks too small to split
* into smaller blocks but larger than the requested size.
* \param max_blocks Peak number of blocks in use, including free and used
*/
*/
void
mbedtls_memory_buffer_alloc_max_get
(
size_t
*
max_used
,
size_t
*
max_blocks
);
void
mbedtls_memory_buffer_alloc_max_get
(
size_t
*
max_used
,
size_t
*
max_blocks
);
...
@@ -111,8 +114,10 @@ void mbedtls_memory_buffer_alloc_max_reset( void );
...
@@ -111,8 +114,10 @@ void mbedtls_memory_buffer_alloc_max_reset( void );
/**
/**
* \brief Get the current heap usage
* \brief Get the current heap usage
*
*
* \param cur_used Number of bytes reauested by the application
* \param cur_used Current number of bytes in use or committed. This
* \param cur_blocks Number of blocks reauested by the application
* includes bytes in allocated blocks too small to split
* into smaller blocks but larger than the requested size.
* \param cur_blocks Current number of blocks in use, including free and used
*/
*/
void
mbedtls_memory_buffer_alloc_cur_get
(
size_t
*
cur_used
,
size_t
*
cur_blocks
);
void
mbedtls_memory_buffer_alloc_cur_get
(
size_t
*
cur_used
,
size_t
*
cur_blocks
);
#endif
/* MBEDTLS_MEMORY_DEBUG */
#endif
/* MBEDTLS_MEMORY_DEBUG */
...
...
app/include/mbedtls/net.h
View file @
67027c0d
/**
/**
* \file net.h
* \file net.h
*
*
* \brief
Network communication functions
* \brief
Deprecated header file that includes mbedtls/net_sockets.h
*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* \deprecated Superseded by mbedtls/net_sockets.h
*/
/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* Licensed under the Apache License, Version 2.0 (the "License"); you may
...
@@ -20,206 +23,10 @@
...
@@ -20,206 +23,10 @@
*
*
* This file is part of mbed TLS (https://tls.mbed.org)
* This file is part of mbed TLS (https://tls.mbed.org)
*/
*/
#ifndef MBEDTLS_NET_H
#define MBEDTLS_NET_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "ssl.h"
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
/**< Failed to open a socket. */
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
/**< The connection to the given server / port failed. */
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
/**< Binding of the socket failed. */
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
/**< Could not listen on the socket. */
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
/**< Could not accept the incoming connection. */
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
/**< Reading information from the socket failed. */
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
/**< Sending information through the socket failed. */
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050
/**< Connection was reset by peer. */
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
/**< Failed to get an IP address for the given hostname. */
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
/**< Buffer is too small to hold the data. */
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
/**< The context is invalid, eg because it was free()ed. */
#define MBEDTLS_NET_LISTEN_BACKLOG 10
/**< The backlog that listen() should use. */
#define MBEDTLS_NET_PROTO_TCP 0
/**< The TCP transport protocol */
#define MBEDTLS_NET_PROTO_UDP 1
/**< The UDP transport protocol */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* Wrapper type for sockets.
*
* Currently backed by just a file descriptor, but might be more in the future
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
* structures for hand-made UDP demultiplexing).
*/
typedef
struct
{
int
fd
;
/**< The underlying file descriptor */
}
mbedtls_net_context
;
/**
* \brief Initialize a context
* Just makes the context ready to be used or freed safely.
*
* \param ctx Context to initialize
*/
void
mbedtls_net_init
(
mbedtls_net_context
*
ctx
);
/**
* \brief Initiate a connection with host:port in the given protocol
*
* \param ctx Socket to use
* \param host Host to connect to
* \param port Port to connect to
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
*
* \return 0 if successful, or one of:
* MBEDTLS_ERR_NET_SOCKET_FAILED,
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
* MBEDTLS_ERR_NET_CONNECT_FAILED
*
* \note Sets the socket in connected mode even with UDP.
*/
int
mbedtls_net_connect
(
mbedtls_net_context
*
ctx
,
const
char
*
host
,
const
char
*
port
,
int
proto
);
/**
* \brief Create a receiving socket on bind_ip:port in the chosen
* protocol. If bind_ip == NULL, all interfaces are bound.
*
* \param ctx Socket to use
* \param bind_ip IP to bind to, can be NULL
* \param port Port number to use
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
*
* \return 0 if successful, or one of:
* MBEDTLS_ERR_NET_SOCKET_FAILED,
* MBEDTLS_ERR_NET_BIND_FAILED,
* MBEDTLS_ERR_NET_LISTEN_FAILED
*
* \note Regardless of the protocol, opens the sockets and binds it.
* In addition, make the socket listening if protocol is TCP.
*/
int
mbedtls_net_bind
(
mbedtls_net_context
*
ctx
,
const
char
*
bind_ip
,
const
char
*
port
,
int
proto
);
/**
* \brief Accept a connection from a remote client
*
* \param bind_ctx Relevant socket
* \param client_ctx Will contain the connected client socket
* \param client_ip Will contain the client IP address
* \param buf_size Size of the client_ip buffer
* \param ip_len Will receive the size of the client IP written
*
* \return 0 if successful, or
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
* non-blocking and accept() would block.
*/
int
mbedtls_net_accept
(
mbedtls_net_context
*
bind_ctx
,
mbedtls_net_context
*
client_ctx
,
void
*
client_ip
,
size_t
buf_size
,
size_t
*
ip_len
);
/**
* \brief Set the socket blocking
*
* \param ctx Socket to set
*
* \return 0 if successful, or a non-zero error code
*/
int
mbedtls_net_set_block
(
mbedtls_net_context
*
ctx
);
/**
* \brief Set the socket non-blocking
*
* \param ctx Socket to set
*
* \return 0 if successful, or a non-zero error code
*/
int
mbedtls_net_set_nonblock
(
mbedtls_net_context
*
ctx
);
/**
* \brief Portable usleep helper
*
* \param usec Amount of microseconds to sleep
*
* \note Real amount of time slept will not be less than
* select()'s timeout granularity (typically, 10ms).
*/
void
mbedtls_net_usleep
(
unsigned
long
usec
);
/**
* \brief Read at most 'len' characters. If no error occurs,
* the actual amount read is returned.
*
* \param ctx Socket
* \param buf The buffer to write to
* \param len Maximum length of the buffer
*
* \return the number of bytes received,
* or a non-zero error code; with a non-blocking socket,
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
*/
int
mbedtls_net_recv
(
void
*
ctx
,
unsigned
char
*
buf
,
size_t
len
);
/**
* \brief Write at most 'len' characters. If no error occurs,
* the actual amount read is returned.
*
* \param ctx Socket
* \param buf The buffer to read from
* \param len The length of the buffer
*
* \return the number of bytes sent,
* or a non-zero error code; with a non-blocking socket,
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
*/
int
mbedtls_net_send
(
void
*
ctx
,
const
unsigned
char
*
buf
,
size_t
len
);
/**
* \brief Read at most 'len' characters, blocking for at most
* 'timeout' seconds. If no error occurs, the actual amount
* read is returned.
*
* \param ctx Socket
* \param buf The buffer to write to
* \param len Maximum length of the buffer
* \param timeout Maximum number of milliseconds to wait for data
* 0 means no timeout (wait forever)
*
* \return the number of bytes received,
* or a non-zero error code:
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
*
* \note This function will block (until data becomes available or
* timeout is reached) even if the socket is set to
* non-blocking. Handling timeouts with non-blocking reads
* requires a different strategy.
*/
int
mbedtls_net_recv_timeout
(
void
*
ctx
,
unsigned
char
*
buf
,
size_t
len
,
uint32_t
timeout
);
/**
* \brief Gracefully shutdown the connection and free associated data
*
* \param ctx The context to free
*/
void
mbedtls_net_free
(
mbedtls_net_context
*
ctx
);
#ifdef __cplusplus
}
#endif
#endif
/* net.h */
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
#include "mbedtls/net_sockets.h"
#if defined(MBEDTLS_DEPRECATED_WARNING)
#warning "Deprecated header file: Superseded by mbedtls/net_sockets.h"
#endif
/* MBEDTLS_DEPRECATED_WARNING */
#endif
/* !MBEDTLS_DEPRECATED_REMOVED */
app/include/mbedtls/net_sockets.h
0 → 100644
View file @
67027c0d
/**
* \file net_sockets.h
*
* \brief Network communication functions
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_NET_SOCKETS_H
#define MBEDTLS_NET_SOCKETS_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include "ssl.h"
#include <stddef.h>
#include <stdint.h>
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042
/**< Failed to open a socket. */
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044
/**< The connection to the given server / port failed. */
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046
/**< Binding of the socket failed. */
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048
/**< Could not listen on the socket. */
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A
/**< Could not accept the incoming connection. */
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C
/**< Reading information from the socket failed. */
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E
/**< Sending information through the socket failed. */
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050
/**< Connection was reset by peer. */
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052
/**< Failed to get an IP address for the given hostname. */
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043
/**< Buffer is too small to hold the data. */
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045
/**< The context is invalid, eg because it was free()ed. */
#define MBEDTLS_NET_LISTEN_BACKLOG 10
/**< The backlog that listen() should use. */
#define MBEDTLS_NET_PROTO_TCP 0
/**< The TCP transport protocol */
#define MBEDTLS_NET_PROTO_UDP 1
/**< The UDP transport protocol */
#ifdef __cplusplus
extern
"C"
{
#endif
/**
* Wrapper type for sockets.
*
* Currently backed by just a file descriptor, but might be more in the future
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
* structures for hand-made UDP demultiplexing).
*/
typedef
struct
{
int
fd
;
/**< The underlying file descriptor */
}
mbedtls_net_context
;
/**
* \brief Initialize a context
* Just makes the context ready to be used or freed safely.
*
* \param ctx Context to initialize
*/
void
mbedtls_net_init
(
mbedtls_net_context
*
ctx
);
/**
* \brief Initiate a connection with host:port in the given protocol
*
* \param ctx Socket to use
* \param host Host to connect to
* \param port Port to connect to
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
*
* \return 0 if successful, or one of:
* MBEDTLS_ERR_NET_SOCKET_FAILED,
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
* MBEDTLS_ERR_NET_CONNECT_FAILED
*
* \note Sets the socket in connected mode even with UDP.
*/
int
mbedtls_net_connect
(
mbedtls_net_context
*
ctx
,
const
char
*
host
,
const
char
*
port
,
int
proto
);
/**
* \brief Create a receiving socket on bind_ip:port in the chosen
* protocol. If bind_ip == NULL, all interfaces are bound.
*
* \param ctx Socket to use
* \param bind_ip IP to bind to, can be NULL
* \param port Port number to use
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
*
* \return 0 if successful, or one of:
* MBEDTLS_ERR_NET_SOCKET_FAILED,
* MBEDTLS_ERR_NET_BIND_FAILED,
* MBEDTLS_ERR_NET_LISTEN_FAILED
*
* \note Regardless of the protocol, opens the sockets and binds it.
* In addition, make the socket listening if protocol is TCP.
*/
int
mbedtls_net_bind
(
mbedtls_net_context
*
ctx
,
const
char
*
bind_ip
,
const
char
*
port
,
int
proto
);
/**
* \brief Accept a connection from a remote client
*
* \param bind_ctx Relevant socket
* \param client_ctx Will contain the connected client socket
* \param client_ip Will contain the client IP address
* \param buf_size Size of the client_ip buffer
* \param ip_len Will receive the size of the client IP written
*
* \return 0 if successful, or
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
* non-blocking and accept() would block.
*/
int
mbedtls_net_accept
(
mbedtls_net_context
*
bind_ctx
,
mbedtls_net_context
*
client_ctx
,
void
*
client_ip
,
size_t
buf_size
,
size_t
*
ip_len
);
/**
* \brief Set the socket blocking
*
* \param ctx Socket to set
*
* \return 0 if successful, or a non-zero error code
*/
int
mbedtls_net_set_block
(
mbedtls_net_context
*
ctx
);
/**
* \brief Set the socket non-blocking
*
* \param ctx Socket to set
*
* \return 0 if successful, or a non-zero error code
*/
int
mbedtls_net_set_nonblock
(
mbedtls_net_context
*
ctx
);
/**
* \brief Portable usleep helper
*
* \param usec Amount of microseconds to sleep
*
* \note Real amount of time slept will not be less than
* select()'s timeout granularity (typically, 10ms).
*/
void
mbedtls_net_usleep
(
unsigned
long
usec
);
/**
* \brief Read at most 'len' characters. If no error occurs,
* the actual amount read is returned.
*
* \param ctx Socket
* \param buf The buffer to write to
* \param len Maximum length of the buffer
*
* \return the number of bytes received,
* or a non-zero error code; with a non-blocking socket,
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
*/
int
mbedtls_net_recv
(
void
*
ctx
,
unsigned
char
*
buf
,
size_t
len
);
/**
* \brief Write at most 'len' characters. If no error occurs,
* the actual amount read is returned.
*
* \param ctx Socket
* \param buf The buffer to read from
* \param len The length of the buffer
*
* \return the number of bytes sent,
* or a non-zero error code; with a non-blocking socket,
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
*/
int
mbedtls_net_send
(
void
*
ctx
,
const
unsigned
char
*
buf
,
size_t
len
);
/**
* \brief Read at most 'len' characters, blocking for at most
* 'timeout' seconds. If no error occurs, the actual amount
* read is returned.
*
* \param ctx Socket
* \param buf The buffer to write to
* \param len Maximum length of the buffer
* \param timeout Maximum number of milliseconds to wait for data
* 0 means no timeout (wait forever)
*
* \return the number of bytes received,
* or a non-zero error code:
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
*
* \note This function will block (until data becomes available or
* timeout is reached) even if the socket is set to
* non-blocking. Handling timeouts with non-blocking reads
* requires a different strategy.
*/
int
mbedtls_net_recv_timeout
(
void
*
ctx
,
unsigned
char
*
buf
,
size_t
len
,
uint32_t
timeout
);
/**
* \brief Gracefully shutdown the connection and free associated data
*
* \param ctx The context to free
*/
void
mbedtls_net_free
(
mbedtls_net_context
*
ctx
);
#ifdef __cplusplus
}
#endif
#endif
/* net_sockets.h */
app/include/mbedtls/oid.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file oid.h
* \file oid.h
*
*
* \brief Object Identifier (OID) database
* \brief Object Identifier (OID) database
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
...
app/include/mbedtls/padlock.h
View file @
67027c0d
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
*
*
* \brief VIA PadLock ACE for HW encryption/decryption supported by some
* \brief VIA PadLock ACE for HW encryption/decryption supported by some
* processors
* processors
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
...
app/include/mbedtls/pem.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file pem.h
* \file pem.h
*
*
* \brief Privacy Enhanced Mail (PEM) decoding
* \brief Privacy Enhanced Mail (PEM) decoding
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
...
app/include/mbedtls/pk.h
View file @
67027c0d
...
@@ -2,7 +2,8 @@
...
@@ -2,7 +2,8 @@
* \file pk.h
* \file pk.h
*
*
* \brief Public Key abstraction layer
* \brief Public Key abstraction layer
*
*/
/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
*
...
@@ -63,6 +64,7 @@
...
@@ -63,6 +64,7 @@
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00
/**< Elliptic curve is unsupported (only NIST curves are supported). */
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00
/**< Elliptic curve is unsupported (only NIST curves are supported). */
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980
/**< Unavailable feature, e.g. RSA disabled for RSA key. */
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980
/**< Unavailable feature, e.g. RSA disabled for RSA key. */
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900
/**< The signature is valid but its length is less than expected. */
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900
/**< The signature is valid but its length is less than expected. */
#define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880
/**< PK hardware accelerator failed. */
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -496,11 +498,12 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
...
@@ -496,11 +498,12 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx,
* \brief Load and parse a public key
* \brief Load and parse a public key
*
*
* \param ctx key to be initialized
* \param ctx key to be initialized
* \param path filename to read the p
rivate
key from
* \param path filename to read the p
ublic
key from
*
*
* \note On entry, ctx must be empty, either freshly initialised
* \note On entry, ctx must be empty, either freshly initialised
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a
* with mbedtls_pk_init() or reset with mbedtls_pk_free(). If
* specific key type, check the result with mbedtls_pk_can_do().
* you need a specific key type, check the result with
* mbedtls_pk_can_do().
*
*
* \note The key is also checked for correctness.
* \note The key is also checked for correctness.
*
*
...
...
Prev
1
2
3
4
5
6
7
…
15
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