Skip to content

Break non-crypto dependencies #74

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 19 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ script:
- make
- make test
- programs/test/selftest
- OSSL_NO_DTLS=1 tests/compat.sh
- tests/ssl-opt.sh -e '\(DTLS\|SCSV\).*openssl' --seed 4
- tests/scripts/test-ref-configs.pl
- tests/scripts/curves.pl
- tests/scripts/key-exchanges.pl
after_failure:
- tests/scripts/travis-log-failure.sh
env:
global:
secure: "barHldniAfXyoWOD/vcO+E6/Xm4fmcaUoC9BeKW+LwsHqlDMLvugaJnmLXkSpkbYhVL61Hzf3bo0KPJn88AFc5Rkf8oYHPjH4adMnVXkf3B9ghHCgznqHsAH3choo6tnPxaFgOwOYmLGb382nQxfE5lUdvnM/W/psQjWt66A1+k="
Expand Down
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@ if(ENABLE_TESTING)
ADD_CUSTOM_TARGET(covtest
COMMAND make test
COMMAND programs/test/selftest
COMMAND tests/compat.sh
COMMAND tests/ssl-opt.sh
)

ADD_CUSTOM_TARGET(lcov
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ ifndef WINDOWS
covtest:
$(MAKE) check
programs/test/selftest
tests/compat.sh
tests/ssl-opt.sh

lcov:
rm -rf Coverage
Expand Down
3 changes: 0 additions & 3 deletions configs/config-mini-tls1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
#define MBEDTLS_CERTS_C
#define MBEDTLS_PEM_PARSE_C

/* For testing with compat.sh */
#define MBEDTLS_FS_IO

#include "mbedtls/check_config.h"

#endif /* MBEDTLS_CONFIG_H */
25 changes: 20 additions & 5 deletions configs/config-psa-crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,11 @@
* Enable "non-blocking" ECC operations that can return early and be resumed.
*
* This allows various functions to pause by returning
* #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module,
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in
* order to further progress and eventually complete their operation. This is
* controlled through mbedtls_ecp_set_max_ops() which limits the maximum
* number of ECC operations a function may perform before pausing; see
* #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in Mbed TLS's SSL module,
* MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in order
* to further progress and eventually complete their operation. This is
* controlled through mbedtls_ecp_set_max_ops() which limits the maximum number
* of ECC operations a function may perform before pausing; see
* mbedtls_ecp_set_max_ops() for more information.
*
* This is useful in non-threaded environments if you want to avoid blocking
Expand Down Expand Up @@ -1156,6 +1156,21 @@
*/
//#define MBEDTLS_PSA_HAS_ITS_IO

/* MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER
*
* In PSA key storage, encode the owner of the key.
*
* This is only meaningful when building the library as part of a
* multi-client service. When you activate this option, you must provide
* an implementation of the type psa_key_owner_id_t and a translation
* from psa_key_file_id_t to file name in all the storage backends that
* you wish to support.
*
* Note that this option is meant for internal use only and may be removed
* without notice.
*/
//#define MBEDTLS_PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER

/**
* \def MBEDTLS_MEMORY_DEBUG
*
Expand Down
4 changes: 0 additions & 4 deletions configs/config-thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@
#define MBEDTLS_SSL_SRV_C
#define MBEDTLS_SSL_TLS_C

/* For tests using ssl-opt.sh */
#define MBEDTLS_NET_C
#define MBEDTLS_TIMING_C

/* Save RAM at the expense of ROM */
#define MBEDTLS_AES_ROM_TABLES

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

endif(INSTALL_MBEDTLS_HEADERS)

# Make config.h available in an out-of-source build. ssl-opt.sh requires it.
# Make config.h available in an out-of-source build.
if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
link_to_source(mbedtls)
link_to_source(psa)
Expand Down
2 changes: 1 addition & 1 deletion include/mbedtls/asn1.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
* - 0x02 -- tag indicating INTEGER
* - 0x01 -- length in octets
* - 0x05 -- value
* Such sequences are typically read into \c ::mbedtls_x509_buf.
* Such sequences are typically read into Mbed TLS's \c mbedtls_x509_buf.
* \{
*/
#define MBEDTLS_ASN1_BOOLEAN 0x01
Expand Down
10 changes: 5 additions & 5 deletions include/mbedtls/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,11 @@
* Enable "non-blocking" ECC operations that can return early and be resumed.
*
* This allows various functions to pause by returning
* #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module,
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in
* order to further progress and eventually complete their operation. This is
* controlled through mbedtls_ecp_set_max_ops() which limits the maximum
* number of ECC operations a function may perform before pausing; see
* #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in Mbed TLS's SSL module,
* MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in order
* to further progress and eventually complete their operation. This is
* controlled through mbedtls_ecp_set_max_ops() which limits the maximum number
* of ECC operations a function may perform before pausing; see
* mbedtls_ecp_set_max_ops() for more information.
*
* This is useful in non-threaded environments if you want to avoid blocking
Expand Down
9 changes: 4 additions & 5 deletions include/mbedtls/dhm.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,10 @@ int mbedtls_dhm_self_test( int verbose );
#endif

/**
* RFC 3526, RFC 5114 and RFC 7919 standardize a number of
* Diffie-Hellman groups, some of which are included here
* for use within the SSL/TLS module and the user's convenience
* when configuring the Diffie-Hellman parameters by hand
* through \c mbedtls_ssl_conf_dh_param.
* RFC 3526, RFC 5114 and RFC 7919 standardize a number of Diffie-Hellman
* groups, some of which are included here for use by Mbed TLS's SSL/TLS module
* and the user's convenience when configuring the Diffie-Hellman parameters by
* hand through Mbed TLS's \c mbedtls_ssl_conf_dh_param.
*
* The following lists the source of the above groups in the standards:
* - RFC 5114 section 2.2: 2048-bit MODP Group with 224-bit Prime Order Subgroup
Expand Down
24 changes: 12 additions & 12 deletions include/mbedtls/ecp.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,19 @@ mbedtls_ecp_keypair;
* same; they must not be used until the function finally
* returns 0.
*
* This only applies to functions whose documentation
* mentions they may return #MBEDTLS_ERR_ECP_IN_PROGRESS (or
* #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS for functions in the
* SSL module). For functions that accept a "restart context"
* argument, passing NULL disables restart and makes the
* function equivalent to the function with the same name
* This only applies to functions whose documentation mentions
* they may return #MBEDTLS_ERR_ECP_IN_PROGRESS (or
* `MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS` for functions in the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: MBEDLTS_ERR_SL_CRYPTO_IN_PROGRESS is back quoted here, but not elsewhere, e.g. in config.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit is only to remove the dependency in the ecp module. A later commit that removes SSL options from config.h will take care to update other references.

* Mbed TLS SSL module). For functions that accept a "restart
* context" argument, passing NULL disables restart and makes
* the function equivalent to the function with the same name
* with \c _restartable removed. For functions in the ECDH
* module, restart is disabled unless the function accepts
* an "ECDH context" argument and
* mbedtls_ecdh_enable_restart() was previously called on
* that context. For function in the SSL module, restart is
* only enabled for specific sides and key exchanges
* (currently only for clients and ECDHE-ECDSA).
* module, restart is disabled unless the function accepts an
* "ECDH context" argument and mbedtls_ecdh_enable_restart()
* was previously called on that context. For function in the
* Mbed TLS SSL module, restart is only enabled for specific
* sides and key exchanges (currently only for clients and
* ECDHE-ECDSA).
*
* \param max_ops Maximum number of basic operations done in a row.
* Default: 0 (unlimited).
Expand Down
2 changes: 1 addition & 1 deletion library/ecp.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ typedef enum
* Curves are listed in order: largest curves first, and for a given size,
* fastest curves first. This provides the default order for the SSL module.
*
* Reminder: update profiles in x509_crt.c when adding a new curves!
* Reminder: update profiles in Mbed TLS's x509_crt.c when adding new curves!
*/
static const mbedtls_ecp_curve_info ecp_supported_curves[] =
{
Expand Down
2 changes: 1 addition & 1 deletion library/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#endif

/*
* Reminder: update profiles in x509_crt.c when adding a new hash!
* Reminder: update profiles in Mbed TLS's x509_crt.c when adding a new hash!
*/
static const int supported_digests[] = {

Expand Down
93 changes: 58 additions & 35 deletions programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,58 @@ ifdef ZLIB
LOCAL_LDFLAGS += -lz
endif

APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
pkey/dh_genprime$(EXEXT) \
pkey/ecdh_curve25519$(EXEXT) \
pkey/ecdsa$(EXEXT) pkey/gen_key$(EXEXT) \
pkey/key_app$(EXEXT) pkey/key_app_writer$(EXEXT) \
pkey/mpi_demo$(EXEXT) pkey/pk_decrypt$(EXEXT) \
pkey/pk_encrypt$(EXEXT) pkey/pk_sign$(EXEXT) \
pkey/pk_verify$(EXEXT) pkey/rsa_genkey$(EXEXT) \
pkey/rsa_decrypt$(EXEXT) pkey/rsa_encrypt$(EXEXT) \
pkey/rsa_sign$(EXEXT) pkey/rsa_verify$(EXEXT) \
pkey/rsa_sign_pss$(EXEXT) pkey/rsa_verify_pss$(EXEXT) \
psa/crypto_examples$(EXEXT) \
psa/key_ladder_demo$(EXEXT) psa/psa_constant_names$(EXEXT) \
ssl/dtls_client$(EXEXT) ssl/dtls_server$(EXEXT) \
ssl/ssl_client1$(EXEXT) ssl/ssl_client2$(EXEXT) \
ssl/ssl_server$(EXEXT) ssl/ssl_server2$(EXEXT) \
ssl/ssl_fork_server$(EXEXT) ssl/mini_client$(EXEXT) \
ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \
random/gen_random_havege$(EXEXT) \
random/gen_random_ctr_drbg$(EXEXT) \
test/ssl_cert_test$(EXEXT) test/benchmark$(EXEXT) \
test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \
test/zeroize$(EXEXT) \
test/query_compile_time_config$(EXEXT) \
util/pem2der$(EXEXT) util/strerror$(EXEXT) \
x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \
x509/req_app$(EXEXT)
APPS = \
aes/aescrypt2$(EXEXT) \
aes/crypt_and_hash$(EXEXT) \
hash/hello$(EXEXT) \
hash/generic_sum$(EXEXT) \
pkey/dh_genprime$(EXEXT) \
pkey/ecdh_curve25519$(EXEXT) \
pkey/ecdsa$(EXEXT) \
pkey/gen_key$(EXEXT) \
pkey/key_app$(EXEXT) \
pkey/key_app_writer$(EXEXT) \
pkey/mpi_demo$(EXEXT) \
pkey/pk_decrypt$(EXEXT) \
pkey/pk_encrypt$(EXEXT) \
pkey/pk_sign$(EXEXT) \
pkey/pk_verify$(EXEXT) \
pkey/rsa_genkey$(EXEXT) \
pkey/rsa_decrypt$(EXEXT) \
pkey/rsa_encrypt$(EXEXT) \
pkey/rsa_sign$(EXEXT) \
pkey/rsa_verify$(EXEXT) \
pkey/rsa_sign_pss$(EXEXT) \
pkey/rsa_verify_pss$(EXEXT) \
psa/crypto_examples$(EXEXT) \
psa/key_ladder_demo$(EXEXT) \
psa/psa_constant_names$(EXEXT) \
ssl/dtls_client$(EXEXT) \
ssl/dtls_server$(EXEXT) \
ssl/ssl_client1$(EXEXT) \
ssl/ssl_client2$(EXEXT) \
ssl/ssl_server$(EXEXT) \
ssl/ssl_server2$(EXEXT) \
ssl/ssl_fork_server$(EXEXT) \
ssl/mini_client$(EXEXT) \
ssl/ssl_mail_client$(EXEXT) \
random/gen_entropy$(EXEXT) \
random/gen_random_havege$(EXEXT) \
random/gen_random_ctr_drbg$(EXEXT) \
test/ssl_cert_test$(EXEXT) \
test/benchmark$(EXEXT) \
test/selftest$(EXEXT) \
test/udp_proxy$(EXEXT) \
test/zeroize$(EXEXT) \
test/query_compile_time_config$(EXEXT) \
util/pem2der$(EXEXT) \
util/strerror$(EXEXT) \
x509/cert_app$(EXEXT) \
x509/crl_app$(EXEXT) \
x509/cert_req$(EXEXT) \
x509/cert_write$(EXEXT) \
x509/req_app$(EXEXT) \
# End of APPS

ifdef PTHREAD
APPS += ssl/ssl_pthread_server$(EXEXT)
Expand Down Expand Up @@ -226,17 +249,17 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP)
echo " CC ssl/ssl_client1.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c ssl/query_config.c $(DEP)
ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c test/query_config.c $(DEP)
echo " CC ssl/ssl_client2.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP)
echo " CC ssl/ssl_server.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c ssl/query_config.c $(DEP)
ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c test/query_config.c $(DEP)
echo " CC ssl/ssl_server2.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

ssl/ssl_fork_server$(EXEXT): ssl/ssl_fork_server.c $(DEP)
echo " CC ssl/ssl_fork_server.c"
Expand Down Expand Up @@ -278,9 +301,9 @@ test/zeroize$(EXEXT): test/zeroize.c $(DEP)
echo " CC test/zeroize.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c ssl/query_config.c $(DEP)
test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c test/query_config.c $(DEP)
echo " CC test/query_compile_time_config.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c test/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

util/pem2der$(EXEXT): util/pem2der.c $(DEP)
echo " CC util/pem2der.c"
Expand Down
2 changes: 1 addition & 1 deletion programs/pkey/key_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO)
#include "mbedtls/error.h"
#include "mbedtls/rsa.h"
#include "mbedtls/x509.h"
#include "mbedtls/pk.h"

#include <string.h>
#endif
Expand Down
14 changes: 0 additions & 14 deletions programs/pkey/rsa_genkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/bignum.h"
#include "mbedtls/x509.h"
#include "mbedtls/rsa.h"

#include <stdio.h>
Expand Down Expand Up @@ -160,19 +159,6 @@ int main( void )
mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret );
goto exit;
}
/*
mbedtls_printf( " ok\n . Generating the certificate..." );

x509write_init_raw( &cert );
x509write_add_pubkey( &cert, &rsa );
x509write_add_subject( &cert, "CN='localhost'" );
x509write_add_validity( &cert, "2007-09-06 17:00:32",
"2010-09-06 17:00:32" );
x509write_create_selfsign( &cert, &rsa );
x509write_crtfile( &cert, "cert.der", X509_OUTPUT_DER );
x509write_crtfile( &cert, "cert.pem", X509_OUTPUT_PEM );
x509write_free_raw( &cert );
*/
mbedtls_printf( " ok\n\n" );

exit_code = MBEDTLS_EXIT_SUCCESS;
Expand Down
2 changes: 1 addition & 1 deletion programs/pkey/rsa_sign_pss.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main( void )
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/md.h"
#include "mbedtls/rsa.h"
#include "mbedtls/x509.h"
#include "mbedtls/pk.h"

#include <stdio.h>
#include <string.h>
Expand Down
1 change: 0 additions & 1 deletion programs/pkey/rsa_verify_pss.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ int main( void )
#include "mbedtls/pem.h"
#include "mbedtls/pk.h"
#include "mbedtls/md.h"
#include "mbedtls/x509.h"

#include <stdio.h>
#include <string.h>
Expand Down
Loading