summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* The int_ prefix also leaves the ec_ameth messtb2023-08-121-5/+5
| | | | The prefixes in here are all over the place... This removes one variety.
* Move EC_KEY and EC_KEY_METHOD typedefs to ossl_typ.htb2023-08-111-4/+1
| | | | ok jsing
* Make the bn_rand_interval() API a bit more ergonomictb2023-08-032-4/+4
| | | | | | | | | | | | | | | | | | Provide bn_rand_in_range() which is a slightly tweaked version of what was previously called bn_rand_range(). The way bn_rand_range() is called in libcrypto, the lower bound is always expressible as a word. In fact, most of the time it is 1, the DH code uses a 2, the MR tests in BPSW use 3 and an exceptinally high number appears in the Tonelli-Shanks implementation where we use 32. Converting these lower bounds to BIGNUMs on the call site is annoying so let bn_rand_interval() do that internally and route that through bn_rand_in_range(). This way we can avoid using BN_sub_word(). Adjust the bn_isqrt() test to use bn_rand_in_range() since that's the only caller that uses actual BIGNUMs as lower bounds. ok jsing
* Stop including ecdsa.h and ecdh.h internallytb2023-07-282-4/+2
| | | | | | | | These headers are now reduced to #include <openssl/ec.h> and are provided for compatiblity only. There's no point in using them. At the same time garbage collect the last uses of OPENSSL_NO_{ECDSA,ECDH} in our tree. ok jsing
* Move KDF handling to ECDH_compute_key()tb2023-07-284-16/+18
| | | | | | | | | | In OpenSSL e2285d87, the KDF handling was moved from the compute_key() method into the public API. A consequence of this change is that the ECDH_compute_key() API no longer returns -1 for some errors. Existing checks for <= 0 are safe as are those checking for the exact length as return value, which is all what the ecosystem seems to be doing. ok jsing
* Merge ecdh.h into ec.htb2023-07-281-1/+6
| | | | | | | The remaining two ECDH interfaces are relocated into ec.h. ecdh.h remains. It does nothing but include ec.h. ok jsing
* Merge ecdsa.h into ec.htb2023-07-281-1/+50
| | | | | | | | | Move the remaining ECDSA API into ec.h to match OpenSSL 1.1's interface better. In particular, the EC_KEY sign and verify method accessors are moved to the right header. Whether the rest of the ECDSA stuff belongs there is debatable, but that was upstream's choice. ok jsing
* Tweak EC_GROUP_check_discriminant()tb2023-07-261-28/+28
| | | | | | | | Make the logic and control flow a bit more explicit and use a single extra variable for computing the discriminant. Call it discriminant, not tmp, tmp_1 or tmp_2. ok jsing
* Unindent a big block in EC_GROUP_get_affine_coordinates()tb2023-07-261-32/+34
|
* Introduce and use ec_encode_scalar()tb2023-07-261-43/+48
| | | | | | | | | | | | This introduces two "inverses" of the ec_decode_scalar() function that take a BIGNUM, reduce it modulo p and then encodes it into the curve's field representation. For setting projective coordinates, we need a specialized helper that deals with the Z_is_one optimization that is used to optimize for calculations in standard affine coordinates of the projective plane. This is used for simplifying EC_POINT_set_Jprojective_coordinates() and for cleaning up and streamlining EC_GROUP_set_curve(). ok jsing
* Garbage collect the unused order in check_discriminant()tb2023-07-261-4/+2
| | | | ok jsing
* Streamline check_discriminant()tb2023-07-261-14/+6
| | | | | | Instead of inlining EC_GROUP_get_curve(), we can simply call it... ok jsing
* Introduce ec_decode_scalar()tb2023-07-261-81/+39
| | | | | | | | | This is a helper that decodes a scalar from field-internal representation to a representation as a BIGNUM in the interval [0, p). This simplifies EC_GROUP_get_curve() and EC_POINT_get_Jprojective_coordinates() to a few obvious lines and prepares cleanup in EC_POINT_get_affine_coordinates(). ok jsing
* Use EC_POINT_set_to_infinity() rather than inlining ittb2023-07-261-6/+4
|
* Fix a few more 0/NULL misspellingstb2023-07-251-8/+8
|
* Use [a,b), not [a,b-1] in a commenttb2023-07-251-2/+2
|
* EC_POINT_is_on_curve() error is -1, not 0.tb2023-07-251-2/+2
| | | | ok miod
* Tweak previous. Should have been 60 instead of 64tb2023-07-221-3/+3
|
* Adapt bn_print() for EdDSA key printingtb2023-07-221-7/+40
| | | | | | | | This is essentially a reimplementation of ASN1_buf_print(). The latter was only added for these printing purposes and it will be removed again since nothing uses it. We can then simply remove t_pkey.c in the upcoming bump. ok jsing
* Unbreak the namespace build after a broken mk.conf and tool misfire hadbeck2023-07-073-26/+3
| | | | | | | | me aliasing symbols not in the headers I was procesing. This unbreaks the namespace build so it will pass again ok tb@
* Hide symbols in hkdf, evp, err, ecdsa, and ecbeck2023-07-0713-13/+157
| | | | | | (part 2 of commit) ok jsing@
* Mop up remaining uses of ASN1_bn_print()tb2023-07-071-17/+6
| | | | | | | This removes lots of silly buffers and will allow us to make this API go away. ok jsing
* Convert ecpk_print_explicit_parameters() to bn_printf()tb2023-07-061-34/+8
| | | | | | | This eliminates a few stupid dances the horrible ASN1_bn_print() API required. ok jsing
* don't return in a void functionbcook2023-07-051-2/+2
| | | | ok tb@
* Mop up last uses of ECDHerror() and ECDSAerror()tb2023-07-052-2/+12
| | | | ok jsing
* Rename ecs_local.h into ecdsa_local.htb2023-07-051-2/+2
|
* Drop useless ossl_ prefixestb2023-07-053-15/+15
| | | | discussed with jsing
* Explicit parameter printing can also use get0_order()tb2023-07-031-5/+6
| | | | ok beck jsing
* Convert ossl_ec_key_gen() and EC_KEY_check_key()tb2023-07-031-23/+6
| | | | | | These also get the EC_GROUP_get0_order() treatment ok beck jsing
* Convert EC_GROUP_check() to EC_GROUP_get0_order()tb2023-07-031-10/+3
| | | | ok beck jsing
* Inline two copies of EC_GROUP_order_bits()tb2023-07-031-22/+6
| | | | | | | This code is way more complicated than it needs to be. Simplify. ec_bits() was particularly stupid. ok beck jsing
* Provide internal-only EC_GROUP_get0_order()tb2023-07-032-3/+11
| | | | ok jsing
* Fix return values of ecx methodstb2023-07-021-5/+5
| | | | | | | | | It is hard to get your return values right if you choose them to be a random subset of {-2, ..., 3}. The item_verify() and the digestverify() methods don't return 0 on error, but -1. Here 0 means "failed to verify", obviously. ok jsing
* Fix typo in previoustb2023-07-021-2/+2
|
* Use asprintf() to avoid repetition in string constantstb2023-07-021-6/+13
| | | | | | ... since ASN1_bn_print() is stupid. ok jsing
* Split ECPKParameters_print()tb2023-07-021-121/+150
| | | | | | | | | This function has two entirely independent parts, so instead of a huge if/else just use two functions. In ecpk_print_explicity parameters() do some additional boring cleanup such as switching to actually using the local BN_CTX and shuffling things into a slightly more sensible order. ok jsing
* Simplify ASN1_bn_print() usage in ec/tb2023-07-012-30/+20
| | | | | | | ASN1_bn_print() doesn't print anything if the BIGNUM passed in is NULL. Also simplify the handling of the point conversion form of the generator. ok jsing
* whitespacetb2023-06-301-2/+2
|
* Remove some dead code from ECPKParameters_print()tb2023-06-271-31/+6
| | | | | | | This code is unreachable since binary curve support was removed. There is a lot more to clean up in here... ok jsing
* Remove the now unused poly[] from EC_GROUPtb2023-06-271-15/+2
| | | | | | | This was needed for defining the multiplication over binary fields. Since that code is gone, this is no longer needed. ok jsing
* Simplify EC_GROUP_get_basis_type()tb2023-06-271-18/+2
| | | | | | | | The remaining EC_METHODs in libcrypto all have a field type of NID_X9_62_prime_field, so this function always returns 0. Make that more obvious. ok jsing
* Stop including ech_local.htb2023-06-251-2/+1
|
* Remove prototypes for EC_KEY_{get,insert}_key_method_data()tb2023-06-251-8/+1
| | | | These were accidentally left behind in a previous commit.
* Move ecdh_KDF_X9_63() to ec_local.htb2023-06-251-1/+7
| | | | | In anticipation of merging ecdh/ and ecdsa/ into ec/, move the last remaining thing in ech_local.h where it will soon belong.
* Remove EC_EXTRA_DATAtb2023-06-254-230/+4
| | | | | | | | | | | With the ecdh_check() and ecdsa_check() abominations gone, we can finally get rid of EC_EXTRA_DATA and EC_KEY_{get,insert}_key_method_data(). The EC_EX_DATA_*() handlers, (which fortunately have always had "'package' level visibility") join the ride to the great bit bucket in the sky. Thanks to op for making this possible. ok jsing
* ec_local.h: move ec_group_simple_order_bits down a bittb2023-06-251-3/+2
|
* Remove precompute_mult/have_precompute_mult from EC_METHOD.jsing2023-06-242-26/+4
| | | | | | | These are no longer in use - stub EC_GROUP_precompute_mult() and EC_GROUP_have_precompute_mult() to match their existing behaviour. ok tb@
* 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