8dd1690993
Resolve conflicts by performing the following operations: - Reject changes related to building a crypto submodule, since Mbed Crypto is the crypto submodule. - Reject X.509, NET, and SSL changes. - Reject changes to README, as Mbed Crypto is a different project from Mbed TLS, with a different README. - Avoid adding mention of ssl-opt.sh in a comment near some modified code in include/CMakeLists.txt (around where ENABLE_TESTING as added). - Align config.pl in Mbed TLS with config.pl in Mbed Crypto where PSA options are concerned, to make future merging easier. There is no reason for the two to be different in this regard, now that Mbed TLS always depends on Mbed Crypto. Remaining differences are only the PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER option and the absence of X.509, NET, and SSL related options in Mbed Crypto's config.pl. - Align config.h in Mbed Crypto with Mbed TLS's copy, with a few notable exceptions: - Leave CMAC on by default. - Leave storage on by default (including ITS emulation). - Avoid documenting the PSA Crypto API as is in beta stage in documentation for MBEDTLS_PSA_CRYPTO_C. The only remaining differences are a lack of X.509, NET, and SSL options in Mbed Crypto's config.h, as well as an additional Mbed-Crypto-specific PSA_CRYPTO_KEY_FILE_ID_ENCODES_OWNER option. Documentation for the check params feature and related macros is also updated to match Mbed TLS's description. - Reject tests/data_files/Makefile changes to generate DER versions of CRTs and keys, as none of those are used by Mbed Crypto tests. - Add the "no PEM and no filesystem" test to all.sh, without ssl-opt.sh run, as Mbed Crypto doesn't have ssl-opt.sh. Also remove use of PSA Crypto storage and ITS emulation, since those depend on filesystem support. - Reject addition of test when no ciphersuites have MAC to all.sh, as the option being tested, MBEDTLS_SSL_SOME_MODES_USE_MAC, is not present in Mbed Crypto. - Use baremetal config in all.sh, as Mbed Crypto's baremetal configuration does exclude the net module (as it doesn't exist in Mbed Crypto) - Reject cmake_subproject_build changes, continuing to link only libmbedcrypto. - Reject changes to visualc and associated templates. Mbed Crypto doesn't need additional logic to handle submodule-sourced headers. - Avoid adding fuzzers from Mbed TLS. The only relevant fuzzers are the privkey and pubkey fuzzers, but non-trivial work would be required to integrate those into Mbed Crypto (more than is comfortable in a merge commit). - Reject addition of Docker wrappers for compat.sh and ssl-opt.sh, as those are not present in Mbed Crypto. - Remove calls to SSL-related scripts from basic-in-docker.sh Fix test errors by performing the following: - Avoid using a link that Doxygen can't seem to resolve in Mbed Crypto, but can resolve in Mbed TLS. In documentation for MBEDTLS_CHECK_PARAMS, don't attempt to link to MBEDTLS_PARAM_FAILED. * origin/development: (339 commits) Do not build fuzz on windows No booleans and import config Removing space before opening parenthesis Style corrections Syntax fix Fixes warnings from MSVC Add a linker flag to enable gcov in basic-build-test.sh Update crypto submodule to a revision with the HAVEGE header changes Test with MBEDTLS_ECP_RESTARTABLE Allow TODO in code Use the docstring in the command line help Split _abi_compliance_command into smaller functions Record the commits that were compared Document how to build the typical argument for -s Allow running /somewhere/else/path/to/abi_check.py tests: Limit each log to 10 GiB Warn if VLAs are used Remove redundant compiler flag Consistently spell -Wextra Fix parsing issue when int parameter is in base 16 ... |
||
---|---|---|
.. | ||
aes | ||
hash | ||
pkey | ||
psa | ||
random | ||
test | ||
util | ||
.gitignore | ||
CMakeLists.txt | ||
Makefile | ||
README.md | ||
wince_main.c |
Mbed TLS sample programs
This subdirectory mostly contains sample programs that illustrate specific features of the library, as well as a few test and support programs.
Symmetric cryptography (AES) examples
-
aes/aescrypt2.c
: file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC.
Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by thepkcs5
module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module). -
aes/crypt_and_hash.c
: file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface.
Hash (digest) examples
-
hash/generic_sum.c
: file hash calculator and verifier, demonstrating the message digest (md
) interface. -
hash/hello.c
: hello-world program for MD5.
Public-key cryptography examples
Generic public-key cryptography (pk
) examples
-
pkey/gen_key.c
: generates a key for any of the supported public-key algorithms (RSA or ECC) and writes it to a file that can be used by the other pk sample programs. -
pkey/key_app.c
: loads a PEM or DER public key or private key file and dumps its content. -
pkey/key_app_writer.c
: loads a PEM or DER public key or private key file and writes it to a new PEM or DER file. -
pkey/pk_encrypt.c
,pkey/pk_decrypt.c
: loads a PEM or DER public/private key file and uses the key to encrypt/decrypt a short string through the generic public-key interface. -
pkey/pk_sign.c
,pkey/pk_verify.c
: loads a PEM or DER private/public key file and uses the key to sign/verify a short string.
ECDSA and RSA signature examples
-
pkey/ecdsa.c
: generates an ECDSA key, signs a fixed message and verifies the signature. -
pkey/rsa_encrypt.c
,pkey/rsa_decrypt.c
: loads an RSA public/private key and uses it to encrypt/decrypt a short string through the low-level RSA interface. -
pkey/rsa_genkey.c
: generates an RSA key and writes it to a file that can be used with the other RSA sample programs. -
pkey/rsa_sign.c
,pkey/rsa_verify.c
: loads an RSA private/public key and uses it to sign/verify a short string with the RSA PKCS#1 v1.5 algorithm. -
pkey/rsa_sign_pss.c
,pkey/rsa_verify_pss.c
: loads an RSA private/public key and uses it to sign/verify a short string with the RSASSA-PSS algorithm.
Diffie-Hellman key exchange examples
pkey/ecdh_curve25519.c
: demonstration of a elliptic curve Diffie-Hellman (ECDH) key agreement.
Bignum (mpi
) usage examples
-
pkey/dh_genprime.c
: shows how to use the bignum (mpi
) interface to generate Diffie-Hellman parameters. -
pkey/mpi_demo.c
: demonstrates operations on big integers.
Random number generator (RNG) examples
-
random/gen_entropy.c
: shows how to use the default entropy sources to generate random data.
Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated byrandom/gen_random_ctr_drbg.c
. -
random/gen_random_ctr_drbg.c
: shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data. -
random/gen_random_havege.c
: demonstrates the HAVEGE entropy collector.
Test utilities
-
test/benchmark.c
: benchmark for cryptographic algorithms. -
test/selftest.c
: runs the self-test function in each library module. -
test/udp_proxy.c
: a UDP proxy that can inject certain failures (delay, duplicate, drop). Useful for testing DTLS. -
test/zeroize.c
: a test program formbedtls_platform_zeroize
, used bytests/scripts/test_zeroize.gdb
.
Development utilities
-
util/pem2der.c
: a PEM to DER converter. Mbed TLS can read PEM files directly, but this utility can be useful for interacting with other tools or with minimal Mbed TLS builds that lack PEM support. -
util/strerror.c
: prints the error description corresponding to an integer status returned by an Mbed TLS function.