diff options
| author | jsing <> | 2017-11-28 16:34:20 +0000 |
|---|---|---|
| committer | jsing <> | 2017-11-28 16:34:20 +0000 |
| commit | 76849a9caf0c93472d0fa91e5211a18f1b3afd18 (patch) | |
| tree | 14049ca61b6311dc9802d8f78a33685da6af3633 | |
| parent | 8498b91851192781ec9ed2dd8420226001473ef7 (diff) | |
| download | openbsd-76849a9caf0c93472d0fa91e5211a18f1b3afd18.tar.gz openbsd-76849a9caf0c93472d0fa91e5211a18f1b3afd18.tar.bz2 openbsd-76849a9caf0c93472d0fa91e5211a18f1b3afd18.zip | |
Add CBB_discard_child(), which allows for a child CBB to be discarded.
Based on BoringSSL.
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/bs_cbb.c | 16 | ||||
| -rw-r--r-- | src/lib/libssl/bytestring.h | 8 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/libssl/bs_cbb.c b/src/lib/libssl/bs_cbb.c index 9de75fbb02..bf7de3fd33 100644 --- a/src/lib/libssl/bs_cbb.c +++ b/src/lib/libssl/bs_cbb.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bs_cbb.c,v 1.17 2017/08/12 02:50:05 jsing Exp $ */ | 1 | /* $OpenBSD: bs_cbb.c,v 1.18 2017/11/28 16:34:20 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
| 4 | * | 4 | * |
| @@ -271,6 +271,20 @@ CBB_flush(CBB *cbb) | |||
| 271 | return 1; | 271 | return 1; |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | void | ||
| 275 | CBB_discard_child(CBB *cbb) | ||
| 276 | { | ||
| 277 | if (cbb->child == NULL) | ||
| 278 | return; | ||
| 279 | |||
| 280 | cbb->base->len = cbb->offset; | ||
| 281 | |||
| 282 | cbb->child->base = NULL; | ||
| 283 | cbb->child = NULL; | ||
| 284 | cbb->pending_len_len = 0; | ||
| 285 | cbb->pending_is_asn1 = 0; | ||
| 286 | cbb->offset = 0; | ||
| 287 | } | ||
| 274 | 288 | ||
| 275 | static int | 289 | static int |
| 276 | cbb_add_length_prefixed(CBB *cbb, CBB *out_contents, size_t len_len) | 290 | cbb_add_length_prefixed(CBB *cbb, CBB *out_contents, size_t len_len) |
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index d8c8e6ada6..2e89a5791a 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bytestring.h,v 1.15 2016/11/04 18:28:58 guenther Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.16 2017/11/28 16:34:20 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
| 4 | * | 4 | * |
| @@ -394,6 +394,12 @@ int CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len); | |||
| 394 | int CBB_flush(CBB *cbb); | 394 | int CBB_flush(CBB *cbb); |
| 395 | 395 | ||
| 396 | /* | 396 | /* |
| 397 | * CBB_discard_child discards the current unflushed child of |cbb|. Neither the | ||
| 398 | * child's contents nor the length prefix will be included in the output. | ||
| 399 | */ | ||
| 400 | void CBB_discard_child(CBB *cbb); | ||
| 401 | |||
| 402 | /* | ||
| 397 | * CBB_add_u8_length_prefixed sets |*out_contents| to a new child of |cbb|. The | 403 | * CBB_add_u8_length_prefixed sets |*out_contents| to a new child of |cbb|. The |
| 398 | * data written to |*out_contents| will be prefixed in |cbb| with an 8-bit | 404 | * data written to |*out_contents| will be prefixed in |cbb| with an 8-bit |
| 399 | * length. It returns one on success or zero on error. | 405 | * length. It returns one on success or zero on error. |
