From bd94b8a5ba71079048f3d3650b2790eaa03c9243 Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 16 Aug 2018 18:39:37 +0000 Subject: [PATCH] Provide CBB_add_u32(), as needed for an upcoming conversion. ok tb@ --- lib/libssl/bs_cbb.c | 11 ++++++++++- lib/libssl/bytestring.h | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c index bf7de3fd333..beb588fe25d 100644 --- a/lib/libssl/bs_cbb.c +++ b/lib/libssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.18 2017/11/28 16:34:20 jsing Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.19 2018/08/16 18:39:37 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -405,6 +405,15 @@ CBB_add_u24(CBB *cbb, size_t value) return cbb_add_u(cbb, (uint32_t)value, 3); } +int +CBB_add_u32(CBB *cbb, size_t value) +{ + if (value > 0xffffffffUL) + return 0; + + return cbb_add_u(cbb, (uint32_t)value, 4); +} + int CBB_add_asn1_uint64(CBB *cbb, uint64_t value) { diff --git a/lib/libssl/bytestring.h b/lib/libssl/bytestring.h index 2e89a5791a5..20ee43999d5 100644 --- a/lib/libssl/bytestring.h +++ b/lib/libssl/bytestring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestring.h,v 1.16 2017/11/28 16:34:20 jsing Exp $ */ +/* $OpenBSD: bytestring.h,v 1.17 2018/08/16 18:39:37 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -461,6 +461,12 @@ int CBB_add_u16(CBB *cbb, size_t value); */ int CBB_add_u24(CBB *cbb, size_t value); +/* + * CBB_add_u32 appends a 32-bit, big-endian number from |value| to |cbb|. It + * returns one on success and zero otherwise. + */ +int CBB_add_u32(CBB *cbb, size_t value); + /* * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| * and writes |value| in its contents. It returns one on success and zero on -- 2.20.1