/*
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
*
- * Licensed under the OpenSSL license (the "License"). You may not use
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
-#include "../ssl_locl.h"
-#include "record_locl.h"
+#include "../ssl_local.h"
+#include "record_local.h"
#include "internal/cryptlib.h"
/*-
* internal errors, but not otherwise.
*
* Returns:
- * 0: (in non-constant time) if the record is publically invalid (i.e. too
+ * 0: (in non-constant time) if the record is publicly invalid (i.e. too
* short etc).
* 1: if the record encryption was successful.
* -1: if the record's AEAD-authenticator is invalid or, if sending,
seq = RECORD_LAYER_get_read_sequence(&s->rlayer);
}
- if (ctx == NULL
- || (rec->type == SSL3_RT_ALERT
- && s->statem.enc_write_state
- == ENC_WRITE_STATE_WRITE_PLAIN_ALERTS)) {
+ /*
+ * If we're sending an alert and ctx != NULL then we must be forcing
+ * plaintext alerts. If we're reading and ctx != NULL then we allow
+ * plaintext alerts at certain points in the handshake. If we've got this
+ * far then we have already validated that a plaintext alert is ok here.
+ */
+ if (ctx == NULL || rec->type == SSL3_RT_ALERT) {
memmove(rec->data, rec->input, rec->length);
rec->input = rec->data;
return 1;
* To get here we must have selected a ciphersuite - otherwise ctx would
* be NULL
*/
- if (!ossl_assert(s->s3->tmp.new_cipher != NULL)) {
+ if (!ossl_assert(s->s3.tmp.new_cipher != NULL)) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_ENC,
ERR_R_INTERNAL_ERROR);
return -1;
}
- alg_enc = s->s3->tmp.new_cipher->algorithm_enc;
+ alg_enc = s->s3.tmp.new_cipher->algorithm_enc;
}
if (alg_enc & SSL_AESCCM) {