Skip to content

Commit c70a3c7

Browse files
committed
Merge remote-tracking branch 'tls/development' into development
Resolve conflicts actions: - Reject path changes to config.h - Reject submodule-related changes in build scripts (Makefile, CMakeLists.txt) - Add oid test suite to list of tests in tests/CMakeLists.txt, rejecting any test filtering related changes (which TLS uses to avoid duplicating crypto tests) - Add legacy ECDH test to all.sh without including all.sh tests that depend on SSL
2 parents 82b3b83 + 57773d4 commit c70a3c7

28 files changed

+878
-120
lines changed

ChangeLog

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
mbed TLS ChangeLog (Sorted per branch, date)
22

3-
= mbed TLS 2.x.x branch released xxxx-xx-xx
3+
= mbed TLS x.x.x branch released xxxx-xx-xx
4+
5+
Features
6+
* Add the Any Policy certificate policy oid, as defined in
7+
rfc 5280 section 4.2.1.4.
8+
9+
Bugfix
10+
* Fix private key DER output in the key_app_writer example. File contents
11+
were shifted by one byte, creating an invalid ASN.1 tag. Fixed by
12+
Christian Walther in #2239.
13+
14+
Changes
15+
* Server's RSA certificate in certs.c was SHA-1 signed. In the default
16+
mbedTLS configuration only SHA-2 signed certificates are accepted.
17+
This certificate is used in the demo server programs, which lead the
18+
client programs to fail at the peer's certificate verification
19+
due to an unacceptable hash signature. The certificate has been
20+
updated to one that is SHA-256 signed. Fix contributed by
21+
Illya Gerasymchuk.
22+
* Return from various debugging routines immediately if the
23+
provided SSL context is unset.
24+
* Remove dead code from bignum.c in the default configuration.
25+
Found by Coverity, reported and fixed by Peter Kolbus (Garmin). Fixes #2309.
26+
* Add test for minimal value of MBEDTLS_MPI_WINDOW_SIZE to all.sh.
27+
Contributed by Peter Kolbus (Garmin).
28+
29+
= mbed TLS 2.17.0 branch released 2019-03-19
430

531
Features
632
* Add a new X.509 API call `mbedtls_x509_parse_der_nocopy()`
@@ -24,6 +50,14 @@ API Changes
2450
mbedtls_ssl_session structure which otherwise stores the peer's
2551
certificate.
2652

53+
Security
54+
* Make mbedtls_ecdh_get_params return an error if the second key
55+
belongs to a different group from the first. Before, if an application
56+
passed keys that belonged to different group, the first key's data was
57+
interpreted according to the second group, which could lead to either
58+
an error or a meaningless output from mbedtls_ecdh_get_params. In the
59+
latter case, this could expose at most 5 bits of the private key.
60+
2761
Bugfix
2862
* Fix a compilation issue with mbedtls_ecp_restart_ctx not being defined
2963
when MBEDTLS_ECP_ALT is defined. Reported by jwhui. Fixes #2242.
@@ -49,9 +83,6 @@ Bugfix
4983
extensions in CSRs and CRTs that caused these bitstrings to not be encoded
5084
correctly as trailing zeroes were not accounted for as unused bits in the
5185
leading content octet. Fixes #1610.
52-
* Fix private key DER output in the key_app_writer example. File contents
53-
were shifted by one byte, creating an invalid ASN.1 tag. Fixed by
54-
Christian Walther in #2239.
5586

5687
Changes
5788
* Reduce RAM consumption during session renegotiation by not storing
@@ -78,19 +109,6 @@ Changes
78109
been disabled for lack of a sufficiently recent version of GnuTLS on the CI.
79110
* Ciphersuites based on 3DES now have the lowest priority by default when
80111
they are enabled.
81-
* Server's RSA certificate in certs.c was SHA-1 signed. In the default
82-
mbedTLS configuration only SHA-2 signed certificates are accepted.
83-
This certificate is used in the demo server programs, which lead the
84-
client programs to fail at the peer's certificate verification
85-
due to an unacceptable hash signature. The certificate has been
86-
updated to one that is SHA-256 signed. Fix contributed by
87-
Illya Gerasymchuk.
88-
* Return from various debugging routines immediately if the
89-
provided SSL context is unset.
90-
* Remove dead code from bignum.c in the default configuration.
91-
Found by Coverity, reported and fixed by Peter Kolbus (Garmin). Fixes #2309.
92-
* Add test for minimal value of MBEDTLS_MPI_WINDOW_SIZE to all.sh.
93-
Contributed by Peter Kolbus (Garmin).
94112

