summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/malloc.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-10-30Provide ec_point_from_octets()tb2-3/+35
This is a wrapper that is the reverse of ec_point_to_octets(). It is a bit simpler since EC_POINT_oct2point() expects the point to be allocated already. It also hands back the correctly parsed point conversion form so that we don't have to do this by hand in a few places. ok jsing
2024-10-30Rewrite BN_hex2point()tb1-11/+12
This can do the reverse dance: chain BN_hex2bn() with EC_POINT_bn2point(). ok jsing
2024-10-30Rewrite EC_POINT_point2hex()tb1-34/+10
Instead of doing everything by hand, this can use EC_POINT_point2bn() and chain it with BN_bn2hex(), slashing the number of lines in half. This removes one of the ten remaining "01234567890ABCDEF" strings from libcrypto. Unfortunately, none of the nine others is used in an API that could convert the octet string directly, so we use that ugly detour via a bignum. Still it's better than what was there. ok jsing
2024-10-30Rewrite EC_POINT_point2bn()tb1-17/+11
While it makes little sens to place either one of the uncompressed, the compressed or the hybrid X9.62 octet string encoding of an elliptic curve point into a BIGNUM, it is what this API does. It's ec_point_to_octets() followed by BN_bin2bn(). ok jsing
2024-10-30ec_asn1_group2parameters: some spring cleaningtb1-14/+12
Garbage collect the ok variable and some comments from captain obvious, wrap a long line and tidy up the exit path.
2024-10-30ec_asn1_group2parameters: replace point with generatortb1-4/+4
2024-10-30ec_asn1_group2parameters: mechanically replace ret with parameterstb1-15/+15
2024-10-30Provide ec_point_to_asn1_bit_string()tb1-30/+14
This adds a specialized helper for creating an ASN.1 bit string out of an elliptic curve point (the public key) and use it in i2d_ECPrivateKey(). ok jsing
2024-10-30Provide ec_point_to_asn1_octet_string()tb1-26/+49
This adds a specialized helper for creating an ASN.1 octet string out of an elliptic curve point (the generator). Use this to simplify ec_asn1_group2parameters(). ok jsing
2024-10-30Add a convenience wrapper for EC_POINT_point2oct()tb2-2/+48
EC_POING_point2oct() is annoying to use since its invocation involves two calls: one to determine the space to allocate and one to pass the buffer and perform the actual conversion. Wrap this dance in a helper with the correct signature. ok jsing
2024-10-29Split ec_key_test_point_encoding() into chunks of saner sizetb1-49/+172
2024-10-29eckey_compute_pubkey: don't leak the public keytb1-2/+1
EC_KEY_set_public_key() sets a copy, so it doesn't take ownership and hence pub_key must not be nulled out on success.
2024-10-29ec_asn1_test: point doubling is fine, the leak is elsewheretb1-3/+1
(will be fixed shortly).
2024-10-29Disable point doubling for now, it leaks due to a doc bug.tb1-1/+3
Can't replace it with adding the point to itself since that also leaks (another doc bug). Who would've thought.
2024-10-29ec_asn1: zap an empty linetb1-2/+1
2024-10-28unifdef -m -DCORRECT_PRIV_KEY_PADDING=1 ec_asn1_test.ctb1-9/+1
2024-10-28Enable the tests that depend on correct private key paddingtb1-2/+2
2024-10-28Fix private key encoding in i2d_ECPrivateKey()tb1-31/+40
The private key is a random integer between 1 and order - 1. As such it requires at most as many bytes as the order to encode. SEC 1, Section C.4 is very explicit about padding it to this length: The component privateKey is the private key defined to be the octet string of length [ceil(log_2 n/8)] (where n is the order of the curve) obtained from the unsigned integer via the encoding of Section 2.3.7. Fix this by generalizing a similar fix for field elements. ok jsing
2024-10-28d2i_ECPrivateKey: split public key setting into a helpertb1-36/+41
If the public key is not part of the ECPrivateKey, it needs to be computed. Rather than doing this ad hoc inline, use the function from the ameth that already does this. If it is present, decode it after checking that its unused bits octet is zero. Again use the dedicated setter API to honor an eventual EC_KEY_METHOD. There remains a gross bit reading the point point conversion form out of the first octet of the bit string. This will go away in a later commit. ok jsing
2024-10-28Expose eckey_compute_key() from ec_amethtb2-3/+4
This helper will be needed in a subsequent commit. ok jsing
2024-10-28d2i_ECPrivateKey: split private key setting into a helpertb1-14/+31
Contrary to domain parameters and public key, the private key most be part of the DER. Convert that to a BIGNUM and set it on the EC_KEY. Use the dedicated setter for this (which will possibly call the handler of the EC_KEY_METHOD) rather than doing this by hand. ok jsing
2024-10-28d2i_ECPrivateKey: split parameter setting into a helpertb1-8/+26
In order to decode a private key, the group must be known in some way. Typically, the group is encoded in the EC domain parameters, preferably as a named curve (this is mandatory in PKIX per RFC 5480). However, the group could be absent because the domain parameters are OPTIONAL in the ECPrivateKey SEQUENCE. In that case the code falls back to the group that may already be set on the EC_KEY. Now there is no way to tell whether that group is the right one... In any case. Split this thing out of the body of d2i_ECPrivateKey() to make that function a bit less of an eyesore. ok jsing
2024-10-28Rename the EC_KEY in i2o_ECPublicKey() to ec_keytb1-6/+6
2024-10-28Rename the EC_KEY in i2d_ECPrivateKey() to ec_keytb1-14/+14
2024-10-28ec_print.c: fix includes.tb1-2/+6
It doesn't currently need ec_local.h, but it will soon, so leave it there.
2024-10-28c2sp: run test against openssl/3.4 if it is installedtb1-2/+2
2024-10-27d2i_ECParameters: clean up entry and exittb1-13/+17
2024-10-27d2i_ECParameters: rename a to out_ec_keytb1-7/+7
2024-10-27d2i_ECParameters: rename ret to ec_keytb1-9/+9
2024-10-27i2d_ECParameters: rename a to ec_keytb1-4/+4
2024-10-26{d2i,i2d}_ECParameters() also want a bit of exercisingtb1-1/+28
2024-10-26d2i_ECPrivateKey: move the version setting where it belongstb1-2/+2
2024-10-26d2i_ECPrivateKey: minor cleanup for entry and exit pathtb1-13/+13
Reduces an upcoming diff which is hard enough to review without these distractions.
2024-10-26a and ret aren't great names for EC_KEYstb1-26/+26
2024-10-26Mechanically rename priv_key to ec_privatekeytb1-27/+27
2024-10-26ec_asn1_test: play some silly games to cover a few more code pathstb1-1/+47
2024-10-26Add regress coverage for ec_print.ctb1-2/+889
Of course the four stunning beauties in there aren't printing anything. the hex family converts an elliptic curve point's X9.62 encoding into a hex string (which kind of makes sense, you can print that if you want). Much more astounding is EC_POINT_point2bn() where the X9.62 octet string is interpreted as a BIGNUM. Yes, the bignum's hex digits are the point conversion form followed by the affine coordinate(s) of the elliptic curve point, and yes you can choose between compressed, uncompressed, and hybrid encoding, why do you ask? This doesn't really make any sense whatsoever but of course you can also print that if you really want to. Of course the beloved platinum members of the "gotta try every terrible OpenSSL interface" club had to use and expose this.
2024-10-25Cosmetic tweak to make point2oct and oct2point more symmetrictb1-7/+12
This can't be perfectly symmetric, but the logic is now roughly the same in both these functions.
2024-10-25Use macros describing the intent rather than #if 0tb1-8/+38
2024-10-25ec_asn1: make two helpers statictb1-3/+3
2024-10-25Minor cosmetic tweaks for EC_GROUP_set_seed()tb1-9/+8
No need to guard free() with a NULL check, check explicitly against 0 and rename p to seed.
2024-10-25ec_asn1: fix some NULL misspellingstb1-4/+4
2024-10-25Add regress for {d2i,i2d}_ECPrivateKey() and {o2i,i2o}_ECPublicKey()tb1-1/+1003
Some test cases are disabled since they exercise an upcoming bug fix.
2024-10-24Fix argument names: des_in -> der_in and des_out -> der_outtb2-19/+19
2024-10-24Add missing error check for CBB_init_fixed()tb1-4/+5
CID 511280
2024-10-23ec_point_conversion: cosmeticstb1-4/+4
2024-10-23ec_point_conversion: extend test coverage by translating back thetb1-2/+76
point to an octet string and match with the initial octet string. would have caught the regression found by anton
2024-10-23EC_POINT_point2oct() need to special case the point at infinitytb1-4/+10
This is annoying since it undoes some polishing done before commit and reintroduces an unpleasant asymmetry. found by anton via openssl-ruby tests ok jsing
2024-10-23EC_get_builtin_curves(): the most appropriate name for a list of curves...tb1-5/+5
... is obviously r.
2024-10-23remove duplicate defines; ok tb@jsg3-13/+3