From d47f6a4e5992e5e59935c9c209ee85d2c93618f3 Mon Sep 17 00:00:00 2001 From: jsing Date: Sat, 22 Jun 2024 15:25:06 +0000 Subject: [PATCH] Provide CBB_add_u32_length_prefixed(). This is needed for an upcoming change in libcrypto. ok tb@ --- lib/libssl/bs_cbb.c | 8 +++++++- lib/libssl/bytestring.h | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/libssl/bs_cbb.c b/lib/libssl/bs_cbb.c index 059f9abd068..9d7ad7d46d8 100644 --- a/lib/libssl/bs_cbb.c +++ b/lib/libssl/bs_cbb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bs_cbb.c,v 1.29 2024/05/25 15:14:26 tb Exp $ */ +/* $OpenBSD: bs_cbb.c,v 1.30 2024/06/22 15:25:06 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -328,6 +328,12 @@ CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents) return cbb_add_length_prefixed(cbb, out_contents, 3); } +int +CBB_add_u32_length_prefixed(CBB *cbb, CBB *out_contents) +{ + return cbb_add_length_prefixed(cbb, out_contents, 4); +} + int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag) { diff --git a/lib/libssl/bytestring.h b/lib/libssl/bytestring.h index 51284da8dbe..750343d4fa0 100644 --- a/lib/libssl/bytestring.h +++ b/lib/libssl/bytestring.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bytestring.h,v 1.24 2022/11/09 23:14:51 jsing Exp $ */ +/* $OpenBSD: bytestring.h,v 1.25 2024/06/22 15:25:06 jsing Exp $ */ /* * Copyright (c) 2014, Google Inc. * @@ -459,6 +459,13 @@ int CBB_add_u16_length_prefixed(CBB *cbb, CBB *out_contents); */ int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents); +/* + * CBB_add_u32_length_prefixed sets |*out_contents| to a new child of |cbb|. + * The data written to |*out_contents| will be prefixed in |cbb| with a 32-bit, + * big-endian length. It returns one on success or zero on error. + */ +int CBB_add_u32_length_prefixed(CBB *cbb, CBB *out_contents); + /* * CBB_add_asn sets |*out_contents| to a |CBB| into which the contents of an * ASN.1 object can be written. The |tag| argument will be used as the tag for -- 2.20.1