summaryrefslogtreecommitdiff
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-03-29man pages: add missing commas in enumerationsnaddy3-9/+9
2022-03-29Bound cofactor in EC_GROUP_set_generator()tb1-1/+7
Instead of bounding only bounding the group order, also bound the cofactor using Hasse's theorem. This could probably be made a lot tighter since all curves of cryptographic interest have small cofactors, but for now this is good enough. A timeout found by oss-fuzz creates a "group" with insane parameters over a 40-bit field: the order is 14464, and the cofactor has 4196223 bits (which is obviously impossible by Hasse's theorem). These led to running an expensive loop in ec_GFp_simple_mul_ct() millions of times. Fixes oss-fuzz #46056 Diagnosed and fix joint with jsing ok inoguchi jsing (previous version)
2022-03-29Do not zero cofactor on ec_guess_cofactor() successtb1-2/+6
The cofactor we tried to calculate should only be zeroed if we failed to compute it. ok inoguchi jsing
2022-03-29Zap trailing whitespacetb1-46/+46
2022-03-28Change internal functions to static in openssl(1) pkcs12inoguchi1-24/+30
ok tb@
2022-03-28Remove unused function cert_load in openssl(1) pkcs12inoguchi1-19/+1
ok tb@
2022-03-28Remove extra 'or'claudio1-3/+2
OK tb@
2022-03-27Check EVP_Digest* functions return value in openssl(1) tsinoguchi1-5/+16
Move up md_ctx and add EVP_MD_CTX_free under the 'err:' label. CID 149810 comment and ok jsing@
2022-03-26name constraints: be more careful with NULstb2-12/+25
An IA5STRING is a Pascal string that can have embedded NULs and is not NUL terminated (except that for legacy reasons it happens to be). Instead of taking the strlen(), use the already known ASN.1 length and use strndup() instead of strdup() to generate NUL terminated strings after some existing code has checked that there are no embedded NULs. In v2i_GENERAL_NAME_ex() use %.*s to print the bytes. This is not optimal and might be switched to using strvis() later. ok beck inoguchi jsing
2022-03-26Clean up {dtls1,ssl3}_read_bytes()jsing2-200/+166
Now that {dtls1,ssl3}_read_bytes() have been refactored, do a clean up pass - this cleans up various parts of the code and reduces differences between these two functions. ok = 1; *(&(ok)) tb@ ok inoguchi@
2022-03-26Remove the minimum record length checks from dtls1_read_bytes()jsing1-32/+1
The code that handles each record type already has appropriate length checks. Furthermore, the handling of application data here is likely incorrect and bypasses the normal state checks at the end of this function. ok inoguchi@ tb@
2022-03-26Convert c2i_ASN1_OBJECT() and d2i_ASN1_OBJECT to CBS.jsing1-81/+92
Along the way, rather than having yet another piece of code that parses OID arcs, reuse oid_parse_arc(). Always allocate a new ASN1_OBJECT rather than doing a crazy dance with ASN1_OBJECT_FLAG_DYNAMIC and trying to free parts of an ASN1_OBJECT if one is passed in. ok inoguchi@ tb@
2022-03-26Provide asn1_get_primitive()jsing2-2/+35
This takes a CBS, gets the ASN.1 identifier and length, ensures the resulting identifier is a valid primitive, then returns the tag number and the content as a CBS. ok inoguchi@ tb@
2022-03-25use the new CPU_ID_AA64ISAR0 sysctl to determine CPU features on arm64robert1-5/+55
ok tb@, deraadt@, kettenis@
2022-03-24Adjust the signer test to link statically and work with hidden tls_signertb2-3/+7
API.
2022-03-24Crank major after symbol removal.tb1-2/+2
2022-03-24Hide the tls_signer from public visibility. It's not ready yet andtb3-29/+24
should not be used. It will be revisited after release. ok beck inoguchi jsing
2022-03-24Check function return valueinoguchi1-2/+3
2022-03-24Compare pointer value with NULLinoguchi1-63/+63
2022-03-24Wrap long linesinoguchi1-39/+44
2022-03-24Remove space between asterisk and variable nameinoguchi1-22/+22
2022-03-24Convert openssl(1) ts option handlinginoguchi1-153/+285
Apply new option handling to openssl(1) ts, and there is no functional changes here. usage strings are comes from manual page. comments and ok jsing@
2022-03-23openssl cms: avoid NULL derefs on option parsingtb1-1/+3
Two missing initializations in the new option handling cause a segfault when -nodetach or -noindef is passed to openssl cms. ok inoguchi jsing miod
2022-03-23Start disentangling armv7 and aarch64 codetb8-6/+154
arm_arch.h and armcap.c are shared between armv7 and aarch64 which results in an inscrutable #ifdef maze. Move copies of these files into arch/{arm,aarch64}/ with appropriate names and some trivial minor adjustments. ok deraadt inoguchi kettenis
2022-03-20Move/group i2d_ASN1_OBJECT() and d2i_ASN1_OBJECT().jsing1-53/+53
2022-03-19Remove three useless tests filestb3-185/+0
The asn1test depends on asn1_mac.h which had a date with the bitbucket a few years back (and the test "isn't meant to run particularly, it's just to test type checking"). methtest.c tests an API that was never present in OpenSSL's git history. r160test.c is nothing but a licence. "nuke away" jsing
2022-03-19Provide t2i_ASN1_OBJECT_internal() and use it for OBJ_txt2obj()jsing3-32/+43
The current OBJ_txt2obj() implementation converts the text to ASN.1 object content octets, builds a full DER encoding from it, then feeds the entire thing back through the DER to ASN.1 object conversion. Rather than doing this crazy dance, provide an t2i_ASN1_OBJECT_internal() function that converts the text to ASN.1 object content octets, then creates a new ASN1_OBJECT and attaches the content octets to it. ok inoguchi@ tb@
2022-03-19Revise regress for ascii/text to ASN.1 object conversion rewrite.jsing1-58/+10
2022-03-19Rewrite ascii/text to ASN.1 object conversion.jsing1-121/+167
Rewrite the ascii/text to ASN.1 object conversion code using CBB/CBS, while also addressing some of the bizarre behaviour (such as allowing mixed separators and treating '..' as a zero value). ok inoguchi@ tb@
2022-03-19Add another invalid separator test case.jsing1-1/+5
2022-03-18Simplify SSL_do_handshake().jsing1-7/+5
ok inoguchi@ tb@
2022-03-18Rewrite legacy DTLS unexpected handshake message handling.jsing1-83/+139
Rewrite the code that handles unexpected handshake messages in the legacy DTLS stack. Parse the DTLS message header up front, then process it based on the message type. Overall the code should be more strict and we should reject various invalid messages that would have previously been accepted. ok inoguchi@ tb@
2022-03-17Rewrite legacy TLS unexpected handshake message handling.jsing1-78/+114
Rewrite the code that handles unexpected handshake messages in the legacy TLS stack. Parse the TLS message header up front, then process it based on the message type. Overall the code should be more strict and we should reject various invalid messages that would have previously been accepted. I also reviewed steve's experimental code and fixed the bug that it contained. ok inoguchi@ tb@
2022-03-17Clean up and simplify ssl3_renegotiate{,_check}()jsing1-22/+15
ok inoguchi@ tb@
2022-03-17Remove const from tls1_transcript_hash_value()jsing2-5/+5
This function populates the passed *out argument, hence it should not be marked const. ok tb@
2022-03-17Rework ASN1_STRING_set()jsing1-14/+21
Rework ASN1_STRING_set() so that we always clear and free an existing allocation, prior to storing the new data. This fixes a number of issues, including a failure to zero data if the existing allocation was too small. This also fixes other bugs such as leaving the allocation uninitialised if NULL is passed for data. Require -1 where strlen() is expected and improve length and overflow checks. ok inoguchi@ tb@
2022-03-16Fix dependency to build bn_mod_sqrt.bluhm1-2/+2
2022-03-16Make gcc 4 happier about x509_addr.ctb1-6/+8
gcc 4 on sparc64 issues a few 'warning: value computed is not used'. There are two cases: sk_set_cmp_function() returns the old comparison function of the stack which we don't care about. The one warning about an sk_delete() is about a return value that we know already and which we will free a few lines down. ok inoguchi miod
2022-03-15LibreSSL 3.5.2bcook1-3/+3
2022-03-15Initialise *out_name at the start of i2t_ASN1_OBJECT_name().jsing1-1/+3
ok tb@
2022-03-15Check BIO_reset() return value to make gcc happy.tb1-2/+5
2022-03-15Add a simple regress to verify that the infinite loop in BN_mod_sqrt()tb2-1/+138
is fixed.
2022-03-15Fix infinite loop in BN_mod_sqrt()tb1-14/+15
A bug in the implementation of the Tonelli-Shanks algorithm can lead to an infinite loop. This loop can be hit in various ways, in particular on decompressing an elliptic curve public key via EC_POINT_oct2point() - to do this, one must solve y^2 = x^3 + ax + b for y, given x. If a certificate uses explicit encoding for elliptic curve parameters, this operation needs to be done during certificate verification, leading to a DoS. In particular, everything dealing with untrusted certificates is affected, notably TLS servers explicitly configured to request client certificates (httpd, smtpd, various VPN implementations, ...). Ordinary TLS servers do not consume untrusted certificates. The problem is that we cannot assume that x^3 + ax + b is actually a square on untrusted input and neither can we assume that the modulus p is a prime. Ensuring that p is a prime is too expensive (it would likely itself lead to a DoS). To avoid the infinite loop, fix the logic to be more resilient and explicitly limit the number of iterations that can be done. The bug is such that the infinite loop can also be hit for primes = 3 (mod 4) but fortunately that case is optimized earlier. It's also worth noting that there is a size bound on the field size enforced via OPENSSL_ECC_MAX_FIELD_BITS (= 661), which help mitigate further DoS vectors in presence of this fix. Reported by Tavis Ormandy and David Benjamin, Google Patch based on the fixes by David Benjamin and Tomas Mraz, OpenSSL ok beck inoguchi
2022-03-14Add a few regress test cases for name constraints.tb3-5/+25
From Alex Wilson
2022-03-14Allow constraints of the form @domain.comtb1-10/+17
Some things issue and expect that we support a non-standard extension of accepting any email address from a host by prefixing an email name constraint with @. This used to be the case with the old code as well. Pointed out and based on a diff by Alex Wilson. ok jsing
2022-03-14Rework ownership handling in x509_constraints_validate()tb3-39/+49
Instead of having the caller allocate and pass in a new x509_constraints_name struct, handle allocation inside x509_constraints_validate(). Also make the error optional. All this is done to simplify the call sites and to make it more obvious that there are no leaks. ok jsing
2022-03-14Factor out unexpected handshake message handling code in the legacy stack.jsing2-229/+256
The TLS record layer has to be able to handle unexpected handshake messages that result when it has been asked to read application data. The way that this is currently done in the legacy stack is a layering violation - the record layer knows about DTLS/TLS handshake messages, parsing them and then deciding what action to take. This is further complicated by the need to handle handshake message fragments. For now, factor this code out with minimal changes - since it is a layering violation we have to retain separate code for DTLS and TLS. ok beck@ inoguchi@ tb@
2022-03-14Factor out ASN1_STRING clearing code.jsing1-4/+15
This fixes a bug in ASN1_STRING_set0() where it does not respect the ASN1_STRING_FLAG_NDEF flag and potentially frees memory that we do not own. ok inguchi@ tb@
2022-03-14First pass clean up of ASN1_STRING code.jsing1-74/+87
Use consistent variable names (astr/src) rather than 'a', 'bs', 'str', 'v' or 'x', add some whitespace and remove some unneeded parentheses. ok inoguchi@ tb@
2022-03-13Relax the check of x509_constraints_dirname()libressl-v3.5.1tb1-2/+6
The dirname constraint must be a prefix in DER format, so relax the check from requiring equal-length strings to allow shorter names also. From Alex Wilson ok jsing