diff options
-rw-r--r-- | src/lib/libssl/bs_cbs.c | 19 | ||||
-rw-r--r-- | src/lib/libssl/bytestring.h | 8 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/lib/libssl/bs_cbs.c b/src/lib/libssl/bs_cbs.c index 627c609bb9..97b0163f3f 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.22 2021/12/15 17:23:34 jsing Exp $ */ | 1 | /* $OpenBSD: bs_cbs.c,v 1.23 2021/12/15 17:30:20 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -191,6 +191,23 @@ CBS_get_u32(CBS *cbs, uint32_t *out) | |||
191 | } | 191 | } |
192 | 192 | ||
193 | int | 193 | int |
194 | CBS_get_u64(CBS *cbs, uint64_t *out) | ||
195 | { | ||
196 | uint32_t a, b; | ||
197 | |||
198 | if (cbs->len < 8) | ||
199 | return 0; | ||
200 | |||
201 | if (!CBS_get_u32(cbs, &a)) | ||
202 | return 0; | ||
203 | if (!CBS_get_u32(cbs, &b)) | ||
204 | return 0; | ||
205 | |||
206 | *out = (uint64_t)a << 32 | b; | ||
207 | return 1; | ||
208 | } | ||
209 | |||
210 | int | ||
194 | CBS_get_last_u8(CBS *cbs, uint8_t *out) | 211 | CBS_get_last_u8(CBS *cbs, uint8_t *out) |
195 | { | 212 | { |
196 | if (cbs->len == 0) | 213 | if (cbs->len == 0) |
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index 4ab2828d09..fa5e05fa27 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.20 2021/12/15 17:23:34 jsing Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.21 2021/12/15 17:30:20 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -134,6 +134,12 @@ int CBS_get_u24(CBS *cbs, uint32_t *out); | |||
134 | int CBS_get_u32(CBS *cbs, uint32_t *out); | 134 | int CBS_get_u32(CBS *cbs, uint32_t *out); |
135 | 135 | ||
136 | /* | 136 | /* |
137 | * CBS_get_u64 sets |*out| to the next, big-endian uint64_t value from |cbs| | ||
138 | * and advances |cbs|. It returns one on success and zero on error. | ||
139 | */ | ||
140 | int CBS_get_u64(CBS *cbs, uint64_t *out); | ||
141 | |||
142 | /* | ||
137 | * CBS_get_last_u8 sets |*out| to the last uint8_t from |cbs| and shortens | 143 | * CBS_get_last_u8 sets |*out| to the last uint8_t from |cbs| and shortens |
138 | * |cbs|. It returns one on success and zero on error. | 144 | * |cbs|. It returns one on success and zero on error. |
139 | */ | 145 | */ |