Skip to content

Bring in changes from Mbed TLS as of 2019-07-22 #187

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 380 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
380 commits
Select commit Hold shift + click to select a range
43c24b8
Fix missing compile-time guards around CID-only constants
May 1, 2019
fe6bb8c
Unify documentation of internal SSL record structure
May 20, 2019
d5aeab1
Improve documentation of ssl_extract_add_data_from_record()
May 20, 2019
c4a190b
Add length of CID to additional data used for record protection
May 8, 2019
92fb4fa
Reduce stack usage for additional data buffers in record dec/enc
May 20, 2019
edb24f8
Remove unnecessary whitespace in ssl_extract_add_data_from_record()
May 20, 2019
d3f8c79
Improve wording in ssl_build_inner_plaintext()
May 20, 2019
07dc97d
Don't quote DTLSInnerPlaintext structure multiple times
May 20, 2019
af05ac0
Remove unnecessary empty line in ssl_tls.c
May 20, 2019
95e4bbc
Fix additional data calculation if CID is disabled
May 9, 2019
e2c2314
Add missing dependencies in unit tests for CID-based record enc/dec
May 20, 2019
76a79ab
Don't allow calling CID API outside of DTLS
May 3, 2019
6e7700d
Expain rationale for handling of consecutive empty AD records
May 8, 2019
82e2a39
Treat an invalid record after decryption as fatal
May 3, 2019
79594fd
Set pointer to start of plaintext at record decryption time
May 8, 2019
37ae952
Move dropping of unexpected AD records to after record decryption
May 3, 2019
f661c9c
Add helper function to check validity of record content type
May 3, 2019
5903de4
Split mbedtls_ssl_hdr_len() in separate functions for in/out records
May 3, 2019
3b154c1
Re-implement mbedtls_ssl_{in/out}_hdr_len() via in/out pointers
May 3, 2019
ad4a137
Add CID configuration API
May 3, 2019
6cbad55
Account for additional record expansion when using CIDs
May 8, 2019
f9c6a4b
Add pointers to in/out CID fields to mbedtls_ssl_context
May 3, 2019
6430faf
Adapt record encryption/decryption routines to change of record type
May 8, 2019
ca59c2b
Implement parsing of CID-based records
May 8, 2019
938489a
Re-enable CID comparison when decrypting CID-based records
May 8, 2019
16ded98
Don't fail on record with unexpected CID
May 8, 2019
05154c3
Re-enable passing CIDs to record transforms
May 3, 2019
2749a67
Reintroduce grepping for debug messages in CID tests in ssl-opt.sh
May 3, 2019
b42ec0d
Add support for change of CID to ssl_client2 / ssl_server2
May 3, 2019
b3e9dd5
Fix mismatching debug grep in ssl-opt.sh CID tests
May 8, 2019
22a59fd
Remove indicators and warnings about unfinished CID implementation
May 8, 2019
78c9137
Add Proxy tests for Connection ID to ssl-opt.sh
May 8, 2019
31f6e37
UDP Proxy: Don't drop CID records
May 8, 2019
c2045b0
Add CID test not using datagram packing to ssl-opt.sh
May 8, 2019
4a4af9f
Fix typo in comment
May 8, 2019
4c3eb7c
Set CID pointer to default value even for TLS
May 8, 2019
b1aa1b3
Allow the configuration of padding when using CID extension
May 8, 2019
2cdc5c3
Make signed to unsigned integer truncation cast explicit
May 9, 2019
3a96828
Add missing compile-time guard around CID API in ssl_server2
May 9, 2019
ddf775a
Reword CID documentation
May 13, 2019
b9ec44f
Remove restriction on value of MBEDTLS_SSL_CID_PADDING_GRANULARITY
May 13, 2019
c37c96a
Add specific SSL error code for unexpected CIDs
May 14, 2019
8367ccc
Allow to configure the stack's behaviour on unexpected CIDs
May 14, 2019
5d12467
Remove warnings about unfinished CID implementation
May 14, 2019
7fefd83
Modify MBEDTLS_SSL_UNEXPECTED_CID_{FAIL|IGNORE} to ignore by default
May 14, 2019
611ac77
Fix mbedtls_ssl_conf_cid() to not depend on macro constant values
May 14, 2019
56f81c7
Improve wording in documentation of MBEDTLS_SSL_CID
May 15, 2019
4cac442
Update references to CID draft to version 5
May 15, 2019
d9d4adb
Improve wording in documentation of mbedtls_ssl_set_cid()
May 15, 2019
08cbc0c
Use uniform spacing in def's of MBEDTLS_SSL_CID_{IN|OUT}_LEN_MAX
May 15, 2019
08cd9db
Use full sentences in Doxygen documentation of mbedtls_ssl_set_cid()
May 15, 2019
5cc145d
Slightly reword documentation of mbedtls_ssl_set_cid()
May 15, 2019
fb034e8
Improve wording of documentation of mbedtls_ssl_get_peer_cid()
May 15, 2019
f1a2808
Fix typo in documentation of `mbedtls_ssl_context::cid_in_use`
May 15, 2019
d1f2035
Slightly reorder CID debug messages during creation of transforms
May 15, 2019
ebcc913
Consistently reference CID draft through name + URL
May 15, 2019
a0e20d0
Rename MBEDTLS_SSL_CID to MBEDTLS_SSL_DTLS_CONNECTION_ID
May 15, 2019
62e5afa
Fix typo in Doxygen documentation of mbedtls_ssl_conf_cid()
May 20, 2019
8c07bee
Rename MBEDTLS_SSL_CID->MBEDTLS_SSL_DTLS_CONNECTION_ID in SSL suite
May 20, 2019
615ef17
Allow passing NULL pointers to mbedtls_ssl_get_peer_cid()
May 22, 2019
6ae14c0
Exemplify ways of calling mbedtls_ssl_get_peer_cid() in ssl_client2
May 22, 2019
1125952
Expand CID to Connection ID in documentation of mbedtls_ssl_conf_cid
May 23, 2019
d5eed42
Use negative-hex format for error codes in ssl_client2/ssl_server2
May 23, 2019
1d433a3
Remove superfluous newline in ssl_client2
May 23, 2019
3279822
Improve readability of ssl_client2/ssl_server2 usage instructions
May 23, 2019
3978d10
Remove superfluous new line in ssl_server2
May 23, 2019
3739e20
Disable Connection ID feature by default
May 23, 2019
8e55b0f
Improve comment in ssl_parse_record_header()
May 23, 2019
92d30f5
Fix indentation in debug message in ssl_tls.c
May 23, 2019
98aaf25
Add bad_cid option UDP proxy to insert unexpected CID records
May 24, 2019
e8d6afd
Add debug line witnessing receipt of unexpected CID
May 24, 2019
d0ac5fa
Insert records with unexpected CID in CID tests in ssl-opt.sh
May 24, 2019
b9355b7
Add description of CID feature to ChangeLog
May 24, 2019
09b8cae
Adapt ssl_server2 to parse DER encoded test CRTs if PEM is disabled
Feb 1, 2019
2900b14
Adapt ssl_client2 to parse DER encoded test CRTs if PEM is disabled
Feb 1, 2019
a0c5ceb
Correct white spaces in ssl_server2 and ssl_client2
Dec 5, 2018
623e7b4
ssl_client2: Skip CA setup if `ca_path` or `ca_file` argument "none"
Mar 5, 2019
8174bdf
ssl_server2: Skip CA setup if `ca_path` or `ca_file` argument "none"
Mar 5, 2019
422d199
Document "none" value for ca_path/ca_file in ssl_client2/ssl_server2
May 1, 2019
e21387e
Add build instructions to generate DER versions of CRTs and keys
Mar 12, 2019
8843c25
Add DER encoded files to git tree
May 17, 2019
58fc28c
Rename server1.der to server1.crt.der
Mar 14, 2019
666f60d
Adapt ChangeLog
Dec 5, 2018
960e588
Document origin of hardcoded certificates in library/certs.c
Mar 12, 2019
91e72c3
ssl-opt.sh: Auto-skip tests that use files if MBEDTLS_FS_IO unset
May 10, 2019
3217c8d
Allow DHM self test to run without MBEDTLS_PEM_PARSE_C
May 10, 2019
a545be2
Add run to all.sh exercising !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO
May 10, 2019
92b4f81
Use strict syntax to annotate origin of test data in certs.c
May 15, 2019
471ad47
Add new line at the end of test-ca2.key.enc
May 15, 2019
ff552f7
Re-generate library/certs.c from script
May 15, 2019
4cbea4b
Remove heading spaces in tests/data_files/Makefile
May 30, 2019
e35f02e
Update crypto submodule
Jun 3, 2019
12f62fb
Obey bounds of ASN.1 substructures
Feb 12, 2019
6ccfb18
Always return a high-level error code from X.509 module
Feb 12, 2019
d57a3a6
Adapt ChangeLog
Feb 14, 2019
3cddba8
Improve documentation of mbedtls_x509_get_ext()
Feb 11, 2019
3c03a88
Correct placement of ChangeLog entry
Jun 4, 2019
ca6aee4
Merge remote-tracking branch 'public/pr/2641' into HEAD
simonbutcher Jun 4, 2019
150deca
Merge remote-tracking branch 'public/pr/2642' into HEAD
simonbutcher Jun 4, 2019
fe20bea
Merge remote-tracking branch 'public/pr/2643' into HEAD
simonbutcher Jun 4, 2019
a1491fe
Merge remote-tracking branch 'public/pr/2651' into HEAD
simonbutcher Jun 4, 2019
a5c481e
Extend negative testing for X.509 TBS header parsing
Jun 4, 2019
a9ef412
Extend negative testing for X.509 Version parsing
Jun 4, 2019
e7d8f96
Extend negative testing for X.509 Serial number parsing
Jun 4, 2019
a328fff
Extend negative testing for X.509 AlgorithmIdentifier parsing
Feb 12, 2019
5e2cf38
Extend negative testing for X.509 Issuer parsing
Feb 12, 2019
18459d4
Extend negative testing for X.509 Validity parsing
Feb 13, 2019
28ae6b1
Extend negative testing for X.509 Subject parsing
Feb 13, 2019
bb955e5
Extend negative testing for X.509 SubjectPublicKeyInfo parsing
Jun 4, 2019
9f06b50
Extend negative testing for X.509 IssuerID parsing
Jun 4, 2019
be3850a
Extend negative testing for X.509 SubjectID parsing
Jun 4, 2019
05987e3
Extend negative testing for X.509 v3 Extension parsing
Jun 4, 2019
5f88a77
Extend negative testing for X.509 SignatureAlgorithm parsing
Jun 4, 2019
44199b6
Extend negative testing for X.509 Signature parsing
Feb 14, 2019
2389d16
Shorten X.509 CRT parsing test names
Feb 14, 2019
0f5acc1
Use ASN.1 NULL TLVs when testing invalid tags
Jun 4, 2019
19db19e
Fix test case name formatting in X.509 parsing suite
Mar 13, 2019
31af3b8
Fix non-DER length encoding in two X.509 CRT parsing tests
Feb 15, 2019
60dd6fc
Fix test dependencies in X.509 CRT parsing suite
Feb 15, 2019
764fbdf
Always use the same X.509 alg structure inside and outside of TBS
Jun 4, 2019
7ca07e3
Improve name of X.509 CRT parsing test
Mar 13, 2019
d51d485
Add negative X.509 parsing tests for IssuerID/SubjectID in v1 CRT
Mar 13, 2019
04b10c0
Add negative X.509 parsing tests for v3Ext in v1/v2 CRT
Mar 13, 2019
8671e81
Improve X.509 CRT parsing test names
Mar 14, 2019
7717c41
Add X.509 CRT parsing test for mixed time-encodings
Mar 14, 2019
c6f874b
Show removed symbols in abi check
dgreen-arm Jun 5, 2019
2de07f1
ssl: Don't access non-existent encrypt_then_mac field
Patater Jun 5, 2019
6b1683d
all.sh: Perform targeted EtM tests for MAC-less configs
Patater Jun 5, 2019
ab11889
test: Check empty buffer decryption for chachapoly
Patater Jun 5, 2019
2353b54
test: Remove redundant 0-byte decryption test
Patater Jun 5, 2019
bb16d0c
Merge remote-tracking branch 'origin/pr/2654' into development
Patater Jun 6, 2019
048df33
Merge remote-tracking branch 'origin/pr/2679' into development
Patater Jun 6, 2019
aa4d152
SSL reproducible test mode
catenacyber Jun 6, 2019
e1ae731
Update crypto submodule to 1.1.0d2
Patater Jun 7, 2019
986b6f2
Style fixes
catenacyber Jun 7, 2019
95f5cbc
Don't systematically rebuild programs
gilles-peskine-arm Jun 7, 2019
5d26e7c
Pass -m32 to the linker as well
gilles-peskine-arm Jun 7, 2019
3ca5085
Code review
catenacyber Jun 7, 2019
a3daa21
Merge remote-tracking branch 'origin/pr/2678' into development
Patater Jun 10, 2019
7c9d724
Option used added in string
catenacyber Jun 11, 2019
0ff84fb
Only warns if MBEDTLS_HAVE_TIME
catenacyber Jun 11, 2019
f91b372
More clarity for ifdef orders
catenacyber Jun 11, 2019
12e85de
Adds missing ret definition
catenacyber Jun 11, 2019
d2235f2
Commit to C90 style
catenacyber Jun 11, 2019
154feb2
comment alignment
catenacyber Jun 11, 2019
c5de462
Making version features easily ROM-able when using Arm C compiler.
mate-varga-arm Jun 12, 2019
961e677
UDP proxy: Don't attempt to dissect dgram into records when dropping
Jun 4, 2019
61cf9e3
Fix documentation of X.509 parsing test
Jun 13, 2019
e7655df
Make test suites compatible with #include <assert.h>
gilles-peskine-arm Jun 7, 2019
c7ad122
Make it easier to define MBEDTLS_PARAM_FAILED as assert
gilles-peskine-arm Jun 13, 2019
3abbced
Remove mbedtls_param_failed from programs
gilles-peskine-arm Jun 12, 2019
e1b02df
Merge remote-tracking branch 'origin/pr/2260' into development
Patater Jun 14, 2019
6b5dc68
Merge remote-tracking branch 'origin/pr/2430' into development
Patater Jun 14, 2019
39a8a26
Merge remote-tracking branch 'origin/pr/2661' into development
Patater Jun 14, 2019
d042198
Merge remote-tracking branch 'origin/pr/2675' into development
Patater Jun 14, 2019
3acb5eb
Merge remote-tracking branch 'origin/pr/2694' into development
Patater Jun 14, 2019
adcde5e
Add all.sh component that exercises invalid_param checks
gilles-peskine-arm Jun 12, 2019
3097a71
Update crypto submodule
gilles-peskine-arm Jun 14, 2019
7af080a
Merge remote-tracking branch 'origin/pr/2442' into development
Patater Jun 14, 2019
c54ee93
Merge remote-tracking branch 'origin/pr/2443' into development
Patater Jun 14, 2019
f3820e3
Fix misuse of signed ints in the HAVEGE module
gilles-peskine-arm Jun 7, 2019
738153a
Adding usage and removing dummy random
catenacyber Jun 18, 2019
b94cf82
unconditional mbedtls_ssl_conf_rng
catenacyber Jun 19, 2019
a152e42
net_sockets: Fix typo in net_would_block()
Patater May 29, 2019
a180926
timing: Remove redundant include file
Patater May 30, 2019
32eb58f
platform: Include stdarg.h where needed
Patater May 30, 2019
4f4af6e
windows: Fix Release x64 configuration
Patater Jun 3, 2019
d431104
ssl_tls: Enable Suite B with subset of ECP curves
Patater Jun 3, 2019
befe1e1
programs: Make `make clean` clean all programs always
Patater Jun 3, 2019
aada0c7
Merge remote-tracking branch 'origin/pr/2053' into development
Patater Jun 21, 2019
ca4e4a8
Merge remote-tracking branch 'origin/pr/2614' into development
Patater Jun 21, 2019
8d936e8
Merge remote-tracking branch 'origin/pr/2681' into development
Patater Jun 21, 2019
e2d5b9e
Merge remote-tracking branch 'origin/pr/2690' into development
Patater Jun 21, 2019
fd0f654
Merge remote-tracking branch 'origin/pr/2697' into development
Patater Jun 21, 2019
66b7edb
Merge remote-tracking branch 'origin/pr/2711' into development
Patater Jun 21, 2019
7233352
Fuzz testing
catenacyber May 3, 2018
9c7b698
Fuzz performance test without entropy
catenacyber May 29, 2018
f049304
Removes warnings for unused parameters
catenacyber Jun 4, 2019
2b7c9a2
Use rand instead of srand
catenacyber Jun 4, 2019
3abe15b
Fixes dummy leak in fuzz driver
catenacyber Jun 4, 2019
dbc0db9
include bignum.h from x509_crt.h
catenacyber May 28, 2018
0863382
Using custom time
catenacyber Jun 4, 2019
499c735
Factoring code
catenacyber Jun 4, 2019
801194b
Adds a ChangeLog entry
catenacyber Jun 4, 2019
8149627
Fuzz README and direct compilation
catenacyber Jun 4, 2019
03e87d9
Makefile support 1
catenacyber Jun 4, 2019
c32fd24
Protecting client/server fuzz targts with ifdefs
catenacyber Jun 6, 2019
cd6cd81
copyediting README.md
catenacyber Jun 6, 2019
a8210b3
Also clean the fuzz subdirectory
catenacyber Jun 7, 2019
7fff1fb
Ignore compiled object files and executables
catenacyber Jun 7, 2019
661d725
Deref pointer when using sizeof in x509_get_other_name
ekse Jun 23, 2019
33908e8
update the test script
May 29, 2019
5075f4d
Update the test encoding to support python3
Jun 3, 2019
64e4595
Make the script portable to both pythons
Jun 3, 2019
b220489
Refactor get_byte function
Jun 3, 2019
72662a4
Refactor receive_uint32()
Jun 25, 2019
3278081
Remove use of CMAKE_SOURCE_DIR
ashesman Apr 29, 2019
33b6a99
ChangeLog: Enable builds as a CMake subproject
Patater Jun 18, 2019
41421c4
README: Enable builds as a CMake subproject
Patater Jun 20, 2019
ab83fdf
CMake: Add a subdirectory build regression test
Patater Jun 20, 2019
c2d56a4
Allow declarations after statements
gilles-peskine-arm Jun 25, 2019
cd2c127
Adds LDFLAGS fsanitize=address
catenacyber Jun 25, 2019
adc23e6
Adding ifdefs to avoid warnings for unused globals
catenacyber Jun 25, 2019
1c582c3
Restore tests/fuzz/Makefile after in-tree cmake
catenacyber Jun 25, 2019
cf8fdfd
Documentation for corpus generation
catenacyber Jun 25, 2019
0069ab7
ChangeLog: Add ChangeLog entry for #2681
Patater Jun 24, 2019
48f35f5
Move fuzz directory to programs
catenacyber Jun 27, 2019
5dece6d
Restore programs/fuzz/Makefile after in-tree cmake
catenacyber Jun 27, 2019
daab28a
checks MBEDTLS_PEM_PARSE_C
catenacyber Jun 28, 2019
e4e2d3a
Add docker-based test scripts
pkolbus Dec 24, 2018
4225b1a
Clean up file prologue comments
pkolbus May 31, 2019
49c2435
Change Docker container to bionic
pkolbus Jun 1, 2019
be54358
Dockerfile: apt -> apt-get
pkolbus Jun 29, 2019
718c74c
Improve compatibility with firewalled networks
pkolbus Jun 29, 2019
a4b94c4
Update Mbed Crypto to contain mbed-crypto#152
Patater Jun 18, 2019
5131f77
Fix parsing issue when int parameter is in base 16
Jun 25, 2019
85aba47
Consistently spell -Wextra
gilles-peskine-arm Jul 2, 2019
1e65771
Remove redundant compiler flag
gilles-peskine-arm Jul 2, 2019
be51716
Warn if VLAs are used
gilles-peskine-arm Jul 2, 2019
6e70eb2
tests: Limit each log to 10 GiB
Patater Jul 3, 2019
6aa32cc
Allow running /somewhere/else/path/to/abi_check.py
gilles-peskine-arm Jul 4, 2019
b6ce234
Document how to build the typical argument for -s
gilles-peskine-arm Jul 4, 2019
3e2da4a
Record the commits that were compared
gilles-peskine-arm Jul 4, 2019
ada828f
Split _abi_compliance_command into smaller functions
gilles-peskine-arm Jul 4, 2019
7dfcfce
Use the docstring in the command line help
gilles-peskine-arm Jul 4, 2019
55b49ee
Allow TODO in code
gilles-peskine-arm Jul 4, 2019
0f220ec
Test with MBEDTLS_ECP_RESTARTABLE
Patater Jul 5, 2019
06e752b
Update crypto submodule to a revision with the HAVEGE header changes
gilles-peskine-arm Jun 14, 2019
482a479
Merge remote-tracking branch 'origin/pr/2699' into development
Patater Jul 5, 2019
702c659
Add a linker flag to enable gcov in basic-build-test.sh
catenacyber Jul 9, 2019
3e408d5
Fixes warnings from MSVC
catenacyber Jul 9, 2019
2321945
Syntax fix
catenacyber Jul 10, 2019
b348a3b
Merge remote-tracking branch 'origin/pr/2314' into development
Patater Jul 9, 2019
f473fa8
Merge remote-tracking branch 'origin/pr/2455' into development
Patater Jul 9, 2019
6d77d20
Merge remote-tracking branch 'origin/pr/2632' into development
Patater Jul 9, 2019
0b8b5e3
Merge remote-tracking branch 'origin/pr/2706' into development
Patater Jul 9, 2019
150d774
Merge remote-tracking branch 'origin/pr/2719' into development
Patater Jul 9, 2019
58259fe
Merge remote-tracking branch 'origin/pr/2721' into development
Patater Jul 9, 2019
01604a3
Merge remote-tracking branch 'origin/pr/2726' into development
Patater Jul 9, 2019
98c234f
Merge remote-tracking branch 'origin/pr/2729' into development
Patater Jul 9, 2019
5db519b
Merge remote-tracking branch 'origin/pr/2730' into development
Patater Jul 9, 2019
74a87f8
Merge remote-tracking branch 'origin/pr/2738' into development
Patater Jul 9, 2019
b3d3127
Style corrections
catenacyber Jul 10, 2019
a82fdd4
Removing space before opening parenthesis
catenacyber Jul 10, 2019
42a2ce8
No booleans and import config
catenacyber Jul 10, 2019
a864db0
Do not build fuzz on windows
catenacyber Jul 10, 2019
072959f
Merge remote-tracking branch 'origin/pr/1622' into development
Patater Jul 11, 2019
8306508
Merge remote-tracking branch 'origin/pr/2660' into development
Patater Jul 11, 2019
ff645d9
Merge remote-tracking branch 'origin/pr/2727' into development
Patater Jul 11, 2019
8dd1690
Merge remote-tracking branch 'tls/development' into development
Patater Jul 22, 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
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ massif-*
# Python build artifacts:
*.pyc

