Commit graph

4 commits

Author SHA1 Message Date
nia
6cd044a35e mbedtls: update to 2.26.0
This release of Mbed TLS provides bug fixes, minor enhancements and new features. This release includes fixes for security issues.
API changes

    Renamed the PSA Crypto API output buffer size macros to bring them in line
    with version 1.0.0 of the specification.
    The API glue function mbedtls_ecc_group_of_psa() now takes the curve size
    in bits rather than bytes, with an additional flag to indicate if the
    size may have been rounded up to a whole number of bytes.
    Renamed the PSA Crypto API AEAD tag length macros to bring them in line
    with version 1.0.0 of the specification.

Default behavior changes

    In mbedtls_rsa_context objects, the ver field was formerly documented
    as always 0. It is now reserved for internal purposes and may take
    different values.

New deprecations

    PSA_KEY_EXPORT_MAX_SIZE, PSA_HASH_SIZE, PSA_MAC_FINAL_SIZE,
    PSA_BLOCK_CIPHER_BLOCK_SIZE, PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE and
    PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN have been renamed, and the old names
    deprecated.
    PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH and PSA_ALG_AEAD_WITH_TAG_LENGTH
    have been renamed, and the old names deprecated.

Features

    The PSA crypto subsystem can now use HMAC_DRBG instead of CTR_DRBG.
    CTR_DRBG is used by default if it is available, but you can override
    this choice by setting MBEDTLS_PSA_HMAC_DRBG_MD_TYPE at compile time.
    Fix #3354.
    Automatic fallback to a software implementation of ECP when
    MBEDTLS_ECP_xxx_ALT accelerator hooks are in use can now be turned off
    through setting the new configuration flag MBEDTLS_ECP_NO_FALLBACK.
    The PSA crypto subsystem can now be configured to use less static RAM by
    tweaking the setting for the maximum amount of keys simultaneously in RAM.
    MBEDTLS_PSA_KEY_SLOT_COUNT sets the maximum number of volatile keys that
    can exist simultaneously. It has a sensible default if not overridden.
    Partial implementation of the PSA crypto driver interface: Mbed TLS can
    now use an external random generator instead of the library's own
    entropy collection and DRBG code. Enable MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
    and see the documentation of mbedtls_psa_external_get_random() for details.
    Applications using both mbedtls_xxx and psa_xxx functions (for example,
    applications using TLS and MBEDTLS_USE_PSA_CRYPTO) can now use the PSA
    random generator with mbedtls_xxx functions. See the documentation of
    mbedtls_psa_get_random() for details.
    In the PSA API, the policy for a MAC or AEAD algorithm can specify a
    minimum MAC or tag length thanks to the new wildcards
    PSA_ALG_AT_LEAST_THIS_LENGTH_MAC and
    PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG.

Security

    Fix a security reduction in CTR_DRBG when the initial seeding obtained a
    nonce from entropy. Applications were affected if they called
    mbedtls_ctr_drbg_set_nonce_len(), if they called
    mbedtls_ctr_drbg_set_entropy_len() with a size that was 3/2 times the key
    length, or when the entropy module uses SHA-256 and CTR_DRBG uses AES-256.
    In such cases, a random nonce was necessary to achieve the advertised
    security strength, but the code incorrectly used a constant instead of
    entropy from the nonce.
    Found by John Stroebel in #3819 and fixed in #3973.
    Fix a buffer overflow in mbedtls_mpi_sub_abs() when calculating
    |A| - |B| where |B| is larger than |A| and has more limbs (so the
    function should return MBEDTLS_ERR_MPI_NEGATIVE_VALUE). Only
    applications calling mbedtls_mpi_sub_abs() directly are affected:
    all calls inside the library were safe since this function is
    only called with |A| >= |B|. Reported by Guido Vranken in #4042.
    Fix an errorneous estimation for an internal buffer in
    mbedtls_pk_write_key_pem(). If MBEDTLS_MPI_MAX_SIZE is set to an odd
    value the function might fail to write a private RSA keys of the largest
    supported size.
    Found by Daniel Otte, reported in #4093 and fixed in #4094.
    Fix a stack buffer overflow with mbedtls_net_poll() and
    mbedtls_net_recv_timeout() when given a file descriptor that is
    beyond FD_SETSIZE. Reported by FigBug in #4169.
    Guard against strong local side channel attack against base64 tables by
    making access aceess to them use constant flow code.

