aboutsummaryrefslogtreecommitdiff
path: root/programs/pkey
AgeCommit message (Collapse)AuthorFilesLines
2022-04-12Rewrite ecdh_curve25519 programThomas Daubney1-72/+56
Rewrite the example ECDH x25519 program using the high-level ECDH API. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-10-25Fix the build of sample programs without mbedtls_strerrorGilles Peskine1-5/+7
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-10-14Merge pull request #4760 from gilles-peskine-arm/ecb-alt-ret-3.0Gilles Peskine2-4/+12
Catch failures of mbedtls_aes_crypt_ecb and its DES equivalents
2021-09-28fixup: Make the fields of mbedtls_ecp_curve_info publicGilles Peskine1-1/+1
Remove more places where MBEDTLS_PRIVATE() was used on grp_id, which is now public. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-09-27Catch failures of AES or DES operationsGilles Peskine2-4/+12
Declare all AES and DES functions that return int as needing to have their result checked, and do check the result in our code. A DES or AES block operation can fail in alternative implementations of mbedtls_internal_aes_encrypt() (under MBEDTLS_AES_ENCRYPT_ALT), mbedtls_internal_aes_decrypt() (under MBEDTLS_AES_DECRYPT_ALT), mbedtls_des_crypt_ecb() (under MBEDTLS_DES_CRYPT_ECB_ALT), mbedtls_des3_crypt_ecb() (under MBEDTLS_DES3_CRYPT_ECB_ALT). A failure can happen if the accelerator peripheral is in a bad state. Several block modes were not catching the error. This commit does the following code changes, grouped together to avoid having an intermediate commit where the build fails: * Add MBEDTLS_CHECK_RETURN to all functions returning int in aes.h and des.h. * Fix all places where this causes a GCC warning, indicating that our code was not properly checking the result of an AES operation: * In library code: on failure, goto exit and return ret. * In pkey programs: goto exit. * In the benchmark program: exit (not ideal since there's no error message, but it's what the code currently does for failures). * In test code: TEST_ASSERT. * Changelog entry. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-08-31Make the fields of mbedtls_ecp_curve_info publicGilles Peskine1-6/+6
The whole point of this structure is to provide information, both for the library's own sake and to applications. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-29Merge pull request #4694 from gilles-peskine-arm/out_size-3.0Ronald Cron3-5/+7
Add output size parameter to signature functions
2021-06-28Replace all inclusions of config.hBence Szépkúti20-100/+20
Also remove preprocessor logic for MBEDTLS_CONFIG_FILE, since build_info.h alreadyy handles it. This commit was generated using the following script: # ======================== #!/bin/sh git ls-files | grep -v '^include/mbedtls/build_info\.h$' | xargs sed -b -E -i ' /^#if !?defined\(MBEDTLS_CONFIG_FILE\)/i#include "mbedtls/build_info.h" //,/^#endif/d ' # ======================== Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2021-06-25Add output size parameter to signature functionsGilles Peskine3-5/+7
The functions mbedtls_pk_sign(), mbedtls_pk_sign_restartable(), mbedtls_ecdsa_write_signature() and mbedtls_ecdsa_write_signature_restartable() now take an extra parameter indicating the size of the output buffer for the signature. No change to RSA because for RSA, the output size is trivial to calculate. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-24Merge pull request #4707 from ↵Gilles Peskine4-4/+4
gilles-peskine-arm/require-matching-hashlen-rsa-implementation Require matching hashlen in RSA functions: implementation
2021-06-22RSA: Use hashlen as the hash input size as documentedGilles Peskine4-4/+4
Where hashlen was previously ignored when the hash length could be inferred from an md_alg parameter, the two must now match. Adapt the existing tests accordingly. Adapt the sample programs accordingly. This commit does not add any negative testing. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-17Use a proper DRBG in programsManuel Pégourié-Gonnard2-13/+61
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-06-17Fix cmake build of programsManuel Pégourié-Gonnard1-0/+2
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-06-17Add RNG params to private key parsingManuel Pégourié-Gonnard5-6/+14
This is necessary for the case where the public part of an EC keypair needs to be computed from the private part - either because it was not included (it's an optional component) or because it was compressed (a format we can't parse). This changes the API of two public functions: mbedtls_pk_parse_key() and mbedtls_pk_parse_keyfile(). Tests and programs have been adapted. Some programs use a non-secure RNG (from the test library) just to get things to compile and run; in a future commit this should be improved in order to demonstrate best practice. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2021-06-15Merge pull request #4629 from ↵Gilles Peskine3-6/+6
TRodziewicz/rename_functions_whose_deprecated_variants_have_been_removd Rename the _ret() functions
2021-06-15Make some fields of mbedtls_ecp_group publicGilles Peskine2-2/+2
The Mbed TLS code relies heavily on reading certain fields of mbedtls_ecp_group directly. Make these fields public. Require that MBEDTLS_ECP_ALT alternative implementations have them. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-15DHM: new functions to query the length of the modulusGilles Peskine2-5/+6
Add two functions mbedtls_dhm_get_len() and mbedtls_dhm_get_bitlen() to query the length of the modulus in bytes or bits. Remove the len field: the cost of calling mbedtls_dhm_get_len() each time it's needed is negligible, and this improves the abstraction of the DHM module. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2021-06-14Merge remote-tracking branch 'mbedtls/development' into ↵Ronald Cron9-11/+21
mbedtls_private_with_python Conflicts: include/mbedtls/ssl.h include/psa/crypto_struct.h Conflicts fixed by using the code from development branch and manually re-applying the MBEDTLS_PRIVATE wrapping.
2021-06-08Rename the _ret() functionsTRodziewicz3-6/+6
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
2021-06-08Fail if a padding disabled by the build-time configuration is selectedRonald Cron1-1/+1
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-06-08Change mbedtls_rsa_init() signatureRonald Cron7-9/+7
Remove padding parameters as mbedtls_rsa_init() cannot return an error code when padding parameters are invalid. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-06-08Change mbedtls_rsa_set_padding() signatureRonald Cron2-2/+14
mbedtls_rsa_set_padding() now returns the error code MBEDTLS_ERR_RSA_INVALID_PADDING when padding parameters are invalid. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2021-05-27Merge branch 'development' into mbedtls_private_with_pythonMateusz Starzyk5-8/+7
Conflicts: include/mbedtls/ssl.h Conflicts resolved by using code from development branch and manually re-applying MBEDTLS_PRIVATE wrapping.
2021-05-21Add MBEDTLS_PRIVATE wrapping to sample programs.Mateusz Starzyk11-65/+65
Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-05-18Removes mode param from mbedtls_rsa_pkcs1_verifyThomas Daubney2-4/+4
Commit removes mode parameter from mbedtls_rsa_pkcs1_verify and propagates the change throughout the codebase. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-05-18Removes p_rng param from mbedtls_rsa_pkcs1_verifyThomas Daubney2-2/+2
Commit removes p_rng from mbedtls_rsa_pkcs1_verify since p_rng has no relevance following the removal of f_rng from this function. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-05-18Removes f_rng parameter from mbedtls_rsa_pkcs1_verifyThomas Daubney2-2/+2
Commit removes f_rng parameter from mbedtls_rsa_pkcs1_verify as a prerequisite to removing the mode parameter. f_rng no longer has relevance in this function if mode is removed. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-05-18Removes mode param from mbedtls_rsa_pkcs1_signThomas Daubney2-2/+2
Commit removes the mode parameter from mbedtls_rsa_pkcs1_sign and progagates the change to all relevant parts of the codebase. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-05-17Removes mode param from mbedtls_rsa_pkcs1_encryptThomas Daubney1-2/+1
Removal of the mode parameter from mbedtls_rsa_pkcs1_encrypt function. This change is propagated throughout the codebase and to relevant tests. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2021-05-12Remove mode param from mbedtls_rsa_pkcs1_decryptThomas Daubney1-1/+1
The mode parameter has been removed from the mbedtls_rsa_pkcs1_decrypt function. The change has been progagated to all function calls, including in test suite .function files. Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
2020-10-20Build: Add MBEDTLS_TARGET_PREFIXRaef Coles1-2/+2
Allows required targets to have prefixes added to them, so that external projects can avoid target names clashing. Signed-off-by: Raef Coles <raef.coles@arm.com>
2020-09-10Merge pull request #3525 from HowJMay/typoDave Rodgman1-1/+1
Fix typo in comment
2020-09-10Fix typo in commentHowJMay1-1/+1
Fix typo in program/pkey/ecdh_curve25519.c Signed-off-by: HowJMay <vulxj0j8j8@gmail.com>
2020-08-25Merge pull request #3574 from makise-homura/e2k_supportGilles Peskine1-1/+1
Support building on e2k (Elbrus) architecture
2020-08-22Don't forget to free G, P, Q, ctr_drbg, and entropymakise-homura1-1/+1
I might be wrong, but lcc's optimizer is curious about this, and I am too: shouldn't we free allocated stuff correctly before exiting `dh_genprime` in this certain point of code? Signed-off-by: makise-homura <akemi_homura@kurisa.ch>
2020-08-19Update copyright notices to use Linux Foundation guidanceBence Szépkúti20-60/+20
As a result, the copyright of contributors other than Arm is now acknowledged, and the years of publishing are no longer tracked in the source files. Also remove the now-redundant lines declaring that the files are part of MbedTLS. This commit was generated using the following script: # ======================== #!/bin/sh # Find files find '(' -path './.git' -o -path './3rdparty' ')' -prune -o -type f -print | xargs sed -bi ' # Replace copyright attribution line s/Copyright.*Arm.*/Copyright The Mbed TLS Contributors/I # Remove redundant declaration and the preceding line $!N /This file is part of Mbed TLS/Id P D ' # ======================== Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2020-06-26programs: Link to tests common codeRonald Cron1-2/+2
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2020-06-26programs: cmake: Use list of executablesRonald Cron1-61/+37
Use list of executables to: - factorize the code to define executables - highlight the similarities and differences of the executable definitions - avoid list duplication Use alphabetic order for executables in lists. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2020-05-27Normalize line endingsGilles Peskine2-10/+10
Convert all text files to Unix line endings unless they're Windows stuff. Make sure that all text files have a trailing newline. Remove whitespace at the end of lines. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-05-12Merge pull request #2595 from k-stachowiak/unified-exit-in-examplesGilles Peskine20-41/+41
Unify the example programs' termination
2020-05-04Merge pull request #3190 from gilles-peskine-arm/config-full-clarify-developmentGilles Peskine3-3/+5
Clarify that the full config enables everything that can be tested together
2020-04-22Fix GCC format-signedness warningsKenneth Soerensen10-25/+25
Signed-off-by: Kenneth Soerensen <knnthsrnsn@gmail.com>
2020-04-20Strict C99: don't use a signed* when an unsigned* is expectedGilles Peskine3-3/+5
It works in practice on almost every platform, given that we're only using the wrong type in cases where the value is guaranteed to stay within the value bits of a signed int. But even in this case it may or may not be strictly conforming. Anyway `gcc -std=c99 -pedantic` rejects it. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2020-03-31Merge pull request #3013 from eozturk1/developmentManuel Pégourié-Gonnard1-1/+1
Fix debug message by using the correct function name called
2020-02-11cmake: link programs that only use crypto with libmbedcryptoGilles Peskine1-18/+18
When building with CMake, for sample programs that only use functionality in libmbedcrypto (i.e. crypto and platform), link with libmbedcrypto, not with libmbedtls. This doesn't change the result, because the linker skips libraries in which no symbol is used, but it changes the build dependencies, and it has the advantage of bringing programs/*/CMakeLists.txt closer to the corresponding files under crypto/. The programs concerned are crypto sample and test programs, and programs that only use (potential) platform functions such as mbedtls_printf. dh_client and dh_server keep linking with mbedtls because they use functions from the net_sockets module.
2020-02-11pkey/rsa_genkey: Remove commented out codeJaeden Amero1-13/+0
There is some commented out X.509 certificate writing code present in rsa_genkey. It looks like it has been commented out since the beginning of time. Let's remove it, since commented out code is not in good style.
2020-02-11pkey: Remove dependency on X.509Jaeden Amero4-4/+2
2020-01-28Fix debug message by using the correct function name calledErcan Ozturk1-1/+1
2019-11-13Use MBEDTLS_PK_SIGNATURE_MAX_SIZE in pkey sample programsGilles Peskine2-13/+2
Use the constant that is now provided by the crypto submodule instead of rolling our own definition which is not correct in all cases.
2019-08-16Unify the example programs' terminationKrzysztof Stachowiak20-41/+41
This is done to account for platforms, for which we want custom behavior upon the program termination, hence we call `mbedtls_exit()` instead of returning from `main()`.