summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordoug <>2015-06-17 07:00:22 +0000
committerdoug <>2015-06-17 07:00:22 +0000
commit7489a76f28fc9e40d91abd387e7e07cf8e913e7e (patch)
tree1c938eea4d2e4db42e65849d2d45997f47d5dd3b /src/lib
parenta68ddb622101bfa87cb91864b28033b49cba1deb (diff)
downloadopenbsd-7489a76f28fc9e40d91abd387e7e07cf8e913e7e.tar.gz
openbsd-7489a76f28fc9e40d91abd387e7e07cf8e913e7e.tar.bz2
openbsd-7489a76f28fc9e40d91abd387e7e07cf8e913e7e.zip
Add a new function CBS_offset() to report the current offset in the data.
"why not" miod@, sure jsing@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libssl/bs_cbs.c9
-rw-r--r--src/lib/libssl/bytestring.h8
-rw-r--r--src/lib/libssl/src/ssl/bs_cbs.c9
-rw-r--r--src/lib/libssl/src/ssl/bytestring.h8
4 files changed, 30 insertions, 4 deletions
diff --git a/src/lib/libssl/bs_cbs.c b/src/lib/libssl/bs_cbs.c
index 1b513c9a0e..1368fe0fd7 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.10 2015/06/16 06:11:39 doug Exp $ */ 1/* $OpenBSD: bs_cbs.c,v 1.11 2015/06/17 07:00:22 doug Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -28,6 +28,7 @@ void
28CBS_init(CBS *cbs, const uint8_t *data, size_t len) 28CBS_init(CBS *cbs, const uint8_t *data, size_t len)
29{ 29{
30 cbs->data = data; 30 cbs->data = data;
31 cbs->initial_len = len;
31 cbs->len = len; 32 cbs->len = len;
32} 33}
33 34
@@ -43,6 +44,12 @@ cbs_get(CBS *cbs, const uint8_t **p, size_t n)
43 return 1; 44 return 1;
44} 45}
45 46
47size_t
48CBS_offset(const CBS *cbs)
49{
50 return cbs->initial_len - cbs->len;
51}
52
46int 53int
47CBS_skip(CBS *cbs, size_t len) 54CBS_skip(CBS *cbs, size_t len)
48{ 55{
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h
index 07be6ddd50..80ca00d77a 100644
--- a/src/lib/libssl/bytestring.h
+++ b/src/lib/libssl/bytestring.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bytestring.h,v 1.9 2015/06/16 06:37:58 doug Exp $ */ 1/* $OpenBSD: bytestring.h,v 1.10 2015/06/17 07:00:22 doug Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -40,6 +40,7 @@ extern "C" {
40/* CRYPTO ByteString */ 40/* CRYPTO ByteString */
41typedef struct cbs_st { 41typedef struct cbs_st {
42 const uint8_t *data; 42 const uint8_t *data;
43 size_t initial_len;
43 size_t len; 44 size_t len;
44} CBS; 45} CBS;
45 46
@@ -66,6 +67,11 @@ const uint8_t *CBS_data(const CBS *cbs);
66size_t CBS_len(const CBS *cbs); 67size_t CBS_len(const CBS *cbs);
67 68
68/* 69/*
70 * CBS_offset returns the current offset into the original data of |cbs|.
71 */
72size_t CBS_offset(const CBS *cbs);
73
74/*
69 * CBS_stow copies the current contents of |cbs| into |*out_ptr| and 75 * CBS_stow copies the current contents of |cbs| into |*out_ptr| and
70 * |*out_len|. If |*out_ptr| is not NULL, the contents are freed with 76 * |*out_len|. If |*out_ptr| is not NULL, the contents are freed with
71 * free. It returns one on success and zero on allocation failure. On 77 * free. It returns one on success and zero on allocation failure. On
diff --git a/src/lib/libssl/src/ssl/bs_cbs.c b/src/lib/libssl/src/ssl/bs_cbs.c
index 1b513c9a0e..1368fe0fd7 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.10 2015/06/16 06:11:39 doug Exp $ */ 1/* $OpenBSD: bs_cbs.c,v 1.11 2015/06/17 07:00:22 doug Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -28,6 +28,7 @@ void
28CBS_init(CBS *cbs, const uint8_t *data, size_t len) 28CBS_init(CBS *cbs, const uint8_t *data, size_t len)
29{ 29{
30 cbs->data = data; 30 cbs->data = data;
31 cbs->initial_len = len;
31 cbs->len = len; 32 cbs->len = len;
32} 33}
33 34
@@ -43,6 +44,12 @@ cbs_get(CBS *cbs, const uint8_t **p, size_t n)
43 return 1; 44 return 1;
44} 45}
45 46
47size_t
48CBS_offset(const CBS *cbs)
49{
50 return cbs->initial_len - cbs->len;
51}
52
46int 53int
47CBS_skip(CBS *cbs, size_t len) 54CBS_skip(CBS *cbs, size_t len)
48{ 55{
diff --git a/src/lib/libssl/src/ssl/bytestring.h b/src/lib/libssl/src/ssl/bytestring.h
index 07be6ddd50..80ca00d77a 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.9 2015/06/16 06:37:58 doug Exp $ */ 1/* $OpenBSD: bytestring.h,v 1.10 2015/06/17 07:00:22 doug Exp $ */
2/* 2/*
3 * Copyright (c) 2014, Google Inc. 3 * Copyright (c) 2014, Google Inc.
4 * 4 *
@@ -40,6 +40,7 @@ extern "C" {
40/* CRYPTO ByteString */ 40/* CRYPTO ByteString */
41typedef struct cbs_st { 41typedef struct cbs_st {
42 const uint8_t *data; 42 const uint8_t *data;
43 size_t initial_len;
43 size_t len; 44 size_t len;
44} CBS; 45} CBS;
45 46
@@ -66,6 +67,11 @@ const uint8_t *CBS_data(const CBS *cbs);
66size_t CBS_len(const CBS *cbs); 67size_t CBS_len(const CBS *cbs);
67 68
68/* 69/*
70 * CBS_offset returns the current offset into the original data of |cbs|.
71 */
72size_t CBS_offset(const CBS *cbs);
73
74/*
69 * CBS_stow copies the current contents of |cbs| into |*out_ptr| and 75 * CBS_stow copies the current contents of |cbs| into |*out_ptr| and
70 * |*out_len|. If |*out_ptr| is not NULL, the contents are freed with 76 * |*out_len|. If |*out_ptr| is not NULL, the contents are freed with
71 * free. It returns one on success and zero on allocation failure. On 77 * free. It returns one on success and zero on allocation failure. On