summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-05-12Reduce the number of SHA-512 C implementations from three to one.Joel Sing
We currently have three C implementations for SHA-512 - a version that is optimised for CPUs with minimal registers (specifically i386), a regular implementation and a semi-unrolled implementation. Testing on a ~15 year old i386 CPU, the fastest version is actually the semi-unrolled version (not to mention that we still currently have an i586 assembly implementation that is used on i386 instead...). More decent architectures do not seem to care between the regular and semi-unrolled version, presumably since they are effectively doing the same thing in hardware during execution. Remove all except the semi-unrolled version. ok tb@
2023-05-12primility -> primalityJonathan Gray
ok tb@
2023-05-12Be a bit more precise on how s2i_ASN1_OCTET_STRING handles colonsTheo Buehler
2023-05-11Retguard addition in commit 72pYktDvmJhq7OyF was based on the understandingPhilip Guenther
that the removal of the off_t padding, amd64 syscalls no longer passed a 7th or later argument. We overlooked that syscall(2) bumps the arg count by one, so six argument calls like SYS_sysctl still pass an argument on the stack. So, repush the 7th argument so it's at the expected stack offset after the retguard register is pushed. problem reported and ok bluhm@
2023-05-11tls_verify.c: give up on variable alignment in this fileTheo Buehler
The previous commit resulted in misalignment, which impacts my OCD worse than no alignment at all. Alignment wasn't consistently done in this file anyway. op tells me it won't affect current efforts in reducing the diff.
2023-05-11Document recent changes in primality testingTheo Buehler
With input from beck and jsing
2023-05-10Use is_pseudoprime instead of is_prime in bn_bpsw.cTheo Buehler
This is more accurate and improves readability a bit. Apart from a comment tweak this is sed + knfmt (which resulted in four wrapped lines). Discussed with beck and jsing
2023-05-10switch two ASN1_STRING_data() to ASN1_STRING_get0_data()Omar Polo
and while here mark as const data. This diff is actually from gilles@, in OpenSMTPD-portable bundled libtls. ok tb@, jsing@
2023-05-10Add Miller-Rabin test for random bases to BPSWTheo Buehler
The behavior of the BPSW primality test for numbers > 2^64 is not very well understood. While there is no known composite that passes the test, there are heuristics that indicate that there are likely infinitely many. Therefore it seems appropriate to harden the test. Having a settable number of MR rounds before doing a version of BPSW is also the approach taken by Go's primality check in math/big. This adds a new implementation of the old MR test that runs before running the strong Lucas test. I like to imagine that it's slightly cleaner code. We're effectively at about twice the cost of what we had a year ago. In addition, it adds some non-determinism in case there actually are false positives for the BPSW test. The implementation is straightforward. It could easily be tweaked to use the additional gcds in the "enhanced" MR test of FIPS 186-5, but as long as we are only going to throw away the additional info, that's not worth much. This is a first step towards incorporating some of the considerations in "A performant misuse-resistant API for Primality Testing" by Massimo and Paterson. Further work will happen in tree. In particular, there are plans to crank the number of Miller-Rabin tests considerably so as to have a guaranteed baseline. The manual will be updated shortly. positive feedback beck ok jsing
2023-05-10As mmap(2) is no longer a LOCK syscall, do away with the extraOtto Moerbeek
unlock-lock dance it serves no real purpose any more. Confirmed by a small performance increase in tests. ok @tb
2023-05-09Make failure mode of EVP_AEAD_CTX_new() more explicitTheo Buehler
Pointed out and ok by dlg
2023-05-09bn_exp: also special case -1 modulusTheo Buehler
Anything taken to the power of 0 is 1, and then reduced mod 1 or mod -1 it will be 0. If "anything" includes 0 or not is a matter of convention, but it should not depend on the sign of the modulus... Reported by Guido Vranken ok jsing (who had the same diff)
2023-05-09Rewrite BN_bn2hex() using CBB/CBS.Joel Sing
ok tb@
2023-05-09Rewrite BN_bn2dec() using CBB/CBS.Joel Sing
ok tb@
2023-05-08Rename the other_ctx in X509_STORE_CTX into trustedTheo Buehler
The other_ctx is a strong contender for the worst name of a struct member in OpenSSL. It's a void * member whose only purpose ever was to be set to a STACK_OF(X509) * via X509_STORE_CTX_trusted_stack() (yes, this is obviously a setter, why do you ask?) and then to be used by the get_issuer() callback (which of course isn't there to find any old issuer, but only to look for issuers among the 'trusted' certs). Anyway, we may want to rename untrusted into intermediates and trusted into roots later on, but for now let's match the lovely public API. While there rename get_issuer_sk() into get_trusted_issuer() which is a more accurate and slightly less silly name. ok jsing
2023-05-08Add RCS tagTheo Buehler
2023-05-08X509_verify_cert(): Garbage collect the unused roots variableTheo Buehler
roots was used to store the trusted stack or pull the roots out of the X509_STORE before beck unmooned Ethel in x509_vfy.c r1.88. Since then this variable is effectively unused. It seems the STACK_OF(3) madness is too complicated for -Wunused-but-set-variable to notice. ok miod
2023-05-08Avoid trailing whitespace in extension printingTheo Buehler
If an extension is non-critical, X509V3_extensions_print() would leave trailing whitespace. This can be trivially avoided. ok miod
2023-05-07Recommit -Wshadow now that the warning on BIG_ENDIAN is fixedTheo Buehler
2023-05-07xts128 mode: avoid two -Wshadow warnings in the BIG_ENDIAN code path.Theo Buehler
Found by, compile tested & ok bluhm.
2023-05-07Backout -Wshadow, it breaks build on powerpc64.Alexander Bluhm
2023-05-07Remove a misplaced empty lineTheo Buehler
2023-05-06Regen cert.pemTheo Buehler
This drops a few certs per the CA's request and TrustCor because of drama. Certainly, a new CA, is added as well as new certs for DigiCert, SECOM and E-Tugra. Unizeto still haven't fixed one of their certs and we still don't want the alternative Firmaprofesional with sha1WithRSAEncryption. ok sthen
2023-05-05Use -Wshadow with clangTheo Buehler
ok jsing (a very long time ago)
2023-05-05Fix error handling in tls_check_common_name()Theo Buehler
A calloc failure should be a fatal error, so make it return -1. Also switch the default rv to -1 and distinguish error cases with acceptable situations with goto err/goto done. ok jsing
2023-05-05Salt shares the blame of the continued existence of the X9.31 padding modeTheo Buehler
2023-05-05Reinstate documentation of RSA_X931_PADDINGTheo Buehler
2023-05-05Add back support for RSA_X931_PADDINGTheo Buehler
This makes the custom stalt stack work again. Tested by robert as part of a larger diff ok jsing
2023-05-05Link rsa_x931.c to buildTheo Buehler
2023-05-05Bring back the X9.31 padding helpersTheo Buehler
Nothing should be using this anymore, except that salt decided to use it in its home-cooked protocol, which already had its share of issues. Hopefully the efforts to switch salt to something more reasonable and standardized like mTLS will succeed sooner rather than later. tested as part of a larger patch by robert ok jsing
2023-05-04Rewrite ECParameters_dup()Theo Buehler
This should leak slightly less than the direct expansion of ASN1_dup_of(). Use freezero() since the DER could contain a private key. ok jsing
2023-05-04Use size_t instead of int in EC_POINT_point2oct()Theo Buehler
An int would be perfectly sufficient for this, but then again there would be fewer traps. ok jsing
2023-05-04Fix line wrappingTheo Buehler
2023-05-04Fix function name in doc commentTheo Buehler
2023-05-03Revert utf-8 fix for X509_NAME_get_index_by_NID to avoid libtlsBob Beck
regress for the moment. this will come back after we rethink the failure versus not there case. ok tb@ jsing@
2023-05-03Bring back length check tb ok'ed and I managed to remove whileBob Beck
changing tests. ok tb@
2023-05-03Fix a few KNF/whitespace issuesTheo Buehler
2023-05-02Change X509_NAME_get_index_by[NID|OBJ] to be safer.Bob Beck
Currently these functions return raw ASN1_STRING bytes as a C string and ignore the encoding in a "hold my beer I am a toolkit not a functioning API surely it's just for testing and you'd never send nasty bytes" kind of way. Sadly some callers seem to use them to fetch things liks subject name components for comparisons, and often just use the result as a C string. Instead, encode the resulting bytes as UTF-8 so it is something like "text", Add a failure case if the length provided is inadequate or if the resulting text would contain an nul byte. based on boringssl. nits by dlg@ ok tb@
2023-05-02Rename P into generatorTheo Buehler
ok jsing
2023-05-02Simplify EC_GROUP_new_by_curve_name()Theo Buehler
Pull the setting of the name a.k.a. nid into ec_group_new_from_data(). This way, we can return early on finding the nid in the curve_list[]. This also avoids a silly bug where a bogus ERR_R_UNKNOWN_BUG is pushed onto the error stack when ec_group_new_from_data() failed. While there rework the exit path of ec_group_new_from_data() a bit. Instead of an ok variable we can use an additional pointer to keep track of the return value and free the EC_GROUP unconditionally. ok jsing
2023-05-02Style tweaks for SMIME_write_PKCS7()Theo Buehler
Initialize the mdalgs stack at the top and test and assign for ctype_nid. Use an empty line to separate variable declarations from the actual code and zap an extra empty line. ok jsing
2023-05-02Unwrap a lineTheo Buehler
2023-05-02Sync with upstreamTheo Buehler
Update some links in the README, remove a duplicate word in a zlib.h doc comment. The only code change is guarded by #if defined(_WIN32).
2023-05-01stray whitespaceTheo Buehler
2023-05-01Add a missing pair of braces.Theo Buehler
2023-05-01Use uppercase for the CURVE_LIST_LENGTH macroTheo Buehler
2023-05-01Consistently use lowercase hex digits for curve parametersTheo Buehler
2023-05-01Now that we have C99 initializers, garbage collect some commentsTheo Buehler
2023-05-01Rework the curve list to use actual structs instead of a customTheo Buehler
serialized format. ok jsing
2023-05-01Drop the now unnecessary and unused field_type from the curve dataTheo Buehler
ok jsing