95113
= mbed TLS 2.16.0 branch released 2018-12-21
96114

doxygen/input/doc_mainpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525

2626
/**
27-
* @mainpage mbed TLS v0.0.0 source code documentation
27+
* @mainpage mbed TLS v2.17.0 source code documentation
2828
*
2929
* This documentation describes the internal structure of mbed TLS. It was
3030
* automatically generated from specially formatted comment blocks in

doxygen/mbedtls.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8
2828
# identify the project. Note that if you do not use Doxywizard you need
2929
# to put quotes around the project name if it contains spaces.
3030

31-
PROJECT_NAME = "mbed TLS v0.0.0"
31+
PROJECT_NAME = "mbed TLS v2.17.0"
3232

3333
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
3434
# This could be handy for archiving the generated documentation or

include/mbedtls/bignum.h

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,24 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf,
490490
size_t buflen );
491491

492492
/**
493-
* \brief Export an MPI into unsigned big endian binary data
494-
* of fixed size.
493+
* \brief Import X from unsigned binary data, little endian
494+
*
495+
* \param X The destination MPI. This must point to an initialized MPI.
496+
* \param buf The input buffer. This must be a readable buffer of length
497+
* \p buflen Bytes.
498+
* \param buflen The length of the input buffer \p p in Bytes.
499+
*
500+
* \return \c 0 if successful.
501+
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed.
502+
* \return Another negative error code on different kinds of failure.
503+
*/
504+
int mbedtls_mpi_read_binary_le( mbedtls_mpi *X,
505+
const unsigned char *buf, size_t buflen );
506+
507+
/**
508+
* \brief Export X into unsigned binary data, big endian.
509+
* Always fills the whole buffer, which will start with zeros
510+
* if the number is smaller.
495511
*
496512
* \param X The source MPI. This must point to an initialized MPI.
497513
* \param buf The output buffer. This must be a writable buffer of length
@@ -506,6 +522,24 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf,
506522
int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf,
507523
size_t buflen );
508524

525+
/**
526+
* \brief Export X into unsigned binary data, little endian.
527+
* Always fills the whole buffer, which will end with zeros
528+
* if the number is smaller.
529+
*
530+
* \param X The source MPI. This must point to an initialized MPI.
531+
* \param buf The output buffer. This must be a writable buffer of length
532+
* \p buflen Bytes.
533+
* \param buflen The size of the output buffer \p buf in Bytes.
534+
*
535+
* \return \c 0 if successful.
536+
* \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't
537+
* large enough to hold the value of \p X.
538+
* \return Another negative error code on different kinds of failure.
539+
*/
540+
int mbedtls_mpi_write_binary_le( const mbedtls_mpi *X,
541+
unsigned char *buf, size_t buflen );
542+
509543
/**
510544
* \brief Perform a left-shift on an MPI: X <<= count
511545
*

include/mbedtls/check_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative or PSA-based ECP implementation"
126126
#endif
127127

128+
#if defined(MBEDTLS_ECP_RESTARTABLE) && \
129+
! defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
130+
#error "MBEDTLS_ECP_RESTARTABLE defined, but not MBEDTLS_ECDH_LEGACY_CONTEXT"
131+
#endif
132+
128133
#if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C)
129134
#error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites"
130135
#endif

include/mbedtls/config.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,10 +760,39 @@
760760
*
761761
* \note This option only works with the default software implementation of
762762
* elliptic curve functionality. It is incompatible with
763-
* MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT.
763+
* MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT
764+
* and MBEDTLS_ECDH_LEGACY_CONTEXT.
764765
*/
765766
//#define MBEDTLS_ECP_RESTARTABLE
766767

