diff options
author | doug <> | 2015-06-19 00:23:36 +0000 |
---|---|---|
committer | doug <> | 2015-06-19 00:23:36 +0000 |
commit | efbf61787a43b6d1b3a3509ed4e6cf7eb2ee6231 (patch) | |
tree | 0c2bf824ab545d4f85a730e504864d99df649f58 | |
parent | 815c9ed0143713859a67f4501a0f3698f19d25a3 (diff) | |
download | openbsd-efbf61787a43b6d1b3a3509ed4e6cf7eb2ee6231.tar.gz openbsd-efbf61787a43b6d1b3a3509ed4e6cf7eb2ee6231.tar.bz2 openbsd-efbf61787a43b6d1b3a3509ed4e6cf7eb2ee6231.zip |
Add CBS_dup() to initialize a new CBS with the same values.
This is useful for when you need to check the data ahead and then continue
on from the same spot.
input + ok jsing@ miod@
-rw-r--r-- | src/lib/libssl/bs_cbs.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/bytestring.h | 8 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bs_cbs.c | 8 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bytestring.h | 8 |
4 files changed, 28 insertions, 4 deletions
diff --git a/src/lib/libssl/bs_cbs.c b/src/lib/libssl/bs_cbs.c index 45c253cc4b..8173177249 100644 --- a/src/lib/libssl/bs_cbs.c +++ b/src/lib/libssl/bs_cbs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbs.c,v 1.13 2015/06/17 07:25:56 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbs.c,v 1.14 2015/06/19 00:23:36 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -32,6 +32,12 @@ CBS_init(CBS *cbs, const uint8_t *data, size_t len) | |||
32 | cbs->len = len; | 32 | cbs->len = len; |
33 | } | 33 | } |
34 | 34 | ||
35 | void | ||
36 | CBS_dup(const CBS *cbs, CBS *out) | ||
37 | { | ||
38 | CBS_init(out, CBS_data(cbs), CBS_len(cbs)); | ||
39 | } | ||
40 | |||
35 | static int | 41 | static int |
36 | cbs_get(CBS *cbs, const uint8_t **p, size_t n) | 42 | cbs_get(CBS *cbs, const uint8_t **p, size_t n) |
37 | { | 43 | { |
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index 4c9d4d8884..8ea84005b4 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.13 2015/06/18 23:25:07 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.14 2015/06/19 00:23:36 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -466,6 +466,12 @@ int CBB_add_asn1_uint64(CBB *cbb, uint64_t value); | |||
466 | 466 | ||
467 | #ifdef LIBRESSL_INTERNAL | 467 | #ifdef LIBRESSL_INTERNAL |
468 | /* | 468 | /* |
469 | * CBS_dup sets |out| to point to cbs's |data| and |len|. It results in two | ||
470 | * CBS that point to the same buffer. | ||
471 | */ | ||
472 | void CBS_dup(const CBS *cbs, CBS *out); | ||
473 | |||
474 | /* | ||
469 | * cbs_get_any_asn1_element sets |*out| to contain the next ASN.1 element from | 475 | * cbs_get_any_asn1_element sets |*out| to contain the next ASN.1 element from |
470 | * |*cbs| (including header bytes) and advances |*cbs|. It sets |*out_tag| to | 476 | * |*cbs| (including header bytes) and advances |*cbs|. It sets |*out_tag| to |
471 | * the tag number and |*out_header_len| to the length of the ASN.1 header. If | 477 | * the tag number and |*out_header_len| to the length of the ASN.1 header. If |
diff --git a/src/lib/libssl/src/ssl/bs_cbs.c b/src/lib/libssl/src/ssl/bs_cbs.c index 45c253cc4b..8173177249 100644 --- a/src/lib/libssl/src/ssl/bs_cbs.c +++ b/src/lib/libssl/src/ssl/bs_cbs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbs.c,v 1.13 2015/06/17 07:25:56 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbs.c,v 1.14 2015/06/19 00:23:36 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -32,6 +32,12 @@ CBS_init(CBS *cbs, const uint8_t *data, size_t len) | |||
32 | cbs->len = len; | 32 | cbs->len = len; |
33 | } | 33 | } |
34 | 34 | ||
35 | void | ||
36 | CBS_dup(const CBS *cbs, CBS *out) | ||
37 | { | ||
38 | CBS_init(out, CBS_data(cbs), CBS_len(cbs)); | ||
39 | } | ||
40 | |||
35 | static int | 41 | static int |
36 | cbs_get(CBS *cbs, const uint8_t **p, size_t n) | 42 | cbs_get(CBS *cbs, const uint8_t **p, size_t n) |
37 | { | 43 | { |
diff --git a/src/lib/libssl/src/ssl/bytestring.h b/src/lib/libssl/src/ssl/bytestring.h index 4c9d4d8884..8ea84005b4 100644 --- a/src/lib/libssl/src/ssl/bytestring.h +++ b/src/lib/libssl/src/ssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.13 2015/06/18 23:25:07 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.14 2015/06/19 00:23:36 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -466,6 +466,12 @@ int CBB_add_asn1_uint64(CBB *cbb, uint64_t value); | |||
466 | 466 | ||
467 | #ifdef LIBRESSL_INTERNAL | 467 | #ifdef LIBRESSL_INTERNAL |
468 | /* | 468 | /* |
469 | * CBS_dup sets |out| to point to cbs's |data| and |len|. It results in two | ||
470 | * CBS that point to the same buffer. | ||
471 | */ | ||
472 | void CBS_dup(const CBS *cbs, CBS *out); | ||
473 | |||
474 | /* | ||
469 | * cbs_get_any_asn1_element sets |*out| to contain the next ASN.1 element from | 475 | * cbs_get_any_asn1_element sets |*out| to contain the next ASN.1 element from |
470 | * |*cbs| (including header bytes) and advances |*cbs|. It sets |*out_tag| to | 476 | * |*cbs| (including header bytes) and advances |*cbs|. It sets |*out_tag| to |
471 | * the tag number and |*out_header_len| to the length of the ASN.1 header. If | 477 | * the tag number and |*out_header_len| to the length of the ASN.1 header. If |