summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-10-29eckey_compute_pubkey: don't leak the public keyTheo Buehler
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: zap an empty lineTheo Buehler
2024-10-28Fix private key encoding in i2d_ECPrivateKey()Theo Buehler
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 helperTheo Buehler
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_amethTheo Buehler
This helper will be needed in a subsequent commit. ok jsing
2024-10-28d2i_ECPrivateKey: split private key setting into a helperTheo Buehler
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 helperTheo Buehler
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_keyTheo Buehler
2024-10-28Rename the EC_KEY in i2d_ECPrivateKey() to ec_keyTheo Buehler
2024-10-28ec_print.c: fix includes.Theo Buehler
It doesn't currently need ec_local.h, but it will soon, so leave it there.
2024-10-27d2i_ECParameters: clean up entry and exitTheo Buehler
2024-10-27d2i_ECParameters: rename a to out_ec_keyTheo Buehler
2024-10-27d2i_ECParameters: rename ret to ec_keyTheo Buehler
2024-10-27i2d_ECParameters: rename a to ec_keyTheo Buehler
2024-10-26d2i_ECPrivateKey: move the version setting where it belongsTheo Buehler
2024-10-26d2i_ECPrivateKey: minor cleanup for entry and exit pathTheo Buehler
Reduces an upcoming diff which is hard enough to review without these distractions.
2024-10-26a and ret aren't great names for EC_KEYsTheo Buehler
2024-10-26Mechanically rename priv_key to ec_privatekeyTheo Buehler
2024-10-25Cosmetic tweak to make point2oct and oct2point more symmetricTheo Buehler
This can't be perfectly symmetric, but the logic is now roughly the same in both these functions.
2024-10-25ec_asn1: make two helpers staticTheo Buehler
2024-10-25Minor cosmetic tweaks for EC_GROUP_set_seed()Theo Buehler
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 misspellingsTheo Buehler
2024-10-24Fix argument names: des_in -> der_in and des_out -> der_outTheo Buehler
2024-10-24Add missing error check for CBB_init_fixed()Theo Buehler
CID 511280
2024-10-23EC_POINT_point2oct() need to special case the point at infinityTheo Buehler
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...Theo Buehler
... is obviously r.
2024-10-23remove duplicate defines; ok tb@Jonathan Gray
2024-10-22remove duplicate X509v3_asid_add_id_or_range.3 lineJonathan Gray
2024-10-22remove duplicate rcs idJonathan Gray
2024-10-22Move a check for hybrid point encoding into a helper functionTheo Buehler
2024-10-22Rewrite ec_GFp_simple_point2oct() using CBBTheo Buehler
Factor ad-hoc inline code into helper functions. Use CBB and BN_bn2binpad() instead of batshit crazy skip loops and pointer banging. With all this done, the function becomes relatively streamlined and pretty much symmetric with the new oct2point() implementation. ok jsing
2024-10-22Rewrite ec_GFp_simple_oct2point() using CBSTheo Buehler
Transform the spaghetti in here into something more readable. Factor various inline checks into helper functions to make the logic clearer. This is a bit longer but a lot safer and simpler. It accepts exactly the same input as the original version. ok jsing
2024-10-22Start cleaning up oct2point and point2octTheo Buehler
The SEC 1 standard defines various ways of encoding an elliptic curve point as ASN.1 octet string. It's also used for the public key, which isn't an octet string but a bit string for whatever historic reason. The public API is incomplete and inconvenient, so we need to jump through a few hoops to support it and to preserve our own sanity. Split a small helper function out of ec_GFp_simple_point2oct() that checks that a uint8_t represents a valid point conversion form. It supports exactly the four possible variants and helps translating from point_conversion_form_t at the API boundary. Reject the form for the point at infinity since the function has historically done that even for the case that the point actually is the point at infinity. ok jsing
2024-10-22Revert marking EC_GROUP_method_of() and EC_METHOD_get_field_type() unusedTheo Buehler
breaks tree as noted by krw
2024-10-22ecp_oct.c: add missing includesTheo Buehler
2024-10-22Mark EC_GROUP_method_of() and EC_METHOD_get_field_type() as unusedTheo Buehler
ok jsing
2024-10-22Provide and use ec_group_get_field_type()Theo Buehler
All internal uses of EC_METHOD_get_field_type() and EC_GROUP_method_of() are chained together. Implement this as a single API call that takes a group and use it throughout. Gets rid of another eyesore in this part of the tree. Not that there will be a shortage of eyesores anytime soon... ok jsing
2024-10-22Inline a use of EC_GROUP_method_of()Theo Buehler
We can just reach into the group to obtain its EC_GROUP_METHOD. After all ec_local.h has to be in scope. This will permit marking this ugly API as unused internally after the next commit. ok jsing
2024-10-20ec_ameth.c: fix includesTheo Buehler
2024-10-20ec_asn1: add missing includesTheo Buehler
2024-10-20ec_curve: add missing includesTheo Buehler
2024-10-20zap an empty lineTheo Buehler
2024-10-19Make ec EVP_PKEY_CTRL_MD handler match dsa/rsa more closelyTheo Buehler
This makes the thing a bit easier on the eyes and improves greppability. ok joshua jsing
2024-10-19Drop a useless cast in pkey_dsa_ctrl()Theo Buehler
ok joshua jsing
2024-10-19Remove IA32 specific code from cryptlib.c.Joel Sing
Move the IA32 specific code to arch/{amd64,i386}/crypto_cpu_caps.c, rather than polluting cryptlib.c with machine dependent code. A stub version of crypto_cpu_caps_ia32() still remains for now.
2024-10-19Remove unused sparc CPU capability detection code.Joel Sing
This has been unused for a long time - it can be found in the attic if someone wants to clean it up and enable it in the future. ok tb@
2024-10-19EC_GROUP_check(): zap useless commentsTheo Buehler
2024-10-19Move EC_GROUP_check() to ec_lib.cTheo Buehler
EC_GROUP_check() is quite simple. It doesn't need to use its own file.
2024-10-18Simplify EC_get_builtin_curves().Theo Buehler
When determining the minimum of nitems and EC_CURVE_LIST_LENGTH we need neither an extra variable nor a ternary operator.
2024-10-18Use better naming in ec_curve.cTheo Buehler
Rename struct ec_list_element into struct ec_curve. Accordingly, curve_list becomes struct ec_curve ec_curve_list[]. Adjust internal API to match. suggested by jsing