aboutsummaryrefslogtreecommitdiff
path: root/ssl
AgeCommit message (Collapse)AuthorFilesLines
2016-11-02Fail if an unrecognised record type is receivedMatt Caswell1-7/+5
TLS1.0 and TLS1.1 say you SHOULD ignore unrecognised record types, but TLS 1.2 says you MUST send an unexpected message alert. We swap to the TLS 1.2 behaviour for all protocol versions to prevent issues where no progress is being made and the peer continually sends unrecognised record types, using up resources processing them. Issue reported by 郭志攀 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-02Fix read_aheadMatt Caswell1-12/+12
The function ssl3_read_n() takes a parameter |clearold| which, if set, causes any old data in the read buffer to be forgotten, and any unread data to be moved to the start of the buffer. This is supposed to happen when we first read the record header. However, the data move was only taking place if there was not already sufficient data in the buffer to satisfy the request. If read_ahead is set then the record header could be in the buffer already from when we read the preceding record. So with read_ahead we can get into a situation where even though |clearold| is set, the data does not get moved to the start of the read buffer when we read the record header. This means there is insufficient room in the read buffer to consume the rest of the record body, resulting in an internal error. This commit moves the |clearold| processing to earlier in ssl3_read_n() to ensure that it always takes place. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-02Add DTLS_get_data_mtu() functionDavid Woodhouse3-0/+91
We add ssl_cipher_get_overhead() as an internal function, to avoid having too much ciphersuite-specific knowledge in DTLS_get_data_mtu() itself. It's going to need adjustment for TLSv1.3... but then again, so is fairly much *all* of the SSL_CIPHER handling. This bit is in the noise. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-11-02Convert a big "if" into a "switch"Matt Caswell1-10/+21
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-02Use ciphersuite id when matching if we've got oneMatt Caswell1-0/+2
When matching a ciphersuite if we are given an id, make sure we use it otherwise we will match another ciphersuite which is identical except for the TLS version. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-02Add the SSL_METHOD for TLSv1.3 and all other base changes requiredMatt Caswell9-3/+76
Includes addition of the various options to s_server/s_client. Also adds one of the new TLS1.3 ciphersuites. This isn't "real" TLS1.3!! It's identical to TLS1.2 apart from the protocol and the ciphersuite...and the ciphersuite is just a renamed TLS1.2 one (not a "real" TLS1.3 ciphersuite). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-01Add SSL_CTX_set1_cert_store()Todd Short1-0/+7
For convenience, combine getting a new ref for the new SSL_CTX with assigning the store and freeing the old one. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1755)
2016-10-28Tweaks based on review feedback of BIO size_t workMatt Caswell1-14/+14
Rename some parameters. Also change handling of buffer sizes >INT_MAX in length. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Fix a shadowed variable declaration warningMatt Caswell1-3/+3
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Create BIO_write_ex() which handles size_t argumentsMatt Caswell1-12/+16
Also extend BIO_METHOD to be able to supply an implementation for the new BIO_write_ex function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Create BIO_read_ex() which handles size_t argumentsMatt Caswell1-3/+13
Also extend BIO_METHOD to be able to supply an implementation for the new BIO_read function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28A zero return from BIO_read()/BIO_write() could be retryableMatt Caswell1-3/+15
A zero return from BIO_read()/BIO_write() could mean that an IO operation is retryable. A zero return from SSL_read()/SSL_write() means that the connection has been closed down (either cleanly or not). Therefore we should not propagate a zero return value from BIO_read()/BIO_write() back up the stack to SSL_read()/SSL_write(). This could result in a retryable failure being treated as fatal. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-17Add SSL_OP_NO_ENCRYPT_THEN_MACDavid Woodhouse1-5/+9
Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-17Fix encrypt-then-mac implementation for DTLSDavid Woodhouse2-2/+30
OpenSSL 1.1.0 will negotiate EtM on DTLS but will then not actually *do* it. If we use DTLSv1.2 that will hopefully be harmless since we'll tend to use an AEAD ciphersuite anyway. But if we're using DTLSv1, then we certainly will end up using CBC, so EtM is relevant — and we fail to interoperate with anything that implements EtM correctly. Fixing it in HEAD and 1.1.0c will mean that 1.1.0[ab] are incompatible with 1.1.0c+... for the limited case of non-AEAD ciphers, where they're *already* incompatible with other implementations due to this bug anyway. That seems reasonable enough, so let's do it. The only alternative is just to turn it off for ever... which *still* leaves 1.0.0[ab] failing to communicate with non-OpenSSL implementations anyway. Tested against itself as well as against GnuTLS both with and without EtM. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-10Remove trailing whitespace from some files.David Benjamin2-2/+2
The prevailing style seems to not have trailing whitespace, but a few lines do. This is mostly in the perlasm files, but a few C files got them after the reformat. This is the result of: find . -name '*.pl' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' find . -name '*.c' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' find . -name '*.h' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' Then bn_prime.h was excluded since this is a generated file. Note mkerr.pl has some changes in a heredoc for some help output, but other lines there lack trailing whitespace too. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-03Fix linebreaks in the tls_construct_client_certificate functionMatt Caswell1-2/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Add a typedef for the construction functionMatt Caswell3-8/+6
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Move setting of the handshake header up one more levelMatt Caswell4-66/+65
We now set the handshake header, and close the packet directly in the write_state_machine. This is now possible because it is common for all messages. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Remove the special case processing for finished constructionMatt Caswell4-37/+22
tls_construct_finished() used to have different arguments to all of the other construction functions. It doesn't anymore, so there is no neeed to treat it as a special case. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Harmonise setting the header and closing constructionMatt Caswell6-191/+165
Ensure all message types work the same way including CCS so that the state machine doesn't need to know about special cases. Put all the special logic into ssl_set_handshake_header() and ssl_close_construct_packet(). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Don't set the handshake header in every messageMatt Caswell5-170/+146
Move setting the handshake header up a level into the state machine code in order to reduce boilerplate. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-03Move init of the WPACKET into write_state_machine()Matt Caswell7-306/+205
Instead of initialising, finishing and cleaning up the WPACKET in every message construction function, we should do it once in write_state_machine(). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-02Rename ssl_set_handshake_header2()Matt Caswell8-43/+30
ssl_set_handshake_header2() was only ever a temporary name while we had to have ssl_set_handshake_header() for code that hadn't been converted to WPACKET yet. No code remains that needed that so we can rename it. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-02Remove ssl_set_handshake_header()Matt Caswell4-36/+0
Remove the old ssl_set_handshake_header() implementations. Later we will rename ssl_set_handshake_header2() to ssl_set_handshake_header(). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-02Remove the tls12_get_sigandhash_old() functionMatt Caswell2-25/+0
This is no longer needed now that all messages use WPACKET Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-02fix memory leakDr. Stephen Henson1-0/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert NewSessionTicket construction to WPACKETMatt Caswell1-58/+51
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix an error in packet_locl.hMatt Caswell1-1/+1
A convenience macro was using the wrong underlying function. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert CertStatus message construction to WPACKETMatt Caswell2-27/+15
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix mis-named macro in packet_locl.hMatt Caswell1-2/+2
A couple of the WPACKET_sub_memcpy* macros were mis-named. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert SeverDone construction to WPACKETMatt Caswell1-7/+14
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix missing NULL checks in NewSessionTicket constructionMatt Caswell2-1/+7
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix an mis-matched function code so that "make update" doesn't failMatt Caswell1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Add an example of usage to the WPACKET_reserve_bytes() documentationMatt Caswell1-0/+10
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Address style feedback commentsMatt Caswell2-1/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix a bug in CKE construction for PSKMatt Caswell1-1/+1
In plain PSK we don't need to do anymore construction after the preamble. We weren't detecting this case and treating it as an unknown cipher. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert ServerKeyExchange construction to WPACKETMatt Caswell1-120/+97
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Add the WPACKET_reserve_bytes() functionMatt Caswell2-8/+55
WPACKET_allocate_bytes() requires you to know the size of the data you are allocating for, before you create it. Sometimes this isn't the case, for example we know the maximum size that a signature will be before we create it, but not the actual size. WPACKET_reserve_bytes() enables us to reserve bytes in the WPACKET, but not count them as written yet. We then subsequently need to acall WPACKET_allocate_bytes to actually count them as written. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Remove tls12_copy_sigalgs_old()Matt Caswell2-22/+0
This was a temporary function needed during the conversion to WPACKET. All callers have now been converted to the new way of doing this so this function is no longer required. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert CertificateRequest construction to WPACKETMatt Caswell3-59/+61
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Address style feedback commentsMatt Caswell1-3/+1
Merge declarations of same type together. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix a bug in the construction of the ClienHello SRTP extensionMatt Caswell1-2/+5
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix heartbeat compilation errorMatt Caswell1-0/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Delete some unneeded codeMatt Caswell3-88/+0
Some functions were being called from both code that used WPACKETs and code that did not. Now that more code has been converted to use WPACKETs some of that duplication can be removed. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Convert ServerHello construction to WPACKETMatt Caswell5-219/+134
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-29Fix an Uninit read in DTLSMatt Caswell1-1/+3
If we have a handshake fragment waiting then dtls1_read_bytes() was not correctly setting the value of recvd_type, leading to an uninit read. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-28Fix a bug in Renegotiation extension constructionMatt Caswell1-2/+4
The conversion to WPACKET broke the construction of the renegotiation extension. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-28Convert HelloRequest construction to WPACKETMatt Caswell1-1/+6
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-26Fix HelloVerifyRequest constructionMatt Caswell1-0/+2
commit c536b6be1a introduced a bug that causes a reachable assert. This fixes it. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-26Fix Use After Free for large message sizesMatt Caswell1-3/+17
The buffer to receive messages is initialised to 16k. If a message is received that is larger than that then the buffer is "realloc'd". This can cause the location of the underlying buffer to change. Anything that is referring to the old location will be referring to free'd data. In the recent commit c1ef7c97 (master) and 4b390b6c (1.1.0) the point in the code where the message buffer is grown was changed. However s->init_msg was not updated to point at the new location. CVE-2016-6309 Reviewed-by: Emilia Käsper <emilia@openssl.org>