768+
/**
769+
* \def MBEDTLS_ECDH_LEGACY_CONTEXT
770+
*
771+
* Use a backward compatible ECDH context.
772+
*
773+
* Mbed TLS supports two formats for ECDH contexts (#mbedtls_ecdh_context
774+
* defined in `ecdh.h`). For most applications, the choice of format makes
775+
* no difference, since all library functions can work with either format,
776+
* except that the new format is incompatible with MBEDTLS_ECP_RESTARTABLE.
777+
778+
* The new format used when this option is disabled is smaller
779+
* (56 bytes on a 32-bit platform). In future versions of the library, it
780+
* will support alternative implementations of ECDH operations.
781+
* The new format is incompatible with applications that access
782+
* context fields directly and with restartable ECP operations.
783+
*
784+
* Define this macro if you enable MBEDTLS_ECP_RESTARTABLE or if you
785+
* want to access ECDH context fields directly. Otherwise you should
786+
* comment out this macro definition.
787+
*
788+
* This option has no effect if #MBEDTLS_ECDH_C is not enabled.
789+
*
790+
* \note This configuration option is experimental. Future versions of the
791+
* library may modify the way the ECDH context layout is configured
792+
* and may modify the layout of the new context type.
793+
*/
794+
#define MBEDTLS_ECDH_LEGACY_CONTEXT
795+
767796
/**
768797
* \def MBEDTLS_ECDSA_DETERMINISTIC
769798
*

include/mbedtls/ecdh.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@
4242

4343
#include "ecp.h"
4444

45-
/*
46-
* Use a backward compatible ECDH context.
47-
*
48-
* This flag is always enabled for now and future versions might add a
49-
* configuration option that conditionally undefines this flag.
50-
* The configuration option in question may have a different name.
51-
*
52-
* Features undefining this flag, must have a warning in their description in
53-
* config.h stating that the feature breaks backward compatibility.
54-
*/
55-
#define MBEDTLS_ECDH_LEGACY_CONTEXT
56-
5745
#ifdef __cplusplus
5846
extern "C" {
5947
#endif

include/mbedtls/ecp.h

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ typedef enum
9999
*/
100100
#define MBEDTLS_ECP_DP_MAX 12
101101

102+
/*
103+
* Curve types
104+
*/
105+
typedef enum
106+
{
107+
MBEDTLS_ECP_TYPE_NONE = 0,
108+
MBEDTLS_ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */
109+
MBEDTLS_ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */
110+
} mbedtls_ecp_curve_type;
111+
102112
/**
103113
* Curve information, for use by other modules.
104114
*/
@@ -417,6 +427,11 @@ void mbedtls_ecp_set_max_ops( unsigned max_ops );
417427
int mbedtls_ecp_restart_is_enabled( void );
418428
#endif /* MBEDTLS_ECP_RESTARTABLE */
419429

430+
/*
431+
* Get the type of a curve
432+
*/
433+
mbedtls_ecp_curve_type mbedtls_ecp_get_type( const mbedtls_ecp_group *grp );
434+
420435
/**
421436
* \brief This function retrieves the information defined in
422437
* mbedtls_ecp_curve_info() for all supported curves in order
@@ -482,7 +497,7 @@ void mbedtls_ecp_point_init( mbedtls_ecp_point *pt );
482497
*
483498
* \note After this function is called, domain parameters
484499
* for various ECP groups can be loaded through the
485-
* mbedtls_ecp_load() or mbedtls_ecp_tls_read_group()
500+
* mbedtls_ecp_group_load() or mbedtls_ecp_tls_read_group()
486501
* functions.
487502
*/
488503
void mbedtls_ecp_group_init( mbedtls_ecp_group *grp );
@@ -626,6 +641,9 @@ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix,
626641
* \param P The point to export. This must be initialized.
627642
* \param format The point format. This must be either
628643
* #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED.
644+
* (For groups without these formats, this parameter is
645+
* ignored. But it still has to be either of the above
646+
* values.)
629647
* \param olen The address at which to store the length of
630648
* the output in Bytes. This must not be \c NULL.
631649
* \param buf The output buffer. This must be a writable buffer
@@ -635,11 +653,14 @@ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix,
635653
* \return \c 0 on success.
636654
* \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output buffer
637655
* is too small to hold the point.
656+
* \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format
657+
* or the export for the given group is not implemented.
638658
* \return Another negative error code on other kinds of failure.
639659
*/
640-
int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P,
641-
int format, size_t *olen,
642-
unsigned char *buf, size_t buflen );
660+
int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp,
661+
const mbedtls_ecp_point *P,
662+
int format, size_t *olen,
663+
unsigned char *buf, size_t buflen );
643664

644665
/**
645666
* \brief This function imports a point from unsigned binary data.
@@ -660,8 +681,8 @@ int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_
660681
* \return \c 0 on success.
661682
* \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid.
662683
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure.
663-
* \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format
664-
* is not implemented.
684+
* \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the import for the
685+
* given group is not implemented.
665686
*/
666687
int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp,
667688
mbedtls_ecp_point *P,
@@ -1093,6 +1114,26 @@ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
10931114
int (*f_rng)(void *, unsigned char *, size_t),
10941115
void *p_rng );
10951116