Bugfix

    Fix use-after-scope error in programs/ssl/ssl_client2.c and ssl_server2.c
    Fix memory leak that occured when calling psa_close_key() on a
    wrapped key with MBEDTLS_PSA_CRYPTO_SE_C defined.
    Fix an incorrect error code if an RSA private operation glitched.
    Fix a memory leak in an error case in psa_generate_derived_key_internal().
    Fix a resource leak in CTR_DRBG and HMAC_DRBG when MBEDTLS_THREADING_C
    is enabled, on platforms where initializing a mutex allocates resources.
    This was a regression introduced in the previous release. Reported in
    #4017, #4045 and #4071.
    Ensure that calling mbedtls_rsa_free() or mbedtls_entropy_free()
    twice is safe. This happens for RSA when some Mbed TLS library functions
    fail. Such a double-free was not safe when MBEDTLS_THREADING_C was
    enabled on platforms where freeing a mutex twice is not safe.
    Fix a resource leak in a bad-arguments case of mbedtls_rsa_gen_key()
    when MBEDTLS_THREADING_C is enabled on platforms where initializing
    a mutex allocates resources.
    Fixes a bug where, if the library was configured to include support for
    both the old SE interface and the new PSA driver interface, external keys were
    not loaded from storage. This was fixed by #3996.
    This change makes 'mbedtls_x509write_crt_set_basic_constraints'
    consistent with RFC 5280 4.2.1.9 which says: "Conforming CAs MUST
    include this extension in all CA certificates that contain public keys
    used to validate digital signatures on certificates and MUST mark the
    extension as critical in such certificates." Previous to this change,
    the extension was always marked as non-critical. This was fixed by
    #3698.

Changes

    A new library C file psa_crypto_client.c has been created to contain
    the PSA code needed by a PSA crypto client when the PSA crypto
    implementation is not included into the library.
    On recent enough versions of FreeBSD and DragonFlyBSD, the entropy module
    now uses the getrandom syscall instead of reading from /dev/urandom.

Who should update

We recommend all users should update to take advantage of the bug fixes contained in this release at an appropriate point in their development lifecycle.
2021-05-02 08:16:13 +00:00
nia
02172b4b0e mbedtls: Set BUILDLINK_ABI_DEPENDS 2020-07-07 11:21:39 +00:00
nia
a87608e63d mbedtls: Add KERN_ARND support.
Motivation: the default behaviour of reopening /dev/urandom repeatedly
for every 128 bytes of entropy required is _exceedingly_ slow on NetBSD.
Not helped is using fread(), which assumes a long-lived file and buffers
excessively. This change makes the standard gen_entropy tool run in
milliseconds instead of seconds when it generates 48K of randomness.

Not only that, but sysctl is a lot more robust in e.g. chroots, resource
limited processes, etc.

Risk: On NetBSD, the security properties of the previous and current
behaviour are identical.

Upstreamed: https://github.com/ARMmbed/mbedtls/pull/3423

Bump PKGREVISION.
2020-06-29 12:39:36 +00:00
fhajny
226bc45014 Import mbed TLS 1.3.11 as security/mbedtls.
This is former security/polarssl rebranded under a new name, keeping the same
API though and providing the previous libs as symlinks, so should be used as
as drop-in replacement for security/polarssl.

Changelog since polarssl-1.3.9 follows.

= mbed TLS 1.3.11 released 2015-06-04

Security
   * With authmode set to SSL_VERIFY_OPTIONAL, verification of keyUsage and
     extendedKeyUsage on the leaf certificate was lost (results not accessible
     via ssl_get_verify_results()).
   * Add countermeasure against "Lucky 13 strikes back" cache-based attack,
     https://dl.acm.org/citation.cfm?id=2714625

Features
   * Improve ECC performance by using more efficient doubling formulas
     (contributed by Peter Dettman).
   * Add x509_crt_verify_info() to display certificate verification results.
   * Add support for reading DH parameters with privateValueLength included
     (contributed by Daniel Kahn Gillmor).
   * Add support for bit strings in X.509 names (request by Fredrik Axelsson).
   * Add support for id-at-uniqueIdentifier in X.509 names.
   * Add support for overriding snprintf() (except on Windows) and exit() in
     the platform layer.
   * Add an option to use macros instead of function pointers in the platform
     layer (helps get rid of unwanted references).
   * Improved Makefiles for Windows targets by fixing library targets and making
     cross-compilation easier (thanks to Alon Bar-Lev).
   * The benchmark program also prints heap usage for public-key primitives
     if POLARSSL_MEMORY_BUFFER_ALLOC_C and POLARSSL_MEMORY_DEBUG are defined.
   * New script ecc-heap.sh helps measuring the impact of ECC parameters on
     speed and RAM (heap only for now) usage.
   * New script memory.sh helps measuring the ROM and RAM requirements of two
     reduced configurations (PSK-CCM and NSA suite B).
   * Add config flag POLARSSL_DEPRECATED_WARNING (off by default) to produce
     warnings on use of deprecated functions (with GCC and Clang only).
   * Add config flag POLARSSL_DEPRECATED_REMOVED (off by default) to produce
     errors on use of deprecated functions.

Bugfix
   * Fix compile errors with PLATFORM_NO_STD_FUNCTIONS.
   * Fix compile error with PLATFORM_EXIT_ALT (thanks to Rafał Przywara).
   * Fix bug in entropy.c when THREADING_C is also enabled that caused
     entropy_free() to crash (thanks to Rafał Przywara).
   * Fix memory leak when gcm_setkey() and ccm_setkey() are used more than
     once on the same context.
   * Fix bug in ssl_mail_client when password is longer that username (found
     by Bruno Pape).
   * Fix undefined behaviour (memcmp( NULL, NULL, 0 );) in X.509 modules
     (detected by Clang's 3.6 UBSan).
   * mpi_size() and mpi_msb() would segfault when called on an mpi that is
     initialized but not set (found by pravic).
   * Fix detection of support for getrandom() on Linux (reported by syzzer) by
     doing it at runtime (using uname) rather that compile time.
   * Fix handling of symlinks by "make install" (found by Gaël PORTAY).
   * Fix potential NULL pointer dereference (not trigerrable remotely) when
     ssl_write() is called before the handshake is finished (introduced in
     1.3.10) (first reported by Martin Blumenstingl).
   * Fix bug in pk_parse_key() that caused some valid private EC keys to be
     rejected.
   * Fix bug in Via Padlock support (found by Nikos Mavrogiannopoulos).
   * Fix thread safety bug in RSA operations (found by Fredrik Axelsson).
   * Fix hardclock() (only used in the benchmarking program) with some
     versions of mingw64 (found by kxjhlele).
   * Fix warnings from mingw64 in timing.c (found by kxjklele).
   * Fix potential unintended sign extension in asn1_get_len() on 64-bit
     platforms.
   * Fix potential memory leak in ssl_set_psk() (found by Mansour Moufid).
   * Fix compile error when POLARSSL_SSL_DISABLE_RENEGOTATION and
     POLARSSL_SSL_SSESSION_TICKETS where both enabled in config.h (introduced
     in 1.3.10).
   * Add missing extern "C" guard in aesni.h (reported by amir zamani).
   * Add missing dependency on SHA-256 in some x509 programs (reported by
     Gergely Budai).
   * Fix bug related to ssl_set_curves(): the client didn't check that the
     curve picked by the server was actually allowed.

Changes
   * Remove bias in mpi_gen_prime (contributed by Pascal Junod).
   * Remove potential sources of timing variations (some contributed by Pascal
     Junod).
   * Options POLARSSL_HAVE_INT8 and POLARSSL_HAVE_INT16 are deprecated.
   * Enabling POLARSSL_NET_C without POLARSSL_HAVE_IPV6 is deprecated.
   * compat-1.2.h and openssl.h are deprecated.
   * Adjusting/overriding CFLAGS and LDFLAGS with the make build system is now
     more flexible (warning: OFLAGS is not used any more) (see the README)
     (contributed by Alon Bar-Lev).
   * ssl_set_own_cert() no longer calls pk_check_pair() since the
     performance impact was bad for some users (this was introduced in 1.3.10).
   * Move from SHA-1 to SHA-256 in example programs using signatures
     (suggested by Thorsten Mühlfelder).
   * Remove some unneeded inclusions of header files from the standard library
     "minimize" others (eg use stddef.h if only size_t is needed).
   * Change #include lines in test files to use double quotes instead of angle
     brackets for uniformity with the rest of the code.
   * Remove dependency on sscanf() in X.509 parsing modules.

= mbed TLS 1.3.10 released 2015-02-09
Security
   * NULL pointer dereference in the buffer-based allocator when the buffer is
     full and polarssl_free() is called (found by Mark Hasemeyer)
     (only possible if POLARSSL_MEMORY_BUFFER_ALLOC_C is enabled, which it is
     not by default).
   * Fix remotely-triggerable uninitialised pointer dereference caused by
     crafted X.509 certificate (TLS server is not affected if it doesn't ask for a
     client certificate) (found using Codenomicon Defensics).
   * Fix remotely-triggerable memory leak caused by crafted X.509 certificates
     (TLS server is not affected if it doesn't ask for a client certificate)
     (found using Codenomicon Defensics).
   * Fix potential stack overflow while parsing crafted X.509 certificates
     (TLS server is not affected if it doesn't ask for a client certificate)
     (found using Codenomicon Defensics).
   * Fix timing difference that could theoretically lead to a
     Bleichenbacher-style attack in the RSA and RSA-PSK key exchanges
     (reported by Sebastian Schinzel).

Features
   * Add support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv).
   * Add support for Extended Master Secret (draft-ietf-tls-session-hash).
   * Add support for Encrypt-then-MAC (RFC 7366).
   * Add function pk_check_pair() to test if public and private keys match.
   * Add x509_crl_parse_der().
   * Add compile-time option POLARSSL_X509_MAX_INTERMEDIATE_CA to limit the
     length of an X.509 verification chain.
   * Support for renegotiation can now be disabled at compile-time
   * Support for 1/n-1 record splitting, a countermeasure against BEAST.
   * Certificate selection based on signature hash, preferring SHA-1 over SHA-2
     for pre-1.2 clients when multiple certificates are available.
   * Add support for getrandom() syscall on recent Linux kernels with Glibc or
     a compatible enough libc (eg uClibc).
   * Add ssl_set_arc4_support() to make it easier to disable RC4 at runtime
     while using the default ciphersuite list.
   * Added new error codes and debug messages about selection of
     ciphersuite/certificate.

Bugfix
   * Stack buffer overflow if ctr_drbg_update() is called with too large
     add_len (found by Jean-Philippe Aumasson) (not triggerable remotely).
   * Possible buffer overflow of length at most POLARSSL_MEMORY_ALIGN_MULTIPLE
     if memory_buffer_alloc_init() was called with buf not aligned and len not
     a multiple of POLARSSL_MEMORY_ALIGN_MULTIPLE (not triggerable remotely).
   * User set CFLAGS were ignored by Cmake with gcc (introduced in 1.3.9, found
     by Julian Ospald).
   * Fix potential undefined behaviour in Camellia.
   * Fix potential failure in ECDSA signatures when POLARSSL_ECP_MAX_BITS is a
     multiple of 8 (found by Gergely Budai).
   * Fix unchecked return code in x509_crt_parse_path() on Windows (found by
     Peter Vaskovic).
   * Fix assembly selection for MIPS64 (thanks to James Cowgill).
   * ssl_get_verify_result() now works even if the handshake was aborted due
     to a failed verification (found by Fredrik Axelsson).
   * Skip writing and parsing signature_algorithm extension if none of the
     key exchanges enabled needs certificates. This fixes a possible interop
     issue with some servers when a zero-length extension was sent. (Reported
     by Peter Dettman.)
   * On a 0-length input, base64_encode() did not correctly set output length
     (found by Hendrik van den Boogaard).

Changes
   * Use deterministic nonces for AEAD ciphers in TLS by default (possible to
     switch back to random with POLARSSL_SSL_AEAD_RANDOM_IV in config.h).
   * Blind RSA private operations even when POLARSSL_RSA_NO_CRT is defined.
   * ssl_set_own_cert() now returns an error on key-certificate mismatch.
   * Forbid repeated extensions in X.509 certificates.
   * debug_print_buf() now prints a text view in addition to hexadecimal.
   * A specific error is now returned when there are ciphersuites in common
     but none of them is usable due to external factors such as no certificate
     with a suitable (extended)KeyUsage or curve or no PSK set.
   * It is now possible to disable negotiation of truncated HMAC server-side
2015-06-12 09:05:05 +00:00