Skip to content

Test merge of development and TLS PR 2028 #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
ec6329f
Add new function mbedtls_asn1_write_named_bitstring()
Sep 26, 2018
5d26163
Add tests for (named) bitstring to suite_asn1write
Sep 26, 2018
88bf1b3
Improve docs for named bitstrings and their usage
Oct 8, 2018
8761d92
Add ChangeLog entry for unused bits in bitstrings
Sep 26, 2018
21daa3c
Reduce the timing tests complexity
k-stachowiak Jan 29, 2019
f4ab6b2
Improve wording in the ChangeLog
k-stachowiak Jan 29, 2019
1bc1a4c
all.sh: Fix check_headers_in_cpp
pkolbus Feb 1, 2019
995d5c1
Add ChangeLog entry
pkolbus Feb 3, 2019
c5a4a13
Apply imperative style in the changelog entry
k-stachowiak Feb 5, 2019
a1dc911
Correct code formatting in the timing test suites
k-stachowiak Feb 5, 2019
bc81884
Query config through ssl_server2 and ssl_client2 cmdline
Oct 16, 2018
3169dc0
ssl-opt: Use ssl_server2 to query config instead of grep and sed
Oct 16, 2018
3b2f9d3
query_config.c: remove duplicated inc of platform.h
Oct 16, 2018
88121a9
Script generation of query_config.c file
Oct 16, 2018
4c981a0
Add gen_query_config.pl to check-gen-files and bump_version
Oct 16, 2018
aabe52f
Add ChangeLog entries
Oct 16, 2018
bb92364
Update programs/ssl/CMakeLists.txt with query_config.c dep
Oct 17, 2018
109f8b6
Fix typo in quenerate_query_config.pl comment
Oct 23, 2018
4581486
Ensure query_config.c includes stdio only when needed
Oct 26, 2018
509ba69
Create programs/test/query_compile_time_config app
Oct 26, 2018
08457ce
Fix aligment in programs/test/query_compile_time_config.c
Oct 26, 2018
2fdc2c2
Fix multiple stdio.h inclusion in query_config.c
Oct 29, 2018
5aca555
Fix GCC 0-length printf format string error
Oct 29, 2018
c28da7e
Improve comments in query_config.fmt
Oct 29, 2018
cb9c015
Improve cmake inclusion of query_config.c when building apps
Oct 30, 2018
c84a65d
Fix missing include in vs proj files for query programs
Oct 30, 2018
5bc6e92
Fix query_config macro expansion for windows
Oct 30, 2018
27b3372
Fix query_config macro expansion for windows
Dec 5, 2018
ef672f0
Exclude macros from query_config.c generation
Jan 3, 2019
8645f73
Update query_config.c with new macros
Jan 8, 2019
bc432b8
Use \r instead of 0xD in generate_visualc_files.pl
Jan 8, 2019
e7856bf
Suppress visual studio preprocessor warnings on query_config.c
Jan 15, 2019
17c53c5
Fix check-generated-files.sh failure with query_config
Jan 24, 2019
1a65dcd
Add a new X.509 API call for copy-less parsing of CRTs
Jan 31, 2019
462c3e5
Add test for mbedtls_x509_parse_file() with DER encoded CRT
Jan 31, 2019
2d8a2c0
Modify existing X.509 test for also test new copyless API
Jan 31, 2019
ac4172c
Adapt ChangeLog
Jan 31, 2019
b2964cb
SSL/TLS client: Remove old session ticket on renegotiation
Jan 30, 2019
def9bdc
Don't store the peer CRT chain twice during renegotiation
Jan 30, 2019
bd9d51d
Adapt ChangeLog
Jan 30, 2019
84879e3
Add compile-time guards around helper routine
Jan 31, 2019
e2734e2
Improve formatting of ssl_parse_certificate_chain()
Jan 31, 2019
c1e18bd
Fix memory leak
Jan 31, 2019
46f34d0
Fix style issue and wording
Feb 8, 2019
f389629
Move a restartable ecp context to a conditional compilation block
AndrzejKurek Feb 11, 2019
4343384
Fix typo in x509write test data
Feb 11, 2019
54efcb7
Update query config with VSNPRINTF macro
Feb 11, 2019
2d79266
psa_utils: Make fallthrough clear for compilers
Patater Feb 11, 2019
1b20be5
Write documentation for TEST_ASSERT
AndrzejKurek Feb 15, 2019
064128c
Update submodule pointer to commit 0574e6a of mbed-crypto/development
AndrzejKurek Feb 15, 2019
9c99dc8
Merge pull request #2395 from ARMmbed/development-psa-merged-dev-8e76332
mpg Feb 18, 2019
f75f912
Add functions to psa_util module to convert EC public keys
Jan 7, 2019
df51dbe
Add fields for PSA-based ECDHE to handshake structure
Feb 18, 2019
bb89e27
Implement ServerKeyExchange parsing for PSA-based ECDHE suites
Jan 8, 2019
4a63ed4
Implement ClientKeyExchange writing in PSA-based ECDHE suites
Jan 8, 2019
c14a3bb
Make variable in ssl_write_client_key_exchange() more descriptive
Jan 14, 2019
0a94a64
Add debugging output to confirm that PSA was used for ECDHE
Jan 11, 2019
354e248
Add ssl-opt.sh tests for PSA-based ECDH with various ECC curves
Jan 8, 2019
3b7c4a0
Regenerate VisualStudio project file
Jan 10, 2019
4af484e
Regenerate VS2010 project file
Jan 29, 2019
28f7844
Grep for debug output witnessing use of PSA in ECDHE ssl-opt.sh
Feb 18, 2019
135baef
Define maximum EC public key length depending on enabled curves
Feb 18, 2019
e254f85
Fix ChangeLog entry to correct release version
Feb 20, 2019
3497323
Initialize PSA Crypto operation contexts
Patater Feb 20, 2019
1ce51e4
Forbid setting MBEDTLS_ECP_RESTARTABLE and MBEDTLS_USE_PSA_CRYPTO_C
Feb 22, 2019
241b524
Disable restartable ECC in full config PSA test in all.sh
Feb 22, 2019
0ae63f7
Merge remote-tracking branch 'origin/pr/2383' into development
Patater Feb 21, 2019
d9516b5
Merge remote-tracking branch 'origin/pr/2407' into development
Patater Feb 21, 2019
8963b03
Merge remote-tracking branch 'origin/pr/2411' into development
Patater Feb 21, 2019
9f47f82
Merge remote-tracking branch 'origin/pr/2391' into development
Patater Feb 21, 2019
461bd3d
Merge remote-tracking branch 'origin/pr/2454' into development
Patater Feb 21, 2019
415620c
Merge remote-tracking branch 'origin/pr/2105' into development
Patater Feb 22, 2019
caca307
crypto: Update submodule to Mbed Crypto 1.0.0d6
Patater Feb 22, 2019
85fd913
Fix typo in check_config.h
Feb 22, 2019
d247762
Merge remote-tracking branch 'origin/pr/2460' into development
Patater Feb 22, 2019
e895342
Merge remote-tracking branch 'origin/pr/2427' into development
Patater Feb 22, 2019
86016a0
Merge remote-tracking branch 'origin/pr/2338' into development
Patater Feb 22, 2019
a9d6ba2
Merge remote-tracking branch 'tls/development' into development
Patater Feb 27, 2019
a78c958
Merge remote-tracking branch 'tls/pr/2028' into development
Patater Feb 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ mbed TLS ChangeLog (Sorted per branch, date)

