-/* $OpenBSD: ssl_clnt.c,v 1.80 2021/02/20 08:22:55 jsing Exp $ */
+/* $OpenBSD: ssl_clnt.c,v 1.81 2021/02/20 14:03:50 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
skip = 0;
}
-end:
+ end:
s->internal->in_handshake--;
if (cb != NULL)
cb(s, SSL_CB_CONNECT_EXIT, ret);
/* SSL3_ST_CW_CLNT_HELLO_B */
return (ssl3_handshake_write(s));
-err:
+ err:
CBB_cleanup(&cbb);
return (-1);
}
if (n < 0)
- goto truncated;
+ goto decode_err;
CBS_init(&hello_verify_request, s->internal->init_msg, n);
if (!CBS_get_u16(&hello_verify_request, &ssl_version))
- goto truncated;
+ goto decode_err;
if (!CBS_get_u8_length_prefixed(&hello_verify_request, &cookie))
- goto truncated;
+ goto decode_err;
if (CBS_len(&hello_verify_request) != 0)
- goto truncated;
+ goto decode_err;
/*
* Per RFC 6347 section 4.2.1, the HelloVerifyRequest should always
return 1;
-truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
return -1;
}
s->internal->first_packet = 0;
if (n < 0)
- goto truncated;
+ goto decode_err;
CBS_init(&cbs, s->internal->init_msg, n);
}
if (!CBS_get_u16(&cbs, &server_version))
- goto truncated;
+ goto decode_err;
if (ssl_supported_version_range(s, &min_version, &max_version) != 1) {
SSLerror(s, SSL_R_NO_PROTOCOLS_AVAILABLE);
/* Server random. */
if (!CBS_get_bytes(&cbs, &server_random, SSL3_RANDOM_SIZE))
- goto truncated;
+ goto decode_err;
if (!CBS_write_bytes(&server_random, s->s3->server_random,
sizeof(s->s3->server_random), NULL))
goto err;
/* Session ID. */
if (!CBS_get_u8_length_prefixed(&cbs, &session_id))
- goto truncated;
+ goto decode_err;
if (CBS_len(&session_id) > SSL3_SESSION_ID_SIZE) {
al = SSL_AD_ILLEGAL_PARAMETER;
/* Cipher suite. */
if (!CBS_get_u16(&cbs, &cipher_suite))
- goto truncated;
+ goto decode_err;
/*
* Check if we want to resume the session based on external
tls1_transcript_free(s);
if (!CBS_get_u8(&cbs, &compression_method))
- goto truncated;
+ goto decode_err;
if (compression_method != 0) {
al = SSL_AD_ILLEGAL_PARAMETER;
return (1);
-truncated:
+ decode_err:
/* wrong packet length */
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
-err:
+ err:
return (-1);
}
}
if (n < 0)
- goto truncated;
+ goto decode_err;
CBS_init(&cbs, s->internal->init_msg, n);
if (CBS_len(&cbs) < 3)
- goto truncated;
+ goto decode_err;
if (!CBS_get_u24_length_prefixed(&cbs, &cert_list) ||
CBS_len(&cbs) != 0) {
CBS cert;
if (CBS_len(&cert_list) < 3)
- goto truncated;
+ goto decode_err;
if (!CBS_get_u24_length_prefixed(&cert_list, &cert)) {
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_CERT_LENGTH_MISMATCH);
ret = 1;
if (0) {
-truncated:
+ decode_err:
/* wrong packet length */
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
-err:
+ err:
EVP_PKEY_free(pkey);
X509_free(x);
sk_X509_pop_free(sk, X509_free);
}
if (!CBS_get_u16_length_prefixed(cbs, &dhp))
- goto truncated;
+ goto decode_err;
if ((dh->p = BN_bin2bn(CBS_data(&dhp), CBS_len(&dhp), NULL)) == NULL) {
SSLerror(s, ERR_R_BN_LIB);
goto err;
}
if (!CBS_get_u16_length_prefixed(cbs, &dhg))
- goto truncated;
+ goto decode_err;
if ((dh->g = BN_bin2bn(CBS_data(&dhg), CBS_len(&dhg), NULL)) == NULL) {
SSLerror(s, ERR_R_BN_LIB);
goto err;
}
if (!CBS_get_u16_length_prefixed(cbs, &dhpk))
- goto truncated;
+ goto decode_err;
if ((dh->pub_key = BN_bin2bn(CBS_data(&dhpk), CBS_len(&dhpk),
NULL)) == NULL) {
SSLerror(s, ERR_R_BN_LIB);
return (1);
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
if (!CBS_get_u8_length_prefixed(cbs, &public))
- goto truncated;
+ goto decode_err;
if (nid == NID_X25519) {
if (ssl3_get_server_kex_ecdhe_ecx(s, sc, nid, &public) != 1)
return (1);
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
uint16_t sigalg_value;
if (!CBS_get_u16(&cbs, &sigalg_value))
- goto truncated;
+ goto decode_err;
if ((sigalg = ssl_sigalg(sigalg_value, tls12_sigalgs,
tls12_sigalgs_len)) == NULL) {
SSLerror(s, SSL_R_UNKNOWN_DIGEST);
md = sigalg->md();
if (!CBS_get_u16_length_prefixed(&cbs, &signature))
- goto truncated;
+ goto decode_err;
if (CBS_len(&signature) > EVP_PKEY_size(pkey)) {
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_WRONG_SIGNATURE_LENGTH);
return (1);
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
}
if (n < 0)
- goto truncated;
+ goto decode_err;
CBS_init(&cert_request, s->internal->init_msg, n);
if ((ca_sk = sk_X509_NAME_new(ca_dn_cmp)) == NULL) {
/* get the certificate types */
if (!CBS_get_u8(&cert_request, &ctype_num))
- goto truncated;
+ goto decode_err;
if (ctype_num > SSL3_CT_NUMBER)
ctype_num = SSL3_CT_NUMBER;
ret = 1;
if (0) {
-truncated:
+ decode_err:
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
}
-err:
+ err:
X509_NAME_free(xn);
sk_X509_NAME_pop_free(ca_sk, X509_NAME_free);
return (ret);
EVP_sha256(), NULL);
ret = 1;
return (ret);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
-err:
+ err:
return (-1);
}
al = SSL_AD_INTERNAL_ERROR;
SSLerror(s, ERR_R_MALLOC_FAILURE);
goto f_err;
- }
+ }
if (s->ctx->internal->tlsext_status_cb) {
int ret;
}
}
return (1);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
return (-1);
}
ret = 1;
-err:
+ err:
explicit_bzero(pms, sizeof(pms));
EVP_PKEY_free(pkey);
free(enc_pms);
ret = 1;
-err:
+ err:
DH_free(dh_clnt);
freezero(key, key_size);
/* SSL3_ST_CW_KEY_EXCH_B */
return (ssl3_handshake_write(s));
-err:
+ err:
CBB_cleanup(&cbb);
return (-1);
}
return (1);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
-err:
+ err:
return (0);
}
-/* $OpenBSD: ssl_srvr.c,v 1.92 2021/02/20 08:22:55 jsing Exp $ */
+/* $OpenBSD: ssl_srvr.c,v 1.93 2021/02/20 14:03:50 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
}
skip = 0;
}
-end:
+ end:
/* BIO_flush(s->wbio); */
s->internal->in_handshake--;
if (cb != NULL)
/* Parse client hello up until the extensions (if any). */
if (!CBS_get_u16(&cbs, &client_version))
- goto truncated;
+ goto decode_err;
if (!CBS_get_bytes(&cbs, &client_random, SSL3_RANDOM_SIZE))
- goto truncated;
+ goto decode_err;
if (!CBS_get_u8_length_prefixed(&cbs, &session_id))
- goto truncated;
+ goto decode_err;
if (CBS_len(&session_id) > SSL3_SESSION_ID_SIZE) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerror(s, SSL_R_SSL3_SESSION_ID_TOO_LONG);
}
if (SSL_is_dtls(s)) {
if (!CBS_get_u8_length_prefixed(&cbs, &cookie))
- goto truncated;
+ goto decode_err;
}
if (!CBS_get_u16_length_prefixed(&cbs, &cipher_suites))
- goto truncated;
+ goto decode_err;
if (!CBS_get_u8_length_prefixed(&cbs, &compression_methods))
- goto truncated;
+ goto decode_err;
/*
* Use version from inside client hello, not from record header.
comp_null = 0;
while (CBS_len(&compression_methods) > 0) {
if (!CBS_get_u8(&compression_methods, &comp_method))
- goto truncated;
+ goto decode_err;
if (comp_method == 0)
comp_null = 1;
}
ret = cookie_valid ? 2 : 1;
if (0) {
-truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
-err:
+ err:
sk_SSL_CIPHER_free(ciphers);
return (ret);
p = pms;
if (!CBS_get_u16_length_prefixed(cbs, &enc_pms))
- goto truncated;
+ goto decode_err;
if (CBS_len(cbs) != 0 || CBS_len(&enc_pms) != RSA_size(rsa)) {
SSLerror(s, SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG);
goto err;
return (1);
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
f_err:
DH *dh;
if (!CBS_get_u16_length_prefixed(cbs, &dh_Yc))
- goto truncated;
+ goto decode_err;
if (CBS_len(cbs) != 0)
- goto truncated;
+ goto decode_err;
if (S3I(s)->tmp.dh == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
return (1);
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
f_err:
/* Decrypt session key */
if (!CBS_get_asn1(cbs, &gostblob, CBS_ASN1_SEQUENCE))
- goto truncated;
+ goto decode_err;
if (CBS_len(cbs) != 0)
- goto truncated;
+ goto decode_err;
if (EVP_PKEY_decrypt(pkey_ctx, premaster_secret, &outlen,
CBS_data(&gostblob), CBS_len(&gostblob)) <= 0) {
SSLerror(s, SSL_R_DECRYPTION_FAILED);
else
goto err;
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
ssl3_send_alert(s, SSL3_AL_FATAL, al);
uint16_t sigalg_value;
if (!CBS_get_u16(&cbs, &sigalg_value))
- goto truncated;
+ goto decode_err;
if ((sigalg = ssl_sigalg(sigalg_value, tls12_sigalgs,
tls12_sigalgs_len)) == NULL ||
(md = sigalg->md()) == NULL) {
ret = 1;
if (0) {
- truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
f_err:
}
if (n < 0)
- goto truncated;
+ goto decode_err;
CBS_init(&cbs, s->internal->init_msg, n);
if (!CBS_get_u24_length_prefixed(&cbs, &client_certs) ||
CBS_len(&cbs) != 0)
- goto truncated;
+ goto decode_err;
while (CBS_len(&client_certs) > 0) {
CBS cert;
ret = 1;
if (0) {
-truncated:
+ decode_err:
al = SSL_AD_DECODE_ERROR;
SSLerror(s, SSL_R_BAD_PACKET_LENGTH);
-f_err:
+ f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
-err:
+ err:
X509_free(x);
sk_X509_pop_free(sk, X509_free);