-/* $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.
*
CBS_init(CBS *cbs, const uint8_t *data, size_t len)
{
cbs->data = data;
+ cbs->initial_len = len;
cbs->len = len;
}
return 1;
}
+size_t
+CBS_offset(const CBS *cbs)
+{
+ return cbs->initial_len - cbs->len;
+}
+
int
CBS_skip(CBS *cbs, size_t len)
{
-/* $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.
*
/* CRYPTO ByteString */
typedef struct cbs_st {
const uint8_t *data;
+ size_t initial_len;
size_t len;
} 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
-/* $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.
*
CBS_init(CBS *cbs, const uint8_t *data, size_t len)
{
cbs->data = data;
+ cbs->initial_len = len;
cbs->len = len;
}
return 1;
}
+size_t
+CBS_offset(const CBS *cbs)
+{
+ return cbs->initial_len - cbs->len;
+}
+
int
CBS_skip(CBS *cbs, size_t len)
{
-/* $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.
*
/* CRYPTO ByteString */
typedef struct cbs_st {
const uint8_t *data;
+ size_t initial_len;
size_t len;
} 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