= mbed TLS 2.x.x branch released xxxx-xx-xx

Features
* Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`
which allows copy-less parsing of DER encoded X.509 CRTs,
at the cost of additional lifetime constraints on the input
buffer, but at the benefit of reduced RAM consumption.

API Changes
* Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`.
See the Features section for more information.

Bugfix
* Fix a compilation issue with mbedtls_ecp_restart_ctx not being defined
when MBEDTLS_ECP_ALT is defined. Reported by jwhui. Fixes #2242.
Expand All @@ -19,8 +29,12 @@ Bugfix
in X.509 module. Fixes #2212.
* Reduce stack usage of `mpi_write_hlp()` by eliminating recursion.
Fixes #2190.
* Fix false failure in all.sh when backup files exist in include/mbedtls
(e.g. config.h.bak). Fixed by Peter Kolbus (Garmin) #2407.

Changes
* Reduce RAM consumption during session renegotiation by not storing
the peer CRT chain and session ticket twice.
* Include configuration file in all header files that use configuration,
instead of relying on other header files that they include.
Inserted as an enhancement for #1371
Expand All @@ -35,6 +49,20 @@ Changes
produced by some optimizing compilers, showing up as failures in
e.g. RSA or ECC signature operations. Reported in #1722, fix suggested
by Aurelien Jarno and submitted by Jeffrey Martin.
* Reduce the complexity of the timing tests. They were assuming more than the
underlying OS actually guarantees.
* Fix configuration queries in ssl-opt.h. #2030
* Ensure that ssl-opt.h can be run in OS X. #2029
* Ensure that unused bits are zero when writing ASN.1 bitstrings when using
mbedtls_asn1_write_bitstring().
* Fix issue when writing the named bitstrings in KeyUsage and NsCertType
extensions in CSRs and CRTs that caused these bitstrings to not be encoded
correctly as trailing zeroes were not accounted for as unused bits in the
leading content octet. Fixes #1610.