# CMake generates *.dir/ folders for in-tree builds (used by MSVC projects), ignore all of those:
*.dir/

# Visual Studio artifacts
/visualc/VS2010/.localhistory/
/visualc/VS2010/.vs/
/visualc/VS2010/Debug/
/visualc/VS2010/Release/
/visualc/VS2010/*.vcxproj.filters
/visualc/VS2010/*.vcxproj.user

# Generated documentation:
/apidoc

Expand Down
23 changes: 13 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ if(CMAKE_COMPILER_IS_GNU)
# note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wwrite-strings")
if (GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wvla")
endif()
if (GCC_VERSION VERSION_GREATER 4.5 OR GCC_VERSION VERSION_EQUAL 4.5)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wlogical-op")
endif()
Expand All @@ -141,7 +144,7 @@ if(CMAKE_COMPILER_IS_GNU)
endif(CMAKE_COMPILER_IS_GNU)

if(CMAKE_COMPILER_IS_CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_C_FLAGS_COVERAGE "-O0 -g3 --coverage")
Expand Down Expand Up @@ -219,13 +222,13 @@ if(ENABLE_TESTING)
COMMAND mv DartConfiguration.tcl.bak DartConfiguration.tcl
)
endif(UNIX)
endif()

# Make scripts needed for testing available in an out-of-source build.
if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
link_to_source(scripts)
# Copy (don't link) DartConfiguration.tcl, needed for memcheck, to
# keep things simple with the sed commands in the memcheck target.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DartConfiguration.tcl
${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY)
# Make scripts needed for testing available in an out-of-source build.
if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
link_to_source(scripts)
# Copy (don't link) DartConfiguration.tcl, needed for memcheck, to
# keep things simple with the sed commands in the memcheck target.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DartConfiguration.tcl
${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY)
endif()
endif()
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

DESTDIR=/usr/local
PREFIX=mbedtls_

Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(INSTALL_MBEDTLS_HEADERS)
endif(INSTALL_MBEDTLS_HEADERS)

# Make config.h available in an out-of-source build.
if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
if (ENABLE_TESTING AND NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
link_to_source(mbedtls)
link_to_source(psa)
endif()
119 changes: 96 additions & 23 deletions include/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,28 +277,52 @@
* For example, when a function accepts as input a pointer to a buffer that may
* contain untrusted data, and its documentation mentions that this pointer
* must not be NULL:
* - the pointer is checked to be non-NULL only if this option is enabled
* - the content of the buffer is always validated
* - The pointer is checked to be non-NULL only if this option is enabled.
* - The content of the buffer is always validated.
*
* When this flag is defined, if a library function receives a parameter that
* is invalid, it will:
* - invoke the macro MBEDTLS_PARAM_FAILED() which by default expands to a
* call to the function mbedtls_param_failed()
* - immediately return (with a specific error code unless the function
* returns void and can't communicate an error).
*
* When defining this flag, you also need to:
* - either provide a definition of the function mbedtls_param_failed() in
* your application (see platform_util.h for its prototype) as the library
* calls that function, but does not provide a default definition for it,
* - or provide a different definition of the macro MBEDTLS_PARAM_FAILED()
* below if the above mechanism is not flexible enough to suit your needs.
* See the documentation of this macro later in this file.
* is invalid:
* 1. The function will invoke the macro MBEDTLS_PARAM_FAILED().
* 2. If MBEDTLS_PARAM_FAILED() did not terminate the program, the function
* will immediately return. If the function returns an Mbed TLS error code,
* the error code in this case is MBEDTLS_ERR_xxx_BAD_INPUT_DATA.
*
* When defining this flag, you also need to arrange a definition for
* MBEDTLS_PARAM_FAILED(). You can do this by any of the following methods:
* - By default, the library defines MBEDTLS_PARAM_FAILED() to call a
* function mbedtls_param_failed(), but the library does not define this
* function. If you do not make any other arrangements, you must provide
* the function mbedtls_param_failed() in your application.
* See `platform_util.h` for its prototype.
* - If you enable the macro #MBEDTLS_CHECK_PARAMS_ASSERT, then the
* library defines MBEDTLS_PARAM_FAILED(\c cond) to be `assert(cond)`.
* You can still supply an alternative definition of
* MBEDTLS_PARAM_FAILED(), which may call `assert`.
* - If you define a macro MBEDTLS_PARAM_FAILED() before including `config.h`
* or you uncomment the definition of MBEDTLS_PARAM_FAILED() in `config.h`,
* the library will call the macro that you defined and will not supply
* its own version. Note that if MBEDTLS_PARAM_FAILED() calls `assert`,
* you need to enable #MBEDTLS_CHECK_PARAMS_ASSERT so that library source
* files include `<assert.h>`.
*
* Uncomment to enable validation of application-controlled parameters.
*/
//#define MBEDTLS_CHECK_PARAMS