1117+
/**
1118+
* \brief This function reads an elliptic curve private key.
1119+
*
1120+
* \param grp_id The ECP group identifier.
1121+
* \param key The destination key.
1122+
* \param buf The the buffer containing the binary representation of the
1123+
* key. (Big endian integer for Weierstrass curves, byte
1124+
* string for Montgomery curves.)
1125+
* \param buflen The length of the buffer in bytes.
1126+
*
1127+
* \return \c 0 on success.
1128+
* \return #MBEDTLS_ERR_ECP_INVALID_KEY error if the key is
1129+
* invalid.
1130+
* \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed.
1131+
* \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the operation for
1132+
* the group is not implemented.
1133+
* \return Another negative error code on different kinds of failure.
1134+
*/
1135+
int mbedtls_ecp_read_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
1136+
const unsigned char *buf, size_t buflen );
10961137
/**
10971138
* \brief This function checks that the keypair objects
10981139
* \p pub and \p prv have the same group and the

include/mbedtls/oid.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@
167167
#define MBEDTLS_OID_INIHIBIT_ANYPOLICY MBEDTLS_OID_ID_CE "\x36" /**< id-ce-inhibitAnyPolicy OBJECT IDENTIFIER ::= { id-ce 54 } */
168168
#define MBEDTLS_OID_FRESHEST_CRL MBEDTLS_OID_ID_CE "\x2E" /**< id-ce-freshestCRL OBJECT IDENTIFIER ::= { id-ce 46 } */
169169

170+
/*
171+
* Certificate policies
172+
*/
173+
#define MBEDTLS_OID_ANY_POLICY MBEDTLS_OID_CERTIFICATE_POLICIES "\x00" /**< anyPolicy OBJECT IDENTIFIER ::= { id-ce-certificatePolicies 0 } */
174+
170175
/*
171176
* Netscape certificate extensions
172177
*/
@@ -576,6 +581,16 @@ int mbedtls_oid_get_md_hmac( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_
576581
*/
577582
int mbedtls_oid_get_extended_key_usage( const mbedtls_asn1_buf *oid, const char **desc );
578583

584+
/**
585+
* \brief Translate certificate policies OID into description
586+
*
587+
* \param oid OID to use
588+
* \param desc place to store string pointer
589+
*
590+
* \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
591+
*/
592+
int mbedtls_oid_get_certificate_policies( const mbedtls_asn1_buf *oid, const char **desc );
593+
579594
/**
580595
* \brief Translate md_type into hash algorithm OID
581596
*

include/mbedtls/version.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838
* The version number x.y.z is split into three parts.
3939
* Major, Minor, Patchlevel
4040
*/
41-
#define MBEDTLS_VERSION_MAJOR 0
42-
#define MBEDTLS_VERSION_MINOR 0
41+
#define MBEDTLS_VERSION_MAJOR 2
42+
#define MBEDTLS_VERSION_MINOR 17
4343
#define MBEDTLS_VERSION_PATCH 0
4444

4545
/**
4646
* The single version number has the following structure:
4747
* MMNNPP00
4848
* Major version | Minor version | Patch version
4949
*/
50-
#define MBEDTLS_VERSION_NUMBER 0x00000000
51-
#define MBEDTLS_VERSION_STRING "0.0.0"
52-
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 0.0.0"
50+
#define MBEDTLS_VERSION_NUMBER 0x02110000
51+
#define MBEDTLS_VERSION_STRING "2.17.0"
52+
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.17.0"
5353

5454
#if defined(MBEDTLS_VERSION_C)
5555

library/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
178178

179179
if(USE_SHARED_MBEDTLS_LIBRARY)
180180
add_library(mbedcrypto SHARED ${src_crypto})
181-
set_target_properties(mbedcrypto PROPERTIES VERSION 2.16.0 SOVERSION 3)
181+
set_target_properties(mbedcrypto PROPERTIES VERSION 2.17.0 SOVERSION 3)
182182
target_link_libraries(mbedcrypto ${libs})
183183
target_include_directories(mbedcrypto
184184
PUBLIC ${CMAKE_SOURCE_DIR}/include/

0 commit comments

Comments
 (0)