Features
* Add a new function mbedtls_asn1_write_named_bitstring() to write ASN.1
named bitstring in DER as required by RFC 5280 Appendix B.

= mbed TLS 2.16.0 branch released 2018-12-21

Expand Down
22 changes: 22 additions & 0 deletions include/mbedtls/asn1write.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,28 @@ int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start,
int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start,
const unsigned char *buf, size_t bits );

/**
* \brief This function writes a named bitstring tag
* (#MBEDTLS_ASN1_BIT_STRING) and value in ASN.1 format.
*
* As stated in RFC 5280 Appendix B, trailing zeroes are
* omitted when encoding named bitstrings in DER.
*
* \note This function works backwards within the data buffer.
*
* \param p The reference to the current position pointer.
* \param start The start of the buffer which is used for bounds-checking.
* \param buf The bitstring to write.
* \param bits The total number of bits in the bitstring.
*
* \return The number of bytes written to \p p on success.
* \return A negative error code on failure.
*/
int mbedtls_asn1_write_named_bitstring( unsigned char **p,
unsigned char *start,
const unsigned char *buf,
size_t bits );

/**
* \brief Write an octet string tag (#MBEDTLS_ASN1_OCTET_STRING)
* and value in ASN.1 format.
Expand Down
5 changes: 3 additions & 2 deletions include/mbedtls/check_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@
#endif

#if defined(MBEDTLS_ECP_RESTARTABLE) && \
( defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \
( defined(MBEDTLS_USE_PSA_CRYPTO) || \
defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \
defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \
defined(MBEDTLS_ECDSA_SIGN_ALT) || \
defined(MBEDTLS_ECDSA_VERIFY_ALT) || \
defined(MBEDTLS_ECDSA_GENKEY_ALT) || \
defined(MBEDTLS_ECP_INTERNAL_ALT) || \
defined(MBEDTLS_ECP_ALT) )
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation"
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative or PSA-based ECP implementation"
#endif

#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
Expand Down
125 changes: 125 additions & 0 deletions include/mbedtls/psa_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "pk.h"
#include "oid.h"

#include <string.h>

/* Translations for symmetric crypto. */

