summaryrefslogtreecommitdiffstats
path: root/lib/libssl/d1_lib.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2020-02-21 16:12:18 +0000
committerjsing <jsing@openbsd.org>2020-02-21 16:12:18 +0000
commit94777d7c366bec9e8db99745e9bca3e7cd1f7560 (patch)
treee300e3e5ab0b80bd38998248b66497bfcae9a004 /lib/libssl/d1_lib.c
parentMove l2n/l2n8 into s3_cbc.c, since this is the only code that uses it. (diff)
downloadwireguard-openbsd-94777d7c366bec9e8db99745e9bca3e7cd1f7560.tar.xz
wireguard-openbsd-94777d7c366bec9e8db99745e9bca3e7cd1f7560.zip
Convert dtls1_build_sequence_number() to CBB.
ok inoguchi@ tb@
Diffstat (limited to 'lib/libssl/d1_lib.c')
-rw-r--r--lib/libssl/d1_lib.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/libssl/d1_lib.c b/lib/libssl/d1_lib.c
index 7e919a6c9bb..45bbd9b45d6 100644
--- a/lib/libssl/d1_lib.c
+++ b/lib/libssl/d1_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: d1_lib.c,v 1.42 2017/04/10 17:27:33 jsing Exp $ */
+/* $OpenBSD: d1_lib.c,v 1.43 2020/02/21 16:12:18 jsing Exp $ */
/*
* DTLS implementation written by Nagendra Modadugu
* (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -455,11 +455,19 @@ void
dtls1_build_sequence_number(unsigned char *dst, unsigned char *seq,
unsigned short epoch)
{
- unsigned char dtlsseq[SSL3_SEQUENCE_SIZE];
- unsigned char *p;
+ CBB cbb;
- p = dtlsseq;
- s2n(epoch, p);
- memcpy(p, &seq[2], SSL3_SEQUENCE_SIZE - 2);
- memcpy(dst, dtlsseq, SSL3_SEQUENCE_SIZE);
+ if (!CBB_init_fixed(&cbb, dst, SSL3_SEQUENCE_SIZE))
+ goto err;
+ if (!CBB_add_u16(&cbb, epoch))
+ goto err;
+ if (!CBB_add_bytes(&cbb, &seq[2], SSL3_SEQUENCE_SIZE - 2))
+ goto err;
+ if (!CBB_finish(&cbb, NULL, NULL))
+ goto err;
+
+ return;
+
+ err:
+ CBB_cleanup(&cbb);
}