summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/recallocarray.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-10-19EC_GROUP_check(): zap useless commentstb1-4/+3
2024-10-19Move EC_GROUP_check() to ec_lib.ctb3-115/+57
EC_GROUP_check() is quite simple. It doesn't need to use its own file.
2024-10-18ec_asn1_test: simplify previoustb1-7/+4
2024-10-18ec_asn1_test: call EC_GROUP_check() for the builtin curvestb2-59/+13
This makes the internal curve test in ectest.c superfluous. Also fix a logic error.
2024-10-18Simplify EC_get_builtin_curves().tb1-4/+5
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.ctb1-33/+33
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
2024-10-18ec_asn1_test: adjust for rejection of non-builtin curve parameterstb1-14/+2
2024-10-18Enforce that EC Parameters correspond to a builtin curvetb3-3/+227
EC parameters are very general. While there are some minimal sanity checks, for the parameters due to DoS risks found in the last decade, the elliptic curve code is poorly written and a target rich environment for NULL dereferences, busy loops, expensive computations and whatever other nastiness you can think of. It is not too hard to come up with parameters that reach very ugly code. While we have removed for the worst of it (the "fast" nist code and GF2m come to mind), the code very much resembles the Augean Stables. Unfortunately, curve parameters are still in use - even mandatory in some contexts - for example in machine-readable travel documents signed by ICAO country signing certification authorities (see ICAO Doc 9303). To avoid many of these DoS vectors, start enforcing that we know what the curve parameters are about, namely that they correspond to a builtin curve. This way we know that the parameters are at least as good as the standards we implement and checking this is cheap: Translate curve parameters into the ad hoc representation in the builtin curve code and check there's a match. That's very cheap since most curves are distinguished by cofactor and parameter length and we need to use an actual parameter comparison for at most half a dozen curves, usually only one or two. ok jsing
2024-10-18Remove now unused x86cpuid.pl.jsing1-153/+0
2024-10-18Provide crypto_cpu_caps_init() for i386.jsing3-10/+120
This is the same CPU capabilities code that is now used for amd64. Like amd64 we now only populate OPENSSL_ia32cap_P with bits used by perlasm. Discussed with tb@
2024-10-18Remove now unused x86_64cpuid.pl.jsing1-147/+0
2024-10-18Provide crypto_cpu_caps_init() for amd64.jsing4-11/+126
This is a CPU capability detection implementation in C, with minimal inline assembly (for cpuid and xgetbv). This replaces the assembly mess generated by x86_64cpuid.pl. Rather than populating OPENSSL_ia32cap_P directly with CPUID output, just set the bits that the remaining perlasm checks (namely AESNI, AVX, FXSR, INTEL, HT, MMX, PCLMUL, SSE, SSE2 and SSSE3). ok joshua@ tb@
2024-10-18Inline last use of OPENSSL_load_builtin_modules()tb4-77/+6
This used to be a trivial wrapper of the ASN1_add_oid_module() horror. It's no longer exported, so it can go away. It moves from the terribly named file conf_mall.c to the equally terribly named file conf_sap.c. I have no idea what mall and sap are supposed to mean in this context.
2024-10-18Move EC_GROUP_new_curve_GFp() into ec_lib.ctb3-99/+23
Another single-function file goes away.
2024-10-18Merge EC_GROUP_new_curve_GFp() with ec_group_new_curve()tb1-12/+5
The latter was used for EC_GROUP_new_curve_GF2m() and is now pointless. ok jsing
2024-10-18ec_asn1_test: add secp256k1.mtb1-10/+81
2024-10-18ec_asn1_test: remove last hardcoded wei25519 remnanttb1-4/+3
2024-10-18ec_asn1_test: test Wei25519.2 and Wei25519.-3 as welltb1-37/+163
Covers a few more corner cases in the elliptic curve code.
2024-10-18ec_asn1_test: clean up & refactor; test Wei25519 with simple methodtb1-109/+189
2024-10-17Split ec_asn1_parameters2group() into digestible piecestb1-96/+144
This becomes a simple wrapper function that currently does three checks: 1. ensure the fieldID is for a prime field 2. check that the purported prime is of reasonable size, extract and set curve coefficients and point conversion form 3. extract and set generator, order, cofactor and seed. Sanity checks such as the Hasse bound are dealt with in the EC_GROUP API, so need not be repeated here. They will become redundant once we enforce that the parameters represent a builtin curve anyway. ok jsing
2024-10-17Provide crypto_cpu_caps_init() as a CPU capability detection entry point.jsing3-5/+18
This can be overridden on a per-architecture basis. The default version calls OPENSSL_cpuid_setup(), which will be eventually replaced/removed. ok joshua@ tb@
2024-10-17Remove run once code from OPENSSL_cpuid_setup().jsing1-5/+1
OPENSSL_cpuid_setup() is no longer exported and is now only ever run under pthread_once(). ok joshua@ tb@
2024-10-17libssl: rework cert signature security leveltb1-24/+28
This switches to using the X509_get_signature_info() API instead of hand rolling a part of it. This is slightly tangly since the security level API is strange. In particular, some failures are passed to the security level callback so that applications can override them. This makes the security level API handle RSA-PSS and EdDSA certificates correctly and the handshake with such can progress a bit further. Of note, we check that the certs are actually suitable for use in TLS per RFC 8446 contrary to what OpenSSL does. ok beck jsing
2024-10-16EC ASN.1: add reminder that the simple method might also want testingtb1-1/+5
2024-10-16Implement Wei25519 to exercise some more elliptic curve codetb1-1/+284
This provides a non-trivial non-builtin curve that is unlikely to ever become a builtin curve. This exercises the cofactor guessing code and and ensures that things work as far as they can with a custom OID. The main reason for adding it is to have a "real-world" example for an upcoming check that EC parameters represent a builtin curve.
2024-10-15rust-openssl: set resolver="2" for workspacetb1-0/+1
silences an annoying warning
2024-10-15Unindent error check in EC_GROUP_set_generator()tb1-5/+5
2024-10-15Switch ec_asn1_group2parameters() to get0_{order,cofactor}()tb1-11/+14
These are more ergonomic, result in more readable code, avoid a copy and we no longer ignore a possible memory allocation error due to API misdesign and bad code. ok jsing
2024-10-15Provide EC_GROUP_get0_cofactor() for internal usetb2-2/+9
While this is public API in OpenSSL, there are no plans to expose it. ok jsing
2024-10-14Make NULL checks in ec_asn1_group2curve() explicittb1-3/+5
2024-10-14Extend ec_asn1_test to check for correct curve coefficient encodingtb1-5/+50
2024-10-14Fix field element encoding for elliptic curve coefficientstb1-45/+36
SEC 1, section 2.3.5, is explicit that the encoding of an element of the field of definition for an elliptic curve needs to be a zero-padded octet string whose length matches the byte size of the field's degree. So use BN_bn2binpad() to fix this. Factor things into a simple helper to avoid copy-pasting. This gets rid of some of the most grotesque code in this file. ok jsing
2024-10-14Drop an obvious comment and fix indent for setting the seedtb1-4/+3
Also remove a pointless cast. ok jsing
2024-10-14In ec_asn1_group2curve() rename ok to ret, per usualtb1-4/+4
ok jsing
2024-10-13byt -> but; ok tb@jsg1-3/+3
2024-10-12Exercise the EC parameters code a bit moretb1-1/+103
Ensure all builtin curves can be roundtripped through DER as named curves, via explicit parameterization, using uncompressed, compressed and hybrid point formats.
2024-10-12Remove unnecessary str variable in ssl_stat.ctb1-427/+208
Drop about 1/4 of the lines in here by avoiding the use of a variable. For some reason the API in this file made me go listen to Pow R. Toc H. All of a sudden the lyrics made sense. I should probably be worried. ok beck jsing
2024-10-11Use a and b for the curve coefficientstb1-10/+11
No idea how anyone would think that tmp_1 and tmp_2 are better suited for this. ok jsing
2024-10-11Clean up ec_asn1_group2fieldid()tb1-32/+28
This drops some unnecessary freeing that was turned into a double free reachable via public API in OpenSSL 1.1. Other than that it unindents code and uses better variable names. ok jsing
2024-10-11Fix a long-standing bug in ec_asn1_group2pkparameters()tb1-2/+2
Only check for the OPENSSL_EC_NAMED_CURVE being set to treat the curve parameters as named curve parameters. ok jsing
2024-10-11Use defines for the CHOICE variants of ECPKPARAMETERStb1-7/+10
ok jsing
2024-10-11Remove NULL check in ec_asn1_pkparameters2group()tb1-5/+1
The callers already ensure that params != NULL. ok jsing
2024-10-11Use better variable names in ec_asn1_pkparameters2group()tb1-10/+13
ok jsing
2024-10-11First cleanup pass over ec_asn1_group2pkparameters()tb1-27/+25
Use better variable names and do things in a slightly more sensible order. This way the code becomes almost self-documenting. ok jsing
2024-10-11err.c: zap stray spacetb1-2/+2
2024-10-11Apply some style(9) and tidy some comments.jsing1-62/+73
2024-10-11Remove pointless locking from err_build_SYS_str_reasons().jsing1-20/+2
err_build_SYS_str_reasons() is only called during initialisation, under pthread_once(). As such, there is no need to grab CRYPTO_LOCK_ERR or check for reentrant calls. ok tb@
2024-10-11Convert err_clear_data() and err_clear() from macros to functions.jsing1-23/+25
ok tb@
2024-10-11Remove unused typedef for ERR_FNS.jsing1-3/+1
2024-10-11Add err_ prefix to build_SYS_str_reasons().jsing1-3/+3