summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2021-12-05libpcap parser uses a memory tracker to only free all objects at the end.Theo de Raadt
this code was slicing up large mallocs with sys/param.h ALIGN(). such a scheme loses the many overflow/damage checking benefits of malloc per object. Change the code to track independent allocations, rather than slicing. ok gnezdo claudio
2021-12-05elf64_checkum->elf64_checksum; adapted from changes by saitoh masanobuJason McIntyre
2021-12-05Simplify DH_check_params a bit.Theo Buehler
It makes no sense to allocate an entire BN_CTX if we only use it to get a single BIGNUM, from which we subtract 1 to compare it to g. We can just use a plain BIGNUM and delete a bunch of lines. ok inoguchi jsing
2021-12-05Add RCS markersTheo Buehler
2021-12-04List subdirectories as a simple list. Avoids a source of many mergeTheo Buehler
conflicts in my work on making much of libcrypto opaque. discussed with jsing
2021-12-04Annotate the structs to be moved to bn_lcl.h in the next bumpTheo Buehler
ok inoguchi jsing
2021-12-04Use BN_is_negative(p) instead of p->neg in one place.Theo Buehler
2021-12-04Add #include "bn_lcl.h" to the files that will soon need it.Theo Buehler
ok inoguchi jsing
2021-12-04Implement the BN_to_montgomery() macro as a functionTheo Buehler
ok inoguchi jsing
2021-12-04Implement the BN_is_negative macro as a functionTheo Buehler
ok inoguchi jsing
2021-12-04Provide function implementations for various BN_* macrosTheo Buehler
BN_abs_is_word, BN_is_{zero,one,word,odd}, BN_one, BN_zero_ex are now implemented as functions for internal use. They will be exposed publicly to replace the macros reaching into BIGNUM in the next bump. ok inoguchi jsing
2021-12-04Provide replacement functions for the BN_{get,set,with}_flags() macros.Theo Buehler
ok inoguchi jsing
2021-12-04Provide replacement functions for the BN_GENCB_set{,_old}() macrosTheo Buehler
The function implementations are necessary to make BIGNUM opaque. They will be used in libcrypto internally until they will replace the macro implementations with the next bump. ok inoguchi jsing
2021-12-04Consolidate {d2i,i2d}_{pr,pu}.cJoel Sing
Currently there are two files for private key ASN.1 (d2i_pr.c, i2d_pr.c) and two files for public key ASN.1 (d2i_pu.c, i2d_pu.c). All of the other ASN.1 code has d2i and i2d in the same per-object file. Consolidate d2i_pr.c/i2d_pr.c into a_pkey.c and consolidate d2i_pu.c/i2d_pu.c into a_pubkey.c before making any further changes to this code. ok tb@
2021-12-04Clean up and refactor server side DHE key exchange.Joel Sing
Provide ssl_kex_generate_dhe_params_auto() which handles DHE key generation based on parameters determined by the specified key bits. Convert the existing DHE auto parameter selection code into a function that just tells us how many key bits to use. Untangle and rework the server side DHE key exchange to use the ssl_kex_* functions. ok inoguchi@ tb@
2021-12-04Move the minimum DHE key size check into ssl_kex_peer_params_dhe()Joel Sing
ok inoguchi@ tb@
2021-12-04Check DH public key in ssl_kex_peer_public_dhe().Joel Sing
Call DH_check_pub_key() after decoding the peer public key - this will be needed for the server DHE key exchange, but also benefits the client. ok inoguchi@ tb@
2021-12-03Replace asn1_tlc_clear and asn1_tlc_clear_nc macros with a function.Joel Sing
Call the replacement asn1_tlc_invalidate() since it does not actually clear the ASN1_TLC. While here, name the ASN1_TLC variables consistently as ctx, remove a pointless comment and simplify ASN1_item_d2i() slightly. ok inoguchi@ tb@
2021-12-03Group and sort includes.Joel Sing
2021-12-03Call asn1_item_ex_d2i() directly from ASN1_item_d2i()Joel Sing
ASN1_item_ex_d2i() is just a wrapper around the internal asn1_item_ex_d2i() function, so call asn1_item_ex_d2i() directly. ok inoguchi@ tb@
2021-12-03Convert ASN1_PCTX_new() to calloc().Joel Sing
Rather than using malloc() and then initialising all struct members to zero values, use calloc(). ok schwarze@ tb@
2021-12-03Use calloc() for X509_CRL_METHOD_new() instead of malloc().Joel Sing
This ensures that if any members are added to this struct, they will be initialised. ok schwarze@ tb@
2021-12-03Rewrite ASN1_STRING_cmp().Joel Sing
This removes nested ifs and uses more sensible variable names. ok schwarze@ tb@
2021-12-03Convert ASN1_STRING_type_new() to calloc().Joel Sing
Rather than using malloc() and then initialising all struct members, use calloc() and only initialise the single non-zero value member. ok schwarze@ tb@
2021-12-03Convert ASN1_OBJECT_new() to calloc().Joel Sing
Rather than using malloc() and then initialising all struct members, use calloc() and only initialise the single non-zero value member. ok schwarze@ tb@
2021-12-03Convert {i2d,d2i}_{,EC_,DSA_,RSA_}PUBKEY{,_bio,_fp}() to templated ASN1Joel Sing
These functions previously used the old ASN1_{d2i,i2d}_{bio,fp}() interfaces. ok inoguchi@ tb@
2021-12-03Use calloc() in EVP_PKEY_meth_new() instead of malloc() and settingTheo Buehler
almost all members to 0. Just set the two things that need setting. ok jsing
2021-12-03Fix EVP_PKEY_{asn1,meth}_copy once and for allTheo Buehler
It is very easy to forget to copy over newly added methods. Everyone working in this corner has run into this. Instead, preserve what needs preserving and use a struct copy, so all methods get copied from src to dest. tweak/ok jsing
2021-12-02bsearch(3): support arrays with more than INT_MAX elementsScott Soule Cheloha
The "lim" variable needs to be a size_t to match nmemb, otherwise we get undefined behavior when nmemb exceeds INT_MAX. Prompted by a blog post by Joshua Bloch: https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html Fixed by Chris Torek a long time ago: https://svnweb.freebsd.org/csrg/lib/libc/stdlib/bsearch.c?revision=51742&view=markup ok millert@
2021-12-01sys/core.h is not needed by these files, therefore sys/param.h isn'tTheo de Raadt
needed for MAXCOMLEN either
2021-12-01we do not need 'struct mbuf; struct rtentry;' to satisfy some ancient unixTheo de Raadt
variant that made a header file mistake. ok jsg
2021-12-01Reduce use of sys/param.h, or annotate the reason why it is neededTheo de Raadt
(pretty much MAXCOMLEN for struct process or struct core), and remove sys/vnode.h where not needed
2021-12-01Use system _ALIGN to reduce the reasons why this uses sys/param.hTheo de Raadt
2021-12-01Remove dead code.Joel Sing
2021-12-01Build libfido2 after all other libraries, as it links against one ofPatrick Wildt
the other libraries, so we have to build those first. Initial report and diff from uaa@ ok anton@ deraadt@ millert@
2021-11-30Add missing const qualifiers in a number of BN_* manuals.Theo Buehler
ok schwarze
2021-11-30last whitespace diff for now.Theo Buehler
2021-11-30KNF for BF_KEYTheo Buehler
2021-11-30Fix some annoying whitespace inconsistencies.Theo Buehler
2021-11-30Provide EVP_CTRL_AEAD_* defines.Theo Buehler
This commit adds generic EVP_CTRL_AEAD_{SET,GET}_TAG and _SET_IVLEN defines and aliases the GCM and CCM versions to those. This is the publicly visible part of OpenSSL's e640fa02005. ok inoguchi jsing
2021-11-30Align ssl_kex_derive_ecdhe_ecp() with ssl_kex_derive_dhe()Theo Buehler
sk is commonly used for a STACK_OF(), so call the shared key simply key. ok jsing
2021-11-30s/ECDHE/ECDH/Joel Sing
If we can provide an EC key that is used, then it is by definition non-ephemeral. ok tb@
2021-11-29Crank the number of rounds of Miller-Rabin from 50 to 64Theo Buehler
for DSA key generation. From Kurt Roeckx, OpenSSL 74ee3796 ok bcook inoguchi jsing
2021-11-29Clean up DH_check_pub_key() and ensure that y^q (mod p) == 1.Theo Buehler
This aligns our behavior with OpenSSL 1.1.1 which includes a mitigation for small subgroup attacks. This did not affect LibreSSL since we do not support X9.42 style parameter files or RFC 5114. The meat of this commit is from Matt Caswell, OpenSSL b128abc3 ok inoguchi jsing
2021-11-29Increase number of iterations in Miller-Rabin checks for DH.Theo Buehler
BN_prime_checks is only to be used for random input. Here, the input isn't random, so increase the number of checks. According to https://eprint.iacr.org/2019/032, 64 rounds is suitable. From Jake Massimo, OpenSSL 1.1.1, af6ce3b4 ok inoguchi jsing
2021-11-29Synchronize DH_check() mostly with OpenSSL 1.1.1 with someTheo Buehler
simplifications and readability tweaks. This ensures in particular that dh->q is suitable if present. Based on work by Stephen Henson and Bernd Edlinger in OpenSSL. Issues with the current implementation found via regression tests in py-cryptography. ok inoguchi jsing
2021-11-29Provide a version of DH_check_params() for internal use.Theo Buehler
Based on the version in OpenSSL 1.1.1l with minor tweaks. ok inoguchi jsing
2021-11-29Provide a number of flags for DH_check and DH_check_pubkeyTheo Buehler
that will be used in subsequent commits. ok inoguchi jsing
2021-11-29First pass of converting ssl_kex.c to opaque DH.Theo Buehler
Assign the result of BN_dup() and BN_bn2bin() to local BIGNUMs, then set the factors and pubkey on the dh using DH_set0_{pqg,key}(). A second pass will be done during the upcoming bump. ok jsing
2021-11-29Hide BIO_s_file_internal() from internal view.Theo Buehler
ok jsing