aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec
Commit message (Collapse)AuthorAgeFilesLines
* CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data()Richard Levitte2020-11-131-2/+4
| | | | | | | | | This is not done absolutely everywhere, as there are places where the use of ERR_add_error_data() is quite complex, but at least the simple cases are done. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
* Convert all {NAME}err() in crypto/ to their corresponding ERR_raise() callRichard Levitte2020-11-1330-598/+545
| | | | | | | | | | This includes error reporting for libcrypto sub-libraries in surprising places. This was done using util/err-to-raise Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13318)
* Fix REF_PRINT_COUNT argument in ecx_key_freeDaniel Bevenius2020-11-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when configuring OpenSSL using -DREF_PRINT the following compilation error is generated: In file included from include/crypto/ecx.h:21, from crypto/ec/ecx_key.c:11: crypto/ec/ecx_key.c: In function 'ecx_key_free': crypto/ec/ecx_key.c:65:32: error: 'r' undeclared (first use in this function) 65 | REF_PRINT_COUNT("ECX_KEY", r); | ^ include/internal/refcount.h:169:40: note: in definition of macro 'REF_PRINT_COUNT' 169 | fprintf(stderr, "%p:%4d:%s\n", b, b->references, a) | ^ crypto/ec/ecx_key.c:65:32: note: each undeclared identifier is reported only once for each function it appears in 65 | REF_PRINT_COUNT("ECX_KEY", r); | ^ include/internal/refcount.h:169:40: note: in definition of macro 'REF_PRINT_COUNT' 169 | fprintf(stderr, "%p:%4d:%s\n", b, b->references, a) | ^ make[1]: *** [Makefile:14929: crypto/ec/libcrypto-lib-ecx_key.o] Error 1 This commit updates the argument passed in to be the ECX_KEY* key. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13298)
* Update copyright yearMatt Caswell2020-10-151-1/+1
| | | | | Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> (Merged from https://github.com/openssl/openssl/pull/13144)
* Rename some occurrences of 'library_context' and 'lib_ctx' to 'libctx'Dr. Matthias St. Pierre2020-10-151-2/+2
| | | | | | | | | This change makes the naming more consistent, because three different terms were used for the same thing. (The term libctx was used by far most often.) Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12621)
* Rename OPENSSL_CTX prefix to OSSL_LIB_CTXDr. Matthias St. Pierre2020-10-1514-48/+49
| | | | | | | | | | | | Many of the new types introduced by OpenSSL 3.0 have an OSSL_ prefix, e.g., OSSL_CALLBACK, OSSL_PARAM, OSSL_ALGORITHM, OSSL_SERIALIZER. The OPENSSL_CTX type stands out a little by using a different prefix. For consistency reasons, this type is renamed to OSSL_LIB_CTX. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12621)
* Remove CMS recipient info information out of the algorithm implementationsMatt Caswell2020-10-151-6/+0
| | | | | | | | | Low level algorithm implementations have no business knowing about details of the higher level CMS concept. This knowledge is therefore moved into the CMS layer. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13088)
* Move CMS signing code out of the algorithms and into CMSMatt Caswell2020-10-151-16/+0
| | | | | | | | There is a large amount of CMS sepcific code in the algorithms. This is in the wrong place and breaks layering. This code should be in the CMS layer. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13088)
* Move CMS enveloping code out of the algorithms and into CMSMatt Caswell2020-10-151-336/+0
| | | | | | | | | | | | | There is quite a large amount of algorithm specific CMS code sitting in the algorithm directories. However, this seems to break layering. Algorithms really have no business knowing anything about CMS. Really it should be the other way around. Where there is algorithm specific CMS code it is the CMS layer that should know how to handle different algorithms. Therefore we move this code into the CMS layer. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/13088)
* Run the withlibctx.pl scriptMatt Caswell2020-10-017-41/+35
| | | | | | | | Automatically rename all instances of _with_libctx() to _ex() as per our coding style. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12970)
* der: _ossl prefix DER functionsPauli2020-10-011-1/+1
| | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13038)
* EC_GROUP_new_by_curve_name_with_libctx(): Add name of unknown group to error ↵Dr. David von Oheimb2020-09-301-0/+4
| | | | | | | output Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13023)
* Prune low-level ASN.1 parse errors from error queue in der2key_decode() etc.Dr. David von Oheimb2020-09-301-12/+5
| | | | | | | Also adds error output tests on loading key files with unsupported algorithms to 30-test_evp.t Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13023)
* Prune low-level ASN.1 parse errors from error queue in decoder_process()Dr. David von Oheimb2020-09-243-13/+2
| | | | | | | | Fixes #12840 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12893)
* Fix missing propq in ecdh_cms_set_shared_info()Shane Lontis2020-09-231-1/+1
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12944)
* Fix ecx so that is uses a settable propertyqueryShane Lontis2020-09-237-68/+91
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12944)
* Add SM2 key managementPaul Yang2020-09-221-3/+18
| | | | | | Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12536)
* Fix: ecp_nistz256-armv4.S bad argumentsHenry N2020-09-201-3/+3
| | | | | | | | | | | | | | | | Fix this error: crypto/ec/ecp_nistz256-armv4.S:3853: Error: bad arguments to instruction -- `orr r11,r10' crypto/ec/ecp_nistz256-armv4.S:3854: Error: bad arguments to instruction -- `orr r11,r12' crypto/ec/ecp_nistz256-armv4.S:3855: Error: bad arguments to instruction -- `orrs r11,r14' CLA: trivial Fixes #12848 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be> GH: #12854
* Fix ec keygen so that it passes the library context to ↵Shane Lontis2020-09-191-3/+3
| | | | | | | | | | | SSL_SELF_TEST_get_callback(). This was written before the ec key contained a library context, now that it contains a libctx it can be passed correctly to the callback. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12877)
* EC_KEY: add EC_KEY_decoded_from_explicit_params()Tomas Mraz2020-09-174-8/+33
| | | | | | | | | The function returns 1 when the encoding of a decoded EC key used explicit encoding of the curve parameters. Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> (Merged from https://github.com/openssl/openssl/pull/12683)
* EC: Reimplement EVP_PKEY_CTX_set_ec_param_enc() to support providersRichard Levitte2020-09-121-0/+40
| | | | | | | | Fixes #12852 Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12853)
* keygen: add FIPS error state management to conditional self testsShane Lontis2020-09-121-0/+2
| | | | | | Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12801)
* EVP: Move the functions and controls for setting and getting distidRichard Levitte2020-09-081-82/+0
| | | | | | | | | | Those functions were located in the EC files, but is really broader than that, even thought currently only used for SM2. They should therefore be in a more central location, which was also indicated by diverse TODOs. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12789)
* EVP: Add support for delayed EVP_PKEY operation parametersRichard Levitte2020-09-081-0/+82
| | | | | | | | | | | | | | | | | They get called "delayed parameters" because they may make it to the implementation at a later time than when they're given. This currently only covers the distinguished ID, as that's the only EVP_PKEY operation parameter so far that has been possible to give before the operation has been initialized. This includes a re-implementation of EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id(), and EVP_PKEY_CTX_get1_id_len(). Also, the more rigorous controls of keytype and optype are restored. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12789)
* Fix coverity CID #1466378 - Incorrect expression in ec_backend.cShane Lontis2020-09-051-1/+1
| | | | | Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/12708)
* EC: Remove one error record that shadows anotherRichard Levitte2020-09-031-2/+0
| | | | | | | | | | | | | In EC_GROUP_new_from_params(), ERR_R_EC_LIB was reported if group_new_from_name() returned NULL. However, this shadows a possible EC_R_INVALID_CURVE, making that harder to detect, which happens to be important to do in test/evp_test.c. This also extends key_unsupported() in test/evp_test.c to check for this error alongside the check for EC_R_UNKNOWN_GROUP. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12587)
* Ignore vendor name in Clang version number.Jung-uk Kim2020-08-272-2/+2
| | | | | | | | | | | | | | | | | | For example, FreeBSD prepends "FreeBSD" to version string, e.g., FreeBSD clang version 11.0.0 (git@github.com:llvm/llvm-project.git llvmorg-11.0.0-rc2-0-g414f32a9e86) Target: x86_64-unknown-freebsd13.0 Thread model: posix InstalledDir: /usr/bin This prevented us from properly detecting AVX support, etc. CLA: trivial Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/12725)
* Fix coverity CID #1458644 - Negative return passed to function taking size_t ↵Shane Lontis2020-08-241-1/+1
| | | | | | | in ecdh_cms_set_shared_info() Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12628)
* Add Explicit EC parameter support to providers.Shane Lontis2020-08-225-153/+604
| | | | | | | | | | This was added for backward compatability. Added EC_GROUP_new_from_params() that supports explicit curve parameters. This fixes the 15-test_genec.t TODO. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12604)
* Add libctx and propq param to ASN.1 sign/verify/HMAC/decryptDr. David von Oheimb2020-08-211-5/+7
| | | | | Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11808)
* X509: Add d2i_PUBKEY_ex(), which take a libctx and propqRichard Levitte2020-08-201-2/+6
| | | | | | | | | | | Just like d2i_PrivateKey() / d2i_PrivateKey_ex(), there's a need to associate an EVP_PKEY extracted from a PUBKEY to a library context and a property query string. Without it, a provider-native EVP_PKEY can only fetch necessary internal algorithms from the default library context, even though an application specific context should be used. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12671)
* Add libctx to ecdh_KDF_X9_63.Shane Lontis2020-08-092-10/+23
| | | | | | | Code is now correctly included in the fips provider. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11884)
* Add evp_test fixes.Shane Lontis2020-08-072-4/+6
| | | | | | | | | | | | | | Changed many tests so they also test fips (and removed 'availablein = default' from some tests). Seperated the monolithic evppkey.txt file into smaller maintainable groups. Changed the availablein option so it must be first - this then skips the entire test before any fetching happens. Changed the code so that all the OPENSSL_NO_XXXX tests are done in code via methods such as is_cipher_disabled(alg), before the fetch happens. Added missing libctx's found by adding a libctx to test_evp. Broke up large data files for cipher, kdf's and mac's into smaller pieces so they no longer need 'AvailableIn = default' Added missing algorithm aliases for cipher/digests to the providers. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12236)
* unify spelling of serializePauli2020-07-303-5/+5
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12104)
* Revert "kdf: make function naming consistent."Matt Caswell2020-07-161-3/+3
| | | | | | | | | | | | The commit claimed to make things more consistent. In fact it makes it less so. Revert back to the previous namig convention. This reverts commit 765d04c9460a304c8119f57941341a149498b9db. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12186)
* [EC][ASN1] Detect missing OID when serializing EC parameters and keysNicola Tuveri2020-07-063-3/+18
| | | | | | | | | | | | | | | | | | | The following built-in curves do not have an assigned OID: - Oakley-EC2N-3 - Oakley-EC2N-4 In general we shouldn't assume that an OID is always available. This commit detects such cases, raises an error and returns appropriate return values so that the condition can be detected and correctly handled by the callers, when serializing EC parameters or EC keys with the default `ec_param_enc:named_curve`. Fixes #12306 Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12313)
* Ensure creating an EC public key uses the libctxMatt Caswell2020-06-192-16/+30
| | | | | | | | | | | Creating an EC public key from the private key uses random numbers internally, which require use of the proper libtx. Therefore we make sure the libctx is used during this operation. Fixes #12150 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12159)
* Add more complete support for libctx/propq in the EC codeMatt Caswell2020-06-198-33/+67
| | | | | | | | Renames some "new_ex" functions to "new_with_libctx" and ensures that we pass around the libctx AND the propq everywhere. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12159)
* Make EVP_PKEY_CTX_[get|set]_ec_paramgen_curve_name more genericMatt Caswell2020-06-193-45/+3
| | | | | | | | | We rename these function to EVP_PKEY_CTX_get_group_name and EVP_PKEY_CTX_set_group_name so that they can be used for other algorithms other than EC. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11914)
* kdf: make function naming consistent.Pauli2020-06-111-3/+3
| | | | | | | | The EVP_KDF_CTX_* functions have been relocated to the EVP_KDF_* namespace for consistency. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11996)
* [crypto/ec] Remove unreachable AVX2 code in NISTZ256 implementationNicola Tuveri2020-06-042-2336/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | `crypto/ec/ecp_nistz256.c` contained code sections guarded by a `ECP_NISTZ256_AVX2` define. The relevant comment read: > /* > * Note that by default ECP_NISTZ256_AVX2 is undefined. While it's great > * code processing 4 points in parallel, corresponding serial operation > * is several times slower, because it uses 29x29=58-bit multiplication > * as opposite to 64x64=128-bit in integer-only scalar case. As result > * it doesn't provide *significant* performance improvement. Note that > * just defining ECP_NISTZ256_AVX2 is not sufficient to make it work, > * you'd need to compile even asm/ecp_nistz256-avx.pl module. > */ Without diminishing the quality of the original submission, it's evident that this code has been basically unreachable without modifications to the library source code and is under-tested. This commit removes these sections from the codebase. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/12019)
* Update copyright yearMatt Caswell2020-06-041-1/+1
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12043)
* Move EC_METHOD to internal-onlyBilly Brumley2020-06-028-26/+47
| | | | | | Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11928)
* Avoid undefined behavior with unaligned accessesBernd Edlinger2020-05-272-20/+22
| | | | | | | | | Fixes: #4983 [extended tests] Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> (Merged from https://github.com/openssl/openssl/pull/6074)
* Constify X509_PUBKEY_get(), X509_PUBKEY_get0(), and X509_PUBKEY_get0_param()Dr. David von Oheimb2020-05-262-2/+2
| | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11894)
* Update core_names.h fields and document most fields.Shane Lontis2020-05-261-8/+7
| | | | | | | | | | | | | | | Renamed some values in core_names i.e Some DH specific names were changed to use DH instead of FFC. Added some strings values related to RSA keys. Moved set_params related docs out of EVP_PKEY_CTX_ctrl.pod into its own file. Updated Keyexchange and signature code and docs. Moved some common DSA/DH docs into a shared EVP_PKEY-FFC.pod. Moved Ed25519.pod into EVP_SIGNATURE-ED25519.pod and reworked it. Added some usage examples. As a result of the usage examples the following change was also made: ec allows OSSL_PKEY_PARAM_USE_COFACTOR_ECDH as a settable gen parameter. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11610)
* Fix coverity issues in EC after #11807Nicola Tuveri2020-05-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should fix 2 issues detected by Coverity and introduced with https://github.com/openssl/openssl/pull/11807 - CID 1463577: Memory - corruptions (ARRAY_VS_SINGLETON) - CID 1463573: Memory - corruptions (ARRAY_VS_SINGLETON) In practice the tests seem to show that they both aren't real issues, yet I believe this small change should appease the scanner and at the same time improve clarity for the reader. Here is the original report: ``` ** CID 1463577: Memory - corruptions (ARRAY_VS_SINGLETON) ________________________________________________________________________________________________________ *** CID 1463577: Memory - corruptions (ARRAY_VS_SINGLETON) /crypto/ec/ec_lib.c: 1123 in EC_POINT_mul() 1117 1118 if (group->meth->mul != NULL) 1119 ret = group->meth->mul(group, r, g_scalar, point != NULL 1120 && p_scalar != NULL, &point, &p_scalar, ctx); 1121 else 1122 /* use default */ CID 1463577: Memory - corruptions (ARRAY_VS_SINGLETON) Passing "&point" to function "ec_wNAF_mul" which uses it as an array. This might corrupt or misinterpret adjacent memory locations. 1123 ret = ec_wNAF_mul(group, r, g_scalar, point != NULL 1124 && p_scalar != NULL, &point, &p_scalar, ctx); 1125 1126 #ifndef FIPS_MODULE 1127 BN_CTX_free(new_ctx); 1128 #endif ** CID 1463573: Memory - corruptions (ARRAY_VS_SINGLETON) ________________________________________________________________________________________________________ *** CID 1463573: Memory - corruptions (ARRAY_VS_SINGLETON) /crypto/ec/ec_lib.c: 1123 in EC_POINT_mul() 1117 1118 if (group->meth->mul != NULL) 1119 ret = group->meth->mul(group, r, g_scalar, point != NULL 1120 && p_scalar != NULL, &point, &p_scalar, ctx); 1121 else 1122 /* use default */ CID 1463573: Memory - corruptions (ARRAY_VS_SINGLETON) Passing "&p_scalar" to function "ec_wNAF_mul" which uses it as an array. This might corrupt or misinterpret adjacent memory locations. 1123 ret = ec_wNAF_mul(group, r, g_scalar, point != NULL 1124 && p_scalar != NULL, &point, &p_scalar, ctx); 1125 1126 #ifndef FIPS_MODULE 1127 BN_CTX_free(new_ctx); 1128 #endif ``` Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/11919)
* deprecate EC_POINT_make_affine and EC_POINTs_make_affineBilly Brumley2020-05-204-5/+12
| | | | | | Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/11874)
* deprecate EC precomputation functionalityBilly Brumley2020-05-192-0/+4
| | | | | | Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/11851)
* deprecate EC_POINTs_mul functionBilly Brumley2020-05-161-8/+34
| | | | | | Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11807)