summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-01-04Return 0 on failure from send/get kex functions in the legacy stack.Joel Sing
In the legacy stack, a message handling function returns -1 for failure, 0 for need more data and 1 for success (although in extra special cases 2 may also be used). However, the various send/get kex functions only need to indicate success or failure - switch these to return 0 on failure (rather than -1) and use normal result testing. This leaves GOST unchanged for now, as that code is special and needs extra work. ok inoguchi@ tb@
2022-01-04Use normal result testing for tls1_check_curve().Joel Sing
2022-01-04Refactor ssl3_get_server_kex_ecdhe() to separate parsing and validation.Joel Sing
If we receive something other than a "named curve", send a handshake failure alert as we're unable to complete the handshake with the given parameters. If the server responded with a curve that we did not advertise send an illegal parameter alert. ok inoguchi@ tb@
2022-01-04Pull key share group/length CBB code up from tls13_key_share_public()Joel Sing
This provides better symmetry with the parsing code and will allow for better reuse with the legacy stack, which has different message structures. ok inoguchi@ tb@
2022-01-04Only allow zero length key shares when we know we're doing HRR.Joel Sing
ok inoguchi@ tb@
2022-01-03By default, put intermediate files in a temp dir and remove it onPhilip Guenther
completion. To leave files in /tmp, use new -k option.
2022-01-02fix strange indentation in code exampleTheo Buehler
2022-01-02Don't use *ENTRY_NB() with END_BUILTIN(), at least yetPhilip Guenther
Problem noted by naddy@
2022-01-01Add ENTRY_NB() macro for doing an ASM function entry without settingPhilip Guenther
the binding to global (NB == "no binding"), as clang 13 is now warning about changing the binding from global to weak. This first pass does amd64 and sparc64 and pulls DEFS.h out of the per-arch directory to a common directory; others to follow ok kettenis@
2022-01-01failured -> failedJonathan Gray
2022-01-01contibutions -> contributionsJonathan Gray
2022-01-01identfier -> identifierJonathan Gray
2021-12-31excpetions -> exceptionsJonathan Gray
2021-12-31deafult -> defaultJonathan Gray
2021-12-28Fix typo in commentTheo Buehler
2021-12-28Use lowercase letters for hexadecimal constants, as both jsing and ITheo Buehler
prefer this.
2021-12-28Rewrite X509v3_addr_canonize() with new accessorsTheo Buehler
This is again a straightforward conversion and leads to something which matches our usual style more. ok jsing
2021-12-28Validate AFIs before sorting in X509v3_adr_canonize()Theo Buehler
Again, we're dealing with necessarily not fully validated data here, so a check up front seems prudent. ok jsing
2021-12-28Rewrite/simplify X509v3_addr_is_canonical()Theo Buehler
This is a more or less straightforward conversion using the new IPAddressFamily accessor API. As a result, some checks have become a bit stricter, which is only desirable here. ok jsing
2021-12-28Check AFI/SAFI before comparing them in X509v3_addr_is_canonical()Theo Buehler
As mentioned in a previous commit, IPAddressFamily_cmp() can't really check for trailing garbage in addressFamily->data. Since the path validation and hence the X.509 validator call X509v3_addr_is_canonical(), this deals with only partially validated data. ok jsing
2021-12-28Make IPAddressFamily_cmp() more pleasing on the eyeTheo Buehler
Define and use MINIMUM() instead of a ternary operator and separate the code from the declarations. Also, we can spare a line to make the return legible instead of squeezing it into another ternary operator. addressFamily->data contains a two-bytes AFI and an optional one-byte SAFI. This function currently also compares any trailing garbage that may be present. Since comparison functions can't really error, this needs to be checked bofore it is used. Such checks will be added in subsequent commits. ok jsing
2021-12-28Style improvements in X509v3_addr_add_range()Theo Buehler
ok jsing
2021-12-28Style improvements in X509v3_addr_add_prefix()Theo Buehler
ok jsing
2021-12-28Another small readability tweak in X509v3_addr_inherits()Theo Buehler
Declare IPAddressFamily before using it.
2021-12-28Use an accessor in X509v3_addr_inherits()Theo Buehler
2021-12-28Add a comment to i2r_IPAddrBlocks that we may want/have to deal withTheo Buehler
unknown address family types. Pointed out by jsing during review.
2021-12-28Add a few accessors for IPAddressFamily and make first use of themTheo Buehler
One reason why this file is hard to read are endless repetitions of checks and assignments reaching deep inside structs. This can be made much more readable by adding a bunch of accessors. As a first step, we deal with IPAddressFamily, where we want to check the type of the ipAddressChoice member, check whether the inheritance element is present or access the addressOrRanges field. This diff already makes minimal use of these accessors to appease -Werror. More use and additional accessors will follow in later passes. ok inoguchi jsing
2021-12-28Simplify and explain expand_addr() a bitTheo Buehler
RFC 3779 section 2.1.2 does a decent job of explaining how IP addresses are encoded in. What's stored amounts to a prefix with all trailing zero octets omitted. If there are trailing zero bits in the last non-zero octet, bs->flags & 7 indicates how many. addr_expand() expands this to an address of length 4 or 16 depending on whether we deal with IPv4 or IPv6. Since an address can be the lower or the upper bound of a prefix or address range, expansion needs to be able to zero-fill or one-fill the unused bits/octets. No other expansion is ever used, so simplify the meaning of fill accordingly. There's no need to special case the case that there are no unused bits, the masking/filling is a noop. ok jsing
2021-12-28Add a comment so I don't forget to think about input validationTheo Buehler
in make_IPAddressFamily()
2021-12-28Convert make_IPAddressFamily to CBS/CBBTheo Buehler
The IPAddrBlocks type, which represents the IPAddrBlocks extension, should have exactly one IPAddressFamily per AFI+SAFI combination to be delegated. make_IPAddressFamily() first builds up a search key from the afi and safi arguments and then looks for an existing IPAddressFamily with that key in the IPAddrBlocks that was passed in. It returns that if it finds it or allocates and adds a new one. This diff preserves the current behavior that the afi and *safi arguments are truncated to 2 and 1 bytes, respectively. This may change in the future. ok inoguchi jsing
2021-12-28Remove two pointless NULL checks and allocationsTheo Buehler
The ASN.1 template for IPAddressFamily doesn't mark either of its two members as optional, so they are allocated by IPAddressFamily_new(). ok inoguchi jsing
2021-12-28Check for trailing garbage in X509_addr_get_afi()Theo Buehler
Per RFC 3779 2.2.3.3, the addressFamily field contains the 2-byte AFI and an optional 1-byte SAFI. Nothing else. The optional SAFI is nowhere exposed in the API. It is used expliclty only for pretty printing. There are implicit uses in a few places, notably for sorting/comparing where trailing garbage would be erroneously taken into account. Erroring in this situation will let us avoid this in upcoming revisions. ok inoguchi jsing
2021-12-28Convert X509v3_adr_get_afi() to CBSTheo Buehler
The manual byte bashing is performed more safely using this API which would have avoided the out-of-bounds read that this API had until a few years back. The API is somewhat strange in that it uses the reserved AFI 0 as an in-band error but it doesn't care about the reserved AFI 65535. ok inoguchi jsing
2021-12-27Pull BN_{new,init,clear,clear_free,free} up to the top of bn_lib.cJoel Sing
Discussed with tb@
2021-12-26zap doubled semicolonTheo Buehler
2021-12-26Check BIO_indent() return like all the others in this file.Theo Buehler
CID 345118
2021-12-26Drop pointless cast in i2d_ASN1_BOOLEAN(). This may or may not fixTheo Buehler
a weird coverity warning. CID 345121 ok jsing
2021-12-26Consistently call BN_init() before BN_with_flags()Theo Buehler
BN_with_flags() preserves the BN_FLG_MALLOCED flag of the destination which results in a potential use of an uninitialized bit. In practice this doesn't matter since we don't free the cloned BIGNUMs anyway. As jsing points out, these are mostly pointless noise and should be garbage collected. I'll leave that for another rainy day. Coverity flagged one instance BN_gcd_no_branch(), the rest was found by the ever so helpful grep(1). CID 345122 ok jsing
2021-12-26Hoist memset of CBB above EVP_MD_CTX_new() and HMAC_CTX_new() to avoidTheo Buehler
a use of uninitialized in the unlikely event that either of them fails. Problem introduced in r1.128. CID 345113 ok jsing
2021-12-26Correct SSL_get_peer_cert_chain() when used with the TLSv1.3 stack.Joel Sing
Due to a wonderful API inconsistency, a client includes the peer's leaf certificate in the stored certificate chain, while a server does not. Found due to a haproxy test failure reported by Ilya Shipitsin. ok tb@
2021-12-25Fix some weird line wrapping and a minor KNF nitTheo Buehler
2021-12-25No need for assert.h in here.Theo Buehler
2021-12-25drop a meaningless XXXTheo Buehler
2021-12-25Use C99 initializers for v3_addr, v3_asid and v3_ct_scts[]Theo Buehler
as is done for most other X.509 v3 extension methods. discussed with jsing
2021-12-25Indent goto labels for diffability.Joel Sing
Whitespace change only.
2021-12-25Merge asn_pack.c into asn1_item.c - these are two ASN1_item_* functions.Joel Sing
No functional change.
2021-12-25Merge evp_asn1.c into a_type.c - these are all ASN1_TYPE_* functions.Joel Sing
No functional change.
2021-12-25Move more ASN1_STRING_* functions to a_string.c.Joel Sing
No functional change.
2021-12-25More consolidation of ASN.1 code.Joel Sing
Consolidate various ASN1_item_* functions into asn1_item.c and the remaining NO_OLD_ASN1 code (not to be confused with the NO_ASN1_OLD code) into asn1_old.c. This is preferable to having many files, often with one or two functions per file. No functional change. Discussed with tb@
2021-12-25Consolidate code/templates for ASN.1 types.Joel Sing
Where an ASN.1 type has its own file, move the ASN.1 item template and template related functions into the file. Discussed with tb@