-/* $OpenBSD: bs_cbb.c,v 1.17 2017/08/12 02:50:05 jsing Exp $ */
+/* $OpenBSD: bs_cbb.c,v 1.18 2017/11/28 16:34:20 jsing Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
return 1;
}
+void
+CBB_discard_child(CBB *cbb)
+{
+ if (cbb->child == NULL)
+ return;
+
+ cbb->base->len = cbb->offset;
+
+ cbb->child->base = NULL;
+ cbb->child = NULL;
+ cbb->pending_len_len = 0;
+ cbb->pending_is_asn1 = 0;
+ cbb->offset = 0;
+}
static int
cbb_add_length_prefixed(CBB *cbb, CBB *out_contents, size_t len_len)
-/* $OpenBSD: bytestring.h,v 1.15 2016/11/04 18:28:58 guenther Exp $ */
+/* $OpenBSD: bytestring.h,v 1.16 2017/11/28 16:34:20 jsing Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
*/
int CBB_flush(CBB *cbb);
+/*
+ * CBB_discard_child discards the current unflushed child of |cbb|. Neither the
+ * child's contents nor the length prefix will be included in the output.
+ */
+void CBB_discard_child(CBB *cbb);
+
/*
* CBB_add_u8_length_prefixed sets |*out_contents| to a new child of |cbb|. The
* data written to |*out_contents| will be prefixed in |cbb| with an 8-bit