summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/ssl/bs_cbs.c9
-rw-r--r--lib/libssl/src/ssl/bytestring.h8
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/libssl/src/ssl/bs_cbs.c b/lib/libssl/src/ssl/bs_cbs.c
index 1b513c9a0e2..1368fe0fd7f 100644
--- a/lib/libssl/src/ssl/bs_cbs.c
+++ b/lib/libssl/src/ssl/bs_cbs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bs_cbs.c,v 1.10 2015/06/16 06:11:39 doug Exp $ */
+/* $OpenBSD: bs_cbs.c,v 1.11 2015/06/17 07:00:22 doug Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
@@ -28,6 +28,7 @@ void
CBS_init(CBS *cbs, const uint8_t *data, size_t len)
{
cbs->data = data;
+ cbs->initial_len = len;
cbs->len = len;
}
@@ -43,6 +44,12 @@ cbs_get(CBS *cbs, const uint8_t **p, size_t n)
return 1;
}
+size_t
+CBS_offset(const CBS *cbs)
+{
+ return cbs->initial_len - cbs->len;
+}
+
int
CBS_skip(CBS *cbs, size_t len)
{
diff --git a/lib/libssl/src/ssl/bytestring.h b/lib/libssl/src/ssl/bytestring.h
index 07be6ddd50e..80ca00d77a4 100644
--- a/lib/libssl/src/ssl/bytestring.h
+++ b/lib/libssl/src/ssl/bytestring.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bytestring.h,v 1.9 2015/06/16 06:37:58 doug Exp $ */
+/* $OpenBSD: bytestring.h,v 1.10 2015/06/17 07:00:22 doug Exp $ */
/*
* Copyright (c) 2014, Google Inc.
*
@@ -40,6 +40,7 @@ extern "C" {
/* CRYPTO ByteString */
typedef struct cbs_st {
const uint8_t *data;
+ size_t initial_len;
size_t len;
} CBS;
@@ -66,6 +67,11 @@ const uint8_t *CBS_data(const CBS *cbs);
size_t CBS_len(const CBS *cbs);
/*
+ * CBS_offset returns the current offset into the original data of |cbs|.
+ */
+size_t CBS_offset(const CBS *cbs);
+
+/*
* CBS_stow copies the current contents of |cbs| into |*out_ptr| and
* |*out_len|. If |*out_ptr| is not NULL, the contents are freed with
* free. It returns one on success and zero on allocation failure. On