static inline psa_key_type_t mbedtls_psa_translate_cipher_type(
Expand Down Expand Up @@ -233,6 +235,86 @@ static inline int mbedtls_psa_get_ecc_oid_from_id(
return( -1 );
}

#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH 1

#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 521 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 521 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 192 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 224 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */

#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 256 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 384 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */

#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
#if MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH < ( 2 * ( ( 512 + 7 ) / 8 ) + 1 )
#undef MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH ( 2 * ( ( 512 + 7 ) / 8 ) + 1 )
#endif
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */


static inline psa_ecc_curve_t mbedtls_psa_translate_ecc_group( mbedtls_ecp_group_id grpid )
{
switch( grpid )
Expand Down Expand Up @@ -294,6 +376,7 @@ static inline psa_ecc_curve_t mbedtls_psa_translate_ecc_group( mbedtls_ecp_group
}
}


#define MBEDTLS_PSA_ECC_KEY_BITS_OF_CURVE( curve ) \
( curve == PSA_ECC_CURVE_SECP192R1 ? 192 : \
curve == PSA_ECC_CURVE_SECP224R1 ? 224 : \
Expand Down Expand Up @@ -352,6 +435,48 @@ static inline psa_ecc_curve_t mbedtls_psa_parse_tls_ecc_group(
return( (psa_ecc_curve_t) tls_ecc_grp_reg_id );
}

/* This function takes a buffer holding an EC public key
* exported through psa_export_public_key(), and converts
* it into an ECPoint structure to be put into a ClientKeyExchange
* message in an ECDHE exchange.
*
* Both the present and the foreseeable future format of EC public keys
* used by PSA have the ECPoint structure contained in the exported key
* as a subbuffer, and the function merely selects this subbuffer instead
* of making a copy.
*/
static inline int mbedtls_psa_tls_psa_ec_to_ecpoint( unsigned char *src,
size_t srclen,
unsigned char **dst,
size_t *dstlen )
{
*dst = src;
*dstlen = srclen;
return( 0 );
}

/* This function takes a buffer holding an ECPoint structure
* (as contained in a TLS ServerKeyExchange message for ECDHE
* exchanges) and converts it into a format that the PSA key
* agreement API understands.
*/
static inline int mbedtls_psa_tls_ecpoint_to_psa_ec( psa_ecc_curve_t curve,
unsigned char const *src,
size_t srclen,
unsigned char *dst,
size_t dstlen,
size_t *olen )
{
((void) curve);

if( srclen > dstlen )
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );

memcpy( dst, src, srclen );
*olen = srclen;
return( 0 );
}

#endif /* MBEDTLS_USE_PSA_CRYPTO */

#endif /* MBEDTLS_PSA_UTIL_H */
15 changes: 14 additions & 1 deletion include/mbedtls/ssl_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
#include "ecjpake.h"
#endif

#if defined(MBEDTLS_USE_PSA_CRYPTO)
#include "psa/crypto.h"
#include "psa_util.h"
#endif /* MBEDTLS_USE_PSA_CRYPTO */

#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
Expand Down Expand Up @@ -280,7 +285,15 @@ struct mbedtls_ssl_handshake_params
#endif
#if defined(MBEDTLS_ECDH_C)
mbedtls_ecdh_context ecdh_ctx; /*!< ECDH key exchange */
#endif

#if defined(MBEDTLS_USE_PSA_CRYPTO)
psa_ecc_curve_t ecdh_psa_curve;
psa_key_handle_t ecdh_psa_privkey;
unsigned char ecdh_psa_peerkey[MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH];
size_t ecdh_psa_peerkey_len;
#endif /* MBEDTLS_USE_PSA_CRYPTO */
#endif /* MBEDTLS_ECDH_C */

#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
mbedtls_ecjpake_context ecjpake_ctx; /*!< EC J-PAKE key exchange */
#if defined(MBEDTLS_SSL_CLI_C)
Expand Down
58 changes: 51 additions & 7 deletions include/mbedtls/x509_crt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ extern "C" {
*/
typedef struct mbedtls_x509_crt
{
int own_buffer; /**< Indicates if \c raw is owned
* by the structure or not. */
mbedtls_x509_buf raw; /**< The raw certificate data (DER). */
mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */

Expand Down Expand Up @@ -220,16 +222,58 @@ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb;

/**
* \brief Parse a single DER formatted certificate and add it
* to the chained list.
* to the end of the provided chained list.
*
* \param chain points to the start of the chain
* \param buf buffer holding the certificate DER data
* \param buflen size of the buffer
* \param chain The pointer to the start of the CRT chain to attach to.
* When parsing the first CRT in a chain, this should point
* to an instance of ::mbedtls_x509_crt initialized through
* mbedtls_x509_crt_init().
* \param buf The buffer holding the DER encoded certificate.
* \param buflen The size in Bytes of \p buf.
*
* \note This function makes an internal copy of the CRT buffer
* \p buf. In particular, \p buf may be destroyed or reused
* after this call returns. To avoid duplicating the CRT
* buffer (at the cost of stricter lifetime constraints),
* use mbedtls_x509_crt_parse_der_nocopy() instead.
*
* \return 0 if successful, or a specific X509 or PEM error code
* \return \c 0 if successful.
* \return A negative error code on failure.
*/
int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *buf,
size_t buflen );
int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain,
const unsigned char *buf,
size_t buflen );

/**
* \brief Parse a single DER formatted certificate and add it
* to the end of the provided chained list. This is a
* variant of mbedtls_x509_crt_parse_der() which takes
* temporary ownership of the CRT buffer until the CRT
* is destroyed.
*
* \param chain The pointer to the start of the CRT chain to attach to.
* When parsing the first CRT in a chain, this should point
* to an instance of ::mbedtls_x509_crt initialized through
* mbedtls_x509_crt_init().
* \param buf The address of the readable buffer holding the DER encoded
* certificate to use. On success, this buffer must be
* retained and not be changed for the liftetime of the
* CRT chain \p chain, that is, until \p chain is destroyed
* through a call to mbedtls_x509_crt_free().
* \param buflen The size in Bytes of \p buf.
*
* \note This call is functionally equivalent to
* mbedtls_x509_crt_parse_der(), but it avoids creating a
* copy of the input buffer at the cost of stronger lifetime
* constraints. This is useful in constrained environments
* where duplication of the CRT cannot be tolerated.
*
* \return \c 0 if successful.
* \return A negative error code on failure.
*/
int mbedtls_x509_crt_parse_der_nocopy( mbedtls_x509_crt *chain,
const unsigned char *buf,
size_t buflen );

/**
* \brief Parse one DER-encoded or one or more concatenated PEM-encoded
Expand Down
8 changes: 8 additions & 0 deletions include/mbedtls/x509_csr.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_ty
* \param key_usage key usage flags to set
*
* \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED
*
* \note The <code>decipherOnly</code> flag from the Key Usage
* extension is represented by bit 8 (i.e.
* <code>0x8000</code>), which cannot typically be represented
* in an unsigned char. Therefore, the flag
* <code>decipherOnly</code> (i.e.
* #MBEDTLS_X509_KU_DECIPHER_ONLY) cannot be set using this
* function.
*/
int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage );

Expand Down
Loading