/**
* \def MBEDTLS_CHECK_PARAMS_ASSERT
*
* Allow MBEDTLS_PARAM_FAILED() to call `assert`, and make it default to
* `assert`. This macro is only used if #MBEDTLS_CHECK_PARAMS is defined.
*
* If this macro is not defined, then MBEDTLS_PARAM_FAILED() defaults to
* calling a function mbedtls_param_failed(). See the documentation of
* #MBEDTLS_CHECK_PARAMS for details.
*
* Uncomment to allow MBEDTLS_PARAM_FAILED() to call `assert`.
*/
//#define MBEDTLS_CHECK_PARAMS_ASSERT

/* \} name SECTION: System support */

/**
Expand Down Expand Up @@ -1007,18 +1031,27 @@
/**
* \def MBEDTLS_USE_PSA_CRYPTO
*
* Make the X.509 and TLS library use PSA for cryptographic operations, see
* #MBEDTLS_PSA_CRYPTO_C.
* Make the X.509 and TLS library use PSA for cryptographic operations, and
* enable new APIs for using keys handled by PSA Crypto.
*
* Note: this option is still in progress, the full X.509 and TLS modules are
* not covered yet, but parts that are not ported to PSA yet will still work
* as usual, so enabling this option should not break backwards compatibility.
* \note Development of this option is currently in progress, and parts of Mbed
* TLS's X.509 and TLS modules are not ported to PSA yet. However, these parts
* will still continue to work as usual, so enabling this option should not
* break backwards compatibility.
*
* \warning Support for PSA is still an experimental feature.
* Any public API that depends on this option may change
* at any time until this warning is removed.
* \warning Support for PSA is still an experimental feature.
* Any public API that depends on this option may change
* at any time until this warning is removed.
*
* \warning This option enables new Mbed TLS APIs that are dependent on the
* PSA Crypto API, so can't come with the same stability guarantees as the
* rest of the Mbed TLS APIs. You're welcome to experiment with them, but for
* now, access to these APIs is opt-in (via enabling the present option), in
* order to clearly differentiate them from the stable Mbed TLS APIs.
*
* Requires: MBEDTLS_PSA_CRYPTO_C.
*
* Uncomment this to enable internal use of PSA Crypto and new associated APIs.
*/
//#define MBEDTLS_USE_PSA_CRYPTO

Expand Down Expand Up @@ -1702,6 +1735,10 @@
*
* Enable the Platform Security Architecture cryptography API.
*
* \warning The PSA Crypto API is still beta status. While you're welcome to
* experiment using it, incompatible API changes are still possible, and some
* parts may not have reached the same quality as the rest of Mbed TLS yet.
*
* Module: library/psa_crypto.c
*
* Requires: MBEDTLS_CTR_DRBG_C, MBEDTLS_ENTROPY_C
Expand Down Expand Up @@ -1950,6 +1987,42 @@
//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */
//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */

/**
* \brief This macro is invoked by the library when an invalid parameter
* is detected that is only checked with #MBEDTLS_CHECK_PARAMS
* (see the documentation of that option for context).
*
* When you leave this undefined here, the library provides
* a default definition. If the macro #MBEDTLS_CHECK_PARAMS_ASSERT
* is defined, the default definition is `assert(cond)`,
* otherwise the default definition calls a function
* mbedtls_param_failed(). This function is declared in
* `platform_util.h` for the benefit of the library, but
* you need to define in your application.
*
* When you define this here, this replaces the default
* definition in platform_util.h (which no longer declares the
* function mbedtls_param_failed()) and it is your responsibility
* to make sure this macro expands to something suitable (in
* particular, that all the necessary declarations are visible
* from within the library - you can ensure that by providing
* them in this file next to the macro definition).
* If you define this macro to call `assert`, also define
* #MBEDTLS_CHECK_PARAMS_ASSERT so that library source files
* include `<assert.h>`.
*
* Note that you may define this macro to expand to nothing, in
* which case you don't have to worry about declarations or
* definitions. However, you will then be notified about invalid
* parameters only in non-void functions, and void function will
* just silently return early on invalid parameters, which
* partially negates the benefits of enabling
* #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged.
*
* \param cond The expression that should evaluate to true, but doesn't.
*/
//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond )

/**
* Uncomment the macro to let mbed TLS use your alternate implementation of
* mbedtls_platform_zeroize(). This replaces the default implementation in
Expand Down
4 changes: 2 additions & 2 deletions include/mbedtls/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
* ECP 4 10 (Started from top)
* MD 5 5
* HKDF 5 1 (Started from top)
* CIPHER 6 8
* SSL 6 23 (Started from top)
* CIPHER 6 8 (Started from 0x6080)
* SSL 6 24 (Started from top, plus 0x6000)
* SSL 7 32
*
* Module dependent error code (5 bits 0x.00.-0x.F8.)
Expand Down
30 changes: 20 additions & 10 deletions include/mbedtls/pem.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,27 @@ void mbedtls_pem_free( mbedtls_pem_context *ctx );
* \brief Write a buffer of PEM information from a DER encoded
* buffer.
*
* \param header header string to write
* \param footer footer string to write
* \param der_data DER data to write
* \param der_len length of the DER data
* \param buf buffer to write to
* \param buf_len length of output buffer
* \param olen total length written / required (if buf_len is not enough)
* \param header The header string to write.
* \param footer The footer string to write.
* \param der_data The DER data to encode.
* \param der_len The length of the DER data \p der_data in Bytes.
* \param buf The buffer to write to.
* \param buf_len The length of the output buffer \p buf in Bytes.
* \param olen The address at which to store the total length written
* or required (if \p buf_len is not enough).
*
* \return 0 on success, or a specific PEM or BASE64 error code. On
* MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL olen is the required
* size.
* \note You may pass \c NULL for \p buf and \c 0 for \p buf_len
* to request the length of the resulting PEM buffer in
* `*olen`.
*
* \note This function may be called with overlapping \p der_data
* and \p buf buffers.
*
* \return \c 0 on success.
* \return #MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL if \p buf isn't large
* enough to hold the PEM buffer. In this case, `*olen` holds
* the required minimum size of \p buf.
* \return Another PEM or BASE64 error code on other kinds of failure.
*/
int mbedtls_pem_write_buffer( const char *header, const char *footer,
const unsigned char *der_data, size_t der_len,
Expand Down
1 change: 1 addition & 0 deletions include/mbedtls/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
* the destination buffer is too short.
*/
#if defined(MBEDTLS_PLATFORM_HAS_NON_CONFORMING_VSNPRINTF)
#include <stdarg.h>
/* For Older Windows (inc. MSYS2), we provide our own fixed implementation */
int mbedtls_platform_win32_vsnprintf( char *s, size_t n, const char *fmt, va_list arg );
#endif
Expand Down
11 changes: 11 additions & 0 deletions include/mbedtls/platform_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,24 @@ extern "C" {

#if defined(MBEDTLS_CHECK_PARAMS)

#if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
/* Allow the user to define MBEDTLS_PARAM_FAILED to something like assert
* (which is what our config.h suggests). */
#include <assert.h>
#endif /* MBEDTLS_CHECK_PARAMS_ASSERT */

#if defined(MBEDTLS_PARAM_FAILED)
/** An alternative definition of MBEDTLS_PARAM_FAILED has been set in config.h.
*
* This flag can be used to check whether it is safe to assume that
* MBEDTLS_PARAM_FAILED() will expand to a call to mbedtls_param_failed().
*/
#define MBEDTLS_PARAM_FAILED_ALT

#elif defined(MBEDTLS_CHECK_PARAMS_ASSERT)
#define MBEDTLS_PARAM_FAILED( cond ) assert( cond )
#define MBEDTLS_PARAM_FAILED_ALT

#else /* MBEDTLS_PARAM_FAILED */
#define MBEDTLS_PARAM_FAILED( cond ) \
mbedtls_param_failed( #cond, __FILE__, __LINE__ )
Expand Down
2 changes: 1 addition & 1 deletion library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Also see "include/mbedtls/config.h"

CFLAGS ?= -O2
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
WARNING_CFLAGS ?= -Wall -Wextra
LDFLAGS ?=

CRYPTO_INCLUDES ?= -I../include
Expand Down
1 change: 0 additions & 1 deletion library/timing.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)

#include <windows.h>
#include <winbase.h>
#include <process.h>

struct _hr_time
Expand Down
7 changes: 5 additions & 2 deletions library/version_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include <string.h>

static const char *features[] = {
static const char * const features[] = {
#if defined(MBEDTLS_VERSION_FEATURES)
#if defined(MBEDTLS_HAVE_ASM)
"MBEDTLS_HAVE_ASM",
Expand Down Expand Up @@ -90,6 +90,9 @@ static const char *features[] = {
#if defined(MBEDTLS_CHECK_PARAMS)
"MBEDTLS_CHECK_PARAMS",
#endif /* MBEDTLS_CHECK_PARAMS */
#if defined(MBEDTLS_CHECK_PARAMS_ASSERT)
"MBEDTLS_CHECK_PARAMS_ASSERT",
#endif /* MBEDTLS_CHECK_PARAMS_ASSERT */
#if defined(MBEDTLS_TIMING_ALT)
"MBEDTLS_TIMING_ALT",
#endif /* MBEDTLS_TIMING_ALT */
Expand Down Expand Up @@ -594,7 +597,7 @@ static const char *features[] = {

int mbedtls_version_check_feature( const char *feature )
{
const char **idx = features;
const char * const *idx = features;

if( *idx == NULL )
return( -2 );
Expand Down
5 changes: 3 additions & 2 deletions programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS

CFLAGS ?= -O2
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
WARNING_CXXFLAGS ?= -Wall -W
WARNING_CFLAGS ?= -Wall -Wextra
WARNING_CXXFLAGS ?= -Wall -Wextra
LDFLAGS ?=

LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
Expand Down Expand Up @@ -244,6 +244,7 @@ psa/crypto_examples$(EXEXT): psa/crypto_examples.c $(DEP)
clean:
ifndef WINDOWS
rm -f $(APPS) $(EXTRA_GENERATED)
-rm -f test/cpp_dummy_build$(EXEXT)
else
if exist *.o del /S /Q /F *.o
if exist *.exe del /S /Q /F *.exe
Expand Down
11 changes: 0 additions & 11 deletions programs/aes/aescrypt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ int main( void )
}
#else

#if defined(MBEDTLS_CHECK_PARAMS)
#include "mbedtls/platform_util.h"
void mbedtls_param_failed( const char *failure_condition,
const char *file,
int line )
{
mbedtls_printf( "%s:%i: Input param failed - %s\n",
file, line, failure_condition );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
#endif

int main( int argc, char *argv[] )
{
Expand Down
Loading