summaryrefslogtreecommitdiffstats
path: root/lib/libssl/t1_lib.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2018-08-19 15:38:03 +0000
committerjsing <jsing@openbsd.org>2018-08-19 15:38:03 +0000
commit481c1145e46ded4f26ffc82fbf5e609beda1850f (patch)
tree92f065d3d6b2ba59ca3c3c5308d01523b925c339 /lib/libssl/t1_lib.c
parentConvert ssl3_send_newsession_ticket() to CBB. (diff)
downloadwireguard-openbsd-481c1145e46ded4f26ffc82fbf5e609beda1850f.tar.xz
wireguard-openbsd-481c1145e46ded4f26ffc82fbf5e609beda1850f.zip
Rename and collapse tls12_get_sigandhash_cbb().
Now that all callers of tls12_get_sigandhash() have been converted to CBB, collapse tls12_get_sigandhash() and tls12_get_sigandhash_cbb() into a single function. Rename it to tls12_gethashandsig() to be representative of the actual order of the sigalgs parameters, and perform some other clean up. ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/t1_lib.c')
-rw-r--r--lib/libssl/t1_lib.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/lib/libssl/t1_lib.c b/lib/libssl/t1_lib.c
index 7f166942f79..1b2e0844fb0 100644
--- a/lib/libssl/t1_lib.c
+++ b/lib/libssl/t1_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: t1_lib.c,v 1.142 2018/08/16 17:49:48 jsing Exp $ */
+/* $OpenBSD: t1_lib.c,v 1.143 2018/08/19 15:38:03 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -1116,51 +1116,43 @@ tls12_find_id(int nid, tls12_lookup *table, size_t tlen)
}
int
-tls12_get_sigandhash_cbb(CBB *cbb, const EVP_PKEY *pk, const EVP_MD *md)
+tls12_get_hashid(const EVP_MD *md)
{
- unsigned char p[2];
+ if (md == NULL)
+ return -1;
- if (!tls12_get_sigandhash(p, pk, md))
- return 0;
+ return tls12_find_id(EVP_MD_type(md), tls12_md,
+ sizeof(tls12_md) / sizeof(tls12_lookup));
+}
- if (!CBB_add_u8(cbb, p[0]))
- return 0;
- if (!CBB_add_u8(cbb, p[1]))
- return 0;
+int
+tls12_get_sigid(const EVP_PKEY *pk)
+{
+ if (pk == NULL)
+ return -1;
- return 1;
+ return tls12_find_id(pk->type, tls12_sig,
+ sizeof(tls12_sig) / sizeof(tls12_lookup));
}
int
-tls12_get_sigandhash(unsigned char *p, const EVP_PKEY *pk, const EVP_MD *md)
+tls12_get_hashandsig(CBB *cbb, const EVP_PKEY *pk, const EVP_MD *md)
{
- int sig_id, md_id;
+ int hash_id, sig_id;
- if (md == NULL)
+ if ((hash_id = tls12_get_hashid(md)) == -1)
return 0;
-
- md_id = tls12_find_id(EVP_MD_type(md), tls12_md,
- sizeof(tls12_md) / sizeof(tls12_lookup));
- if (md_id == -1)
+ if ((sig_id = tls12_get_sigid(pk)) == -1)
return 0;
- sig_id = tls12_get_sigid(pk);
- if (sig_id == -1)
+ if (!CBB_add_u8(cbb, hash_id))
+ return 0;
+ if (!CBB_add_u8(cbb, sig_id))
return 0;
-
- p[0] = (unsigned char)md_id;
- p[1] = (unsigned char)sig_id;
return 1;
}
-int
-tls12_get_sigid(const EVP_PKEY *pk)
-{
- return tls12_find_id(pk->type, tls12_sig,
- sizeof(tls12_sig) / sizeof(tls12_lookup));
-}
-
const EVP_MD *
tls12_get_hash(unsigned char hash_alg)
{