summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
* Sweep over EC_KEY_copy()tb2024-11-081-32/+28
| | | | | | | | | | | | | | | | | This is a special snowflake. Its logic is such that it only overwrites things on the target that are available in the source. So if the source has no group (yes, that's possible), the destination's group will remain. Even better: if you copy a public key over what was previously a private key, the private scalar will remain. That's almost never going to result in a valid key. If you copy from a larger group to a smaller group the private scalar will most likely be out of range [1, order). Use dup functions instead of reimplementing badly and add a snarky comment courtesy of beck to one of those silly const annotations (there's a small addendum by me). ok beck jsing
* Clean up EC_KEY_freetb2024-11-081-14/+11
| | | | | | | | r is a silly name for an EC_KEY and it is silly to assign the refcount to a variable i (short for uninspired) when you can check the function return directly. Tweak sizeof in freezero to jsing's liking. ok beck jsing
* Clean up EC_KEY_new_by_curve_name()tb2024-11-081-14/+20
| | | | | | | | Use a better variable name, simpler error handling. This could be simplified further if we decide to have an ec_key_set0_group() that avoids a copy. ok beck jsing
* List CMAC_CTX_copy(3) in the SYNOPSIS. It was alreadyschwarze2024-11-081-2/+7
| | | | mentioned in NAME and described in DESCRIPTION and RETURN VALUES.
* Provide a replacement assembly implementation for SHA-256 on amd64.jsing2024-11-083-6/+330
| | | | | | | | | | | | | Replace the perlasm generated SHA-256 assembly implementation with one that is actually readable. Call the assembly implementation from a C wrapper that can, in the future, dispatch to alternate implementations. Performance is similar (or even better) on modern CPUs, while somewhat slower on older CPUs (this is in part due to the wrapper, the impact of which is more noticable with small block sizes). Thanks to gkoehler@ and tb@ for testing. ok tb@
* Rewrite bn2binpad.jsing2024-11-081-58/+44
| | | | | | | | | | | | | | | Rewrite bn2binpad, removing some OpenSSL specific behaviour and unnecessary complexity. Our BN_num_bytes() does not return bogus lengths, so we don't need to see if things work out with nominated outputs. Swipe away some endianness_t, but continue to ignore negatives and don't dare give away padded zeroes. Implement a more readable constant time conversion. In particular, the little endian is the less common use case, which we can implement by reversing the padded output in place, rather than complicating all of the conversion code. ok beck@ tb@
* Add regress coverage for the size_t constant time comparisions.jsing2024-11-081-26/+120
|
* Provide constant time comparison functions for size_t.jsing2024-11-081-1/+69
| | | | | | These will be used in an upcoming change. ok beck@ tb@
* Relocate ECParameters_dup() to ec_asn1tb2024-11-082-24/+24
| | | | | | | | | jsing rightly points out that this has nothing to do with ASN.1, but ec_lib.c has no EC_KEY knowledge otherwise (it's about groups and points) and moving it to ec_key.c is also not satisfactory since the weird d2i/i2d for ECParameters don't belong there either. no objection from jsing
* Replace aarch64 CPU capabilities detection code.jsing2024-11-086-261/+114
| | | | | | | | | | | | Replace the aarch64 CPU detection code with a version that parses ISAR0, avoiding signal handling and SIGILL. This gets ISAR0 via sysctl(), but this can be adapted to other mechanisms for other platforms (or alternatively the same can be achieved via HWCAP). This now follows the same naming/design as used by amd64 and i386, hence define HAVE_CRYPTO_CPU_CAPS_INIT for aarch64. ok kettenis@ tb@
* ec_asn1_test: remove extra parenstb2024-11-081-4/+4
|
* Rename EC_YBIT to EC_POINT_YBITtb2024-11-081-6/+6
|
* Ugh. Don't return the group after freeing ittb2024-11-081-2/+2
| | | | CID 514612
* document EVP_PKEY_CTRL_SET_MAC_KEY for CMACschwarze2024-11-071-2/+16
|
* document EVP_PKEY_CTRL_CIPHER, providing a bit of contextschwarze2024-11-061-2/+33
|
* About a year ago, the obsolete function EVP_Cipher(3) was moved out ofschwarze2024-11-061-5/+5
| | | | | the important manual page EVP_EncryptInit(3). Belatedly adjust some cross references.
* EC_GROUP_set_seed(): flip order of seed and len null checkstb2024-11-061-2/+2
| | | | requested by jsing
* Treat the curls in EC_GROUP_dup() with a flatirontb2024-11-061-9/+17
| | | | | | | This was about as unreadable as four lines of code doing a trivial thing can get... ok jsing
* Clean up EC_GROUP_copy()tb2024-11-061-27/+15
| | | | | | | | | | | | | | | | | | | Switch from artistic free reinterpretations of public API in the same file to calling the real thing if possible. This means that we need to copy the group's coefficients first instead of last, so that we can call EC_GROUP_set_generator() to set - yes - all three of generator, order, and cofactor of the group. However, we may not have a generator yet since for some reason it is an optional field and some code relies on that. In that case simply copy over order and cofactor and punt on sanity checking for now (since this API never did that anyway). Finally set the seed using EC_GROUP_set_seed() instead of using a custom reimplementation. ok jsing
* Switch EC_GROUP_new() to calloc()tb2024-11-061-21/+20
| | | | | | | | Use a single cleanup path, use calloc rather than setting several members to 0/NULL. This has the side effect that finished can be called even when init() wasn't called, but this isn't an issue with our EC_GROUP_METHODs. ok jsing
* Toss tedu's cleanse into crypto_memory.ctb2024-11-062-9/+9
|
* add an empty line between license and #include linestb2024-11-061-1/+2
|
* Rename malloc-wrapper.c to crypto_memory.ctb2024-11-062-3/+3
| | | | | | | | | Apparently it's important that five trivial one-line wrappers remain in a file with the ISC license. So instead of cleaning the root directory of our favorite pigsty further by squashing all the useless legacy garbage into a single file, rename the oddly-named malloc-wrapper.c into crypto_memory.c. discussed with beck, jsing
* bn_convert: avoid a zero-sized allocationtb2024-11-051-2/+2
|
* Rename cpt_err.c into crypto_err.ctb2024-11-052-3/+3
| | | | | | | It is a bit sad, because cpt is such an apt abbreviation for crypto that everybody immediately understands. discussed with jsing
* Relocate FIPS stubs to crpyto_legacy.ctb2024-11-053-80/+20
| | | | discussed with jsing
* CRYPTO_mem_ctrl() is also relocated to crypto_legacy.ctb2024-11-053-122/+9
| | | | discussed with jsing
* Move OPENSSL_cleanse() to crypto_legacy()tb2024-11-053-15/+9
| | | | | | The correct spelling is explicit_bzero() and it doesn't need its own file. discussed with jsing
* Fold cversion.c into crypto_legacy.ctb2024-11-053-119/+57
| | | | discussed with jsing
* Rename cryptlib.c into crypto_legacy.ctb2024-11-052-3/+3
| | | | discussed with jsing
* crypto_local.h: add comment to #endiftb2024-11-051-2/+2
|
* Move cryptlib.h to crypto_local.htb2024-11-056-158/+28
| | | | discussed with jsing
* ec_asn1_test: remove debug leftover that broke the build on Windowstb2024-11-051-3/+1
|
* EC_POINT_is_at_infinity() returns a booleantb2024-11-053-15/+15
| | | | | | | | | This may have been different at some point in the past, but it may also have been a confusion with EC_POINT_is_on_curve() which, like any great API with a name implying a boolean return, actually has three possible return values. ok jsing
* cryptlib.h: adjust header guard for upcoming surgerytb2024-11-0514-16/+16
| | | | | | | | It is gross that an internal detail leaked into a public header, but, hey, it's openssl. No hack is too terrible to appear in this library. opensslconf.h needs major pruning but the day that happens is not today. ok jsing
* crypto_local.h is empty, so cryptlib.c doesn't need it right now.tb2024-11-041-2/+1
|
* Rewrite EC_POINT_new() and EC_POINT_dup()tb2024-11-041-27/+34
| | | | | | | | Like most of the code in this file that hasn't been overhauled, these are just terrible. As jsing points out, we will need to ensure that finish() works on a not fully initialized point. That's currently safe. ok jsing
* ec tests: allow linking against eopenssltb2024-11-042-3/+16
|
* affine coordinates: the intention was to move the check, not to copy it...tb2024-11-031-6/+1
| | | | | So... zap the now redundant check. Should have been committed along with ec_lib.c -r1.77
* Move point at infinity check to API boundarytb2024-11-031-2/+7
| | | | | | | | Since we only consider standard affine coordinates, the point at infinity must be excluded. Check at the API boundary that the point isn't the point at infinity rather than hiding this check somewhere in a method. ok jsing
* Add regress coverage for BN_bn2binpad() and BN_bn2lebinpad().jsing2024-11-031-3/+137
|
* Add some additional BN conversion test cases.jsing2024-11-031-3/+21
|
* d2i_ECPKParameters(): unify return statement with rest of filetb2024-11-021-2/+3
|
* netcat: drop caddr_t cast. It's not needed and not portable.tb2024-11-021-2/+2
| | | | From Jonas 'Sortie' Termansen
* ec_convert: remove _OCT also from the macro namestb2024-11-021-24/+24
|
* Fix includes in ec_lib and ecp_smpltb2024-11-022-2/+11
|
* Merge compressed coordinate setting back into ecp_smpl and ec_libtb2024-11-025-286/+140
| | | | The reason these were in separate files was FIPS. Not our problem.
* ec_asn1_test: I somehow managed to commit the version without freezero...tb2024-11-021-3/+4
|
* Assert assumption on CRYPTO_THREADIDtb2024-11-021-1/+2
| | | | | | | | This type has been opaque for a while, and nobody should be able to call this function with id != NULL. If they do, we want to know and it should be noisy. suggested by/ok jsing
* Rewrite/clean up ec_GFp_simple_set_compressed_coordinates()tb2024-11-021-62/+48
| | | | | | | | | | | | | | The biggest change here is that the computation is now performed in the Montgomery domain if we have a Montgomery curve. This avoids constant checking whether need to use plain field operations or whether we can use curve-specific ones. Use a few better variable names and stop attempting to figure out whether the operation failed due to an error in BN_mod_sqrt() or a bad point. All in all this only shaves off 10 lines, but it is astounding what a few tweaks can do to code that looked like Rome in 455 AD. with/ok jsing