-/* $OpenBSD: ssl_clnt.c,v 1.100 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: ssl_clnt.c,v 1.101 2021/06/27 18:15:35 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if (!CBS_get_u16(&cbs, &sigalg_value))
goto decode_err;
- if ((sigalg = ssl_sigalg_from_value(sigalg_value,
- tls12_sigalgs, tls12_sigalgs_len)) == NULL) {
+ if ((sigalg = ssl_sigalg_from_value(
+ S3I(s)->hs.negotiated_tls_version,
+ sigalg_value)) == NULL) {
SSLerror(s, SSL_R_UNKNOWN_DIGEST);
al = SSL_AD_DECODE_ERROR;
goto fatal_err;
-/* $OpenBSD: ssl_sigalgs.c,v 1.28 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: ssl_sigalgs.c,v 1.29 2021/06/27 18:15:35 jsing Exp $ */
/*
* Copyright (c) 2018-2020 Bob Beck <beck@openbsd.org>
*
}
const struct ssl_sigalg *
-ssl_sigalg_lookup(uint16_t sigalg)
+ssl_sigalg_lookup(uint16_t value)
{
int i;
for (i = 0; sigalgs[i].value != SIGALG_NONE; i++) {
- if (sigalgs[i].value == sigalg)
+ if (sigalgs[i].value == value)
return &sigalgs[i];
}
}
const struct ssl_sigalg *
-ssl_sigalg_from_value(uint16_t sigalg, const uint16_t *values, size_t len)
+ssl_sigalg_from_value(uint16_t tls_version, uint16_t value)
{
+ const uint16_t *values;
+ size_t len;
int i;
+ ssl_sigalgs_for_version(tls_version, &values, &len);
+
for (i = 0; i < len; i++) {
- if (values[i] == sigalg)
- return ssl_sigalg_lookup(sigalg);
+ if (values[i] == value)
+ return ssl_sigalg_lookup(value);
}
return NULL;
*/
CBS_init(&cbs, S3I(s)->hs.sigalgs, S3I(s)->hs.sigalgs_len);
while (CBS_len(&cbs) > 0) {
- uint16_t sig_alg;
const struct ssl_sigalg *sigalg;
+ uint16_t sigalg_value;
- if (!CBS_get_u16(&cbs, &sig_alg))
+ if (!CBS_get_u16(&cbs, &sigalg_value))
return 0;
- if ((sigalg = ssl_sigalg_from_value(sig_alg, tls_sigalgs,
- tls_sigalgs_len)) == NULL)
+ if ((sigalg = ssl_sigalg_from_value(
+ S3I(s)->hs.negotiated_tls_version, sigalg_value)) == NULL)
continue;
/* RSA cannot be used without PSS in TLSv1.3. */
-/* $OpenBSD: ssl_sigalgs.h,v 1.19 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: ssl_sigalgs.h,v 1.20 2021/06/27 18:15:35 jsing Exp $ */
/*
* Copyright (c) 2018-2019 Bob Beck <beck@openbsd.org>
*
#define SIGALG_GOSTR12_256_STREEBOG_256 0xEEEE
#define SIGALG_GOSTR01_GOST94 0xEDED
-/* Legacy sigalg for < 1.2 same value as boring uses*/
+/* Legacy sigalg for < TLSv1.2 same value as BoringSSL uses. */
#define SIGALG_RSA_PKCS1_MD5_SHA1 0xFF01
#define SIGALG_FLAG_RSA_PSS 0x00000001
int flags;
};
-extern const uint16_t tls12_sigalgs[];
-extern const size_t tls12_sigalgs_len;
-extern const uint16_t tls13_sigalgs[];
-extern const size_t tls13_sigalgs_len;
-
const struct ssl_sigalg *ssl_sigalg_lookup(uint16_t sigalg);
-const struct ssl_sigalg *ssl_sigalg_from_value(uint16_t sigalg,
- const uint16_t *values, size_t len);
+const struct ssl_sigalg *ssl_sigalg_from_value(uint16_t tls_version,
+ uint16_t value);
int ssl_sigalgs_build(uint16_t tls_version, CBB *cbb);
-int ssl_sigalg_pkey_check(uint16_t sigalg, EVP_PKEY *pk);
int ssl_sigalg_pkey_ok(const struct ssl_sigalg *sigalg, EVP_PKEY *pkey,
int check_curve);
const struct ssl_sigalg *ssl_sigalg_select(SSL *s, EVP_PKEY *pkey);
-/* $OpenBSD: ssl_srvr.c,v 1.113 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: ssl_srvr.c,v 1.114 2021/06/27 18:15:35 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
if (!CBS_get_u16(&cbs, &sigalg_value))
goto decode_err;
- if ((sigalg = ssl_sigalg_from_value(sigalg_value,
- tls12_sigalgs, tls12_sigalgs_len)) == NULL ||
+ if ((sigalg = ssl_sigalg_from_value(
+ S3I(s)->hs.negotiated_tls_version, sigalg_value)) == NULL ||
(md = sigalg->md()) == NULL) {
SSLerror(s, SSL_R_UNKNOWN_DIGEST);
al = SSL_AD_DECODE_ERROR;
-/* $OpenBSD: tls13_client.c,v 1.81 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: tls13_client.c,v 1.82 2021/06/27 18:15:35 jsing Exp $ */
/*
* Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
*
if (!CBS_get_u16_length_prefixed(cbs, &signature))
goto err;
- if ((sigalg = ssl_sigalg_from_value(signature_scheme,
- tls13_sigalgs, tls13_sigalgs_len)) == NULL)
+ if ((sigalg = ssl_sigalg_from_value(ctx->hs->negotiated_tls_version,
+ signature_scheme)) == NULL)
goto err;
if (!CBB_init(&cbb, 0))
-/* $OpenBSD: tls13_server.c,v 1.79 2021/06/27 18:09:07 jsing Exp $ */
+/* $OpenBSD: tls13_server.c,v 1.80 2021/06/27 18:15:35 jsing Exp $ */
/*
* Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org>
* Copyright (c) 2020 Bob Beck <beck@openbsd.org>
if (!CBS_get_u16_length_prefixed(cbs, &signature))
goto err;
- if ((sigalg = ssl_sigalg_from_value(signature_scheme,
- tls13_sigalgs, tls13_sigalgs_len)) == NULL)
+ if ((sigalg = ssl_sigalg_from_value(ctx->hs->negotiated_tls_version,
+ signature_scheme)) == NULL)
goto err;
if (!CBB_init(&cbb, 0))