summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Mop up EC_GROUP precomp machinery.jsing2023-06-243-252/+10
| | | | | | | | | | | Since there are now no EC implementations that perform pre-computation at the EC_GROUP level, remove all of the precomp machinery, including the extra_data EC_GROUP member. The ec_wNAF_mul() code is horrific - simply cut out the precomp code, rather than trying to rewrite it (that's a project for another day). ok tb@
* Mop up ec_wNAF_{,have_}precompute_mult().jsing2023-06-242-206/+2
| | | | | | | | These were previously called by GF2m code and are no longer used. Also remove ec_pre_comp_new(), since it is only called by ec_wNAF_precompute_mult() and is now unused. ok tb@
* Fix return check for BN_hex2bn()tb2023-06-231-2/+2
| | | | | | | | Purely cosmetic change taking into account the fact that this function returns a length rather than a boolean. This is the last offender in the library. ok jsing
* Consolidate elliptic curve cofactor handlingtb2023-06-201-49/+41
| | | | | | | | | | | | | The various checks of the cofactor to be set in EC_GROUP_set_generator() are a bit all over the place. Move them into a single function and clean things up a little. Instead of calculating directly with the cofactor member of the group, use a temporary variable and copy this variable only if all tests passed. In cryptographic contexts the cofactor almost always fits if not into a single byte then into a word, so copying is cheap. Also streamline the computations a bit and remove some binary curve contortions. ok jsing
* Remove prototypes for various ec_GF2m_* functions that no longer exist.jsing2023-06-121-13/+1
|
* Rewrite ECParameters_dup()tb2023-05-041-7/+12
| | | | | | | This should leak slightly less than the direct expansion of ASN1_dup_of(). Use freezero() since the DER could contain a private key. ok jsing
* Use size_t instead of int in EC_POINT_point2oct()tb2023-05-041-2/+2
| | | | | | | An int would be perfectly sufficient for this, but then again there would be fewer traps. ok jsing
* Fix line wrappingtb2023-05-041-3/+3
|
* Fix function name in doc commenttb2023-05-041-2/+2
|
* Fix a few KNF/whitespace issuestb2023-05-031-9/+5
|
* Rename P into generatortb2023-05-021-6/+6
| | | | ok jsing
* Simplify EC_GROUP_new_by_curve_name()tb2023-05-021-20/+14
| | | | | | | | | | | | | Pull the setting of the name a.k.a. nid into ec_group_new_from_data(). This way, we can return early on finding the nid in the curve_list[]. This also avoids a silly bug where a bogus ERR_R_UNKNOWN_BUG is pushed onto the error stack when ec_group_new_from_data() failed. While there rework the exit path of ec_group_new_from_data() a bit. Instead of an ok variable we can use an additional pointer to keep track of the return value and free the EC_GROUP unconditionally. ok jsing
* stray whitespacetb2023-05-011-2/+2
|
* Add a missing pair of braces.tb2023-05-011-2/+3
|
* Use uppercase for the CURVE_LIST_LENGTH macrotb2023-05-011-6/+6
|
* Consistently use lowercase hex digits for curve parameterstb2023-05-011-749/+749
|
* Now that we have C99 initializers, garbage collect some commentstb2023-05-011-299/+299
|
* Rework the curve list to use actual structs instead of a customtb2023-05-011-742/+1530
| | | | | | serialized format. ok jsing
* Drop the now unnecessary and unused field_type from the curve datatb2023-05-011-54/+4
| | | | ok jsing
* Convert EC_CURVE_DATA to C99 initializerstb2023-05-011-51/+192
| | | | | | Also clean up the definition of EC_CURVE_DATA a bit. ok jsing
* Simplify ec_group_new_from_data() furthertb2023-05-011-16/+55
| | | | | | | | | | We have a BN_CTX available, so we may as well use it. This simplifies the cleanup path at the cost of a bit more code in the setup. Also use an extra BIGNUM for the cofactor. Reusing x for this is just silly. If you were really going to avoid extra allocations, this entire function could easily have been written with three BIGNUMs. ok jsing
* Drop some dead codetb2023-05-011-11/+2
| | | | | | | No member of the curve_list[] table has a method set. Thus, curve.meth is always NULL and we never take the EC_GROUP_new(meth) code path. ok jsing
* Remove pointless/wrong .meth = 0 entries from curves_list[]tb2023-05-011-55/+1
|
* Mechanically convert curve_list[] to C99 initializerstb2023-05-011-55/+325
| | | | ok jsing
* Clean up handling of nist_curves[]tb2023-05-011-18/+14
| | | | | | | | There's no point in introducing a typedef only for two sizeof() calls. We might as well use an anonymous struct for this list. Make it const while there, drop some braces and compare strcmp() return value to 0. ok jsing
* Move EC_POINT_{get,set}_Jprojective_coordinates to ec_local.htb2023-04-272-10/+12
|
* Nuke doxygen noisetb2023-04-271-421/+37
|
* Clean up ec.h a little.tb2023-04-261-186/+31
| | | | | The doxygen comments are either obvious or otherwise unhelpful and generally an eye sore. Go read the manpage if the header isn't enough.
* GF2m bites the dust. It won't be missed.tb2023-04-259-3320/+9
|
* Remove prototype of EC_GFp_nist_method()tb2023-04-251-8/+1
|
* Move EC_KEY_{insert,set}_key_method_data() to internal-onlytb2023-04-252-18/+7
|
* Remove the horror show that is bn_nist and ecp_nisttb2023-04-251-177/+0
| | | | | | This code is full of problematic C and is also otherwise of questionable quality. It is far from constant time and jsing informs me it also isn't faster. Good riddance.
* Wire up truncated SHA-2, SHA-3 and related thingstb2023-04-251-2/+7
| | | | from jsing
* Use NULL, not 0 for pointers and use an explicit comparison against NULL.tb2023-04-181-3/+3
|
* Remove prototypes under OPENSSL_NO_EC_NISTP_64_GCC_128tb2023-04-181-18/+1
| | | | | | | The code was deleted a while back, the prototypes remained. We had OPENSSL_NO_EC_NISTP_64_GCC_128 in opensslfeatures.h since forever. discussed with jsing
* Sigh cvs... Also drop OPENSSL_NO_DEPRECATED from ec.htb2023-04-181-3/+1
|
* Mark public bn_nist and ec_nist API for removaltb2023-04-161-1/+3
| | | | | | | | | | | | | The faster nist code is rife with problematic C. While this is generally considered to be a pleonasm nowadays, here it specifically refers to aliasing issues and other flavors of undefined behavior. With compilers and standardization committees becoming seemingly more determined about making C even more unusable than it already is, this code has resulted in miscompilations and generally is a target rich environment for fuzzers to feast on. We're better off without it. Go look while it's still there. It's some of the very worst we have to offer. ok jsing
* Mark EC_KEY_{get,insert}_method_data() for removaltb2023-04-161-1/+5
| | | | | | | This is unused and in the way of some house keeping. Thus it will be relocated to the attic. ok jsing
* ec_lib.c: fix a few NULL misspellingstb2023-04-131-6/+6
|
* Fix various early return issues spotted by coveritytb2023-04-131-13/+13
| | | | | | | A large mechanical diff led to sloppy review and gave coverity an opportunity to be right for once. First time in a good many weeks. same diff/ok jsing
* Handle BN_CTX at the EC API boundary.jsing2023-04-1111-491/+553
| | | | | | | | | | | The EC API allows callers to optionally pass in a BN_CTX, which means that any code needing a BN_CTX has to check if one was provided, allocate one if not, then free it again. Rather than doing this dance throughout the EC code, handle the BN_CTX existance at the EC API boundary. This means that lower level implementation code can simply assume that the BN_CTX is available. ok tb@
* Clean up unused BIGNUM.jsing2023-04-111-4/+1
|
* Replace the remaining BN_copy() with bn_copy()tb2023-03-276-70/+70
| | | | ok jsing
* Return the signature length after successful signing operationtb2023-03-151-1/+3
| | | | | | | | | This is required behavior of the EVP_DigestSign() API, but seemingly almost nothing uses this. Well, turns out ldns does. Reported by Stephane. Helpful comments by sthen. ok jsing
* Fix a EC_GROUP_clear_free() that snuck through.jsing2023-03-081-2/+2
| | | | Thanks to Mark Patruck for reporting.
* Fix previous.jsing2023-03-081-5/+5
|
* Always clear EC groups and points on free.jsing2023-03-0810-114/+35
| | | | | | | | | | Rather than sometimes clearing, turn the free functions into ones that always clear (as we've done elsewhere). Turn the EC_GROUP_clear_free() and EC_POINT_clear_free() functions into wrappers that call the *_free() version. Do similar for the EC_METHOD implementations, removing the group_clear_finish() and point_clear_finish() hooks in the process. ok tb@
* Stop trying to use EC_GFp_nist_method().jsing2023-03-081-76/+20
| | | | | | | | | | | | | | | | | | | | | | | | Currently, if compiled without OPENSSL_BN_ASM_MONT, EC_GROUP_new_curve_GFp() tries to use EC_GFp_nist_method(), falling back to EC_GFp_mont_method() if it is not a NIST curve (if OPENSSL_BN_ASM_MONT is defined we use EC_GFp_mont_method() unconditionally). Now that we have a reasonable non-assembly Montgomery implementation, the performance of EC_GFp_nist_method() is either similar or slower than EC_GFp_mont_method() (the exception being P-521, however if you're using that you're not doing it for performance reasons anyway). The EC_GFp_nist_method() uses rather scary BN NIST code (which would probably already be removed, if not for the BN and EC public APIs), it uses code paths that are currently less constant time, and there is additional overhead in checking to see if the curve is actually supported. Stop trying to use EC_GFp_nist_method() and unconditionally use EC_GFp_mont_method() in all cases. While here, factor out the common setup code and call it from both EC_GROUP_new_curve_GFp() and EC_GROUP_new_curve_GF2m(). ok beck@ tb@
* Remove EC_FLAGS_DEFAULT_OCT.jsing2023-03-086-79/+27
| | | | | | | | | | | | | | The EC code has an amazing array of function pointer hooks, such that a method can hook into almost any operation... and then there is the EC_FLAGS_DEFAULT_OCT flag, which adds a bunch of complex code and #ifdef so you can avoid setting three of those function pointers! Remove EC_FLAGS_DEFAULT_OCT, the now unused flags field from EC_METHOD, along with the various code that was wrapped in EC_FLAGS_DEFAULT_OCT, setting the three function pointers that need to be set in each of the EC_METHODs. ok beck@ tb@
* Call BN_free() instead of BN_clear_free().jsing2023-03-075-22/+22
| | | | | | | BN_clear_free() is a wrapper that calls BN_free() - call BN_free() directly instead. ok tb@