-/* $OpenBSD: asn1_lib.c,v 1.53 2022/04/28 18:30:57 jsing Exp $ */
+/* $OpenBSD: asn1_lib.c,v 1.54 2022/05/05 19:18:56 jsing Exp $ */
/*
* Copyright (c) 2021 Joel Sing <jsing@openbsd.org>
*
int
asn1_get_length_cbs(CBS *cbs, int der_mode, int *out_indefinite,
- uint32_t *out_length)
+ size_t *out_length)
{
uint8_t len_bytes;
- uint32_t length;
+ size_t length;
uint8_t val;
/*
return 0;
if (der_mode && length == 0 && val == 0)
return 0;
- if (length > (UINT32_MAX >> 8))
+ if (length > (SIZE_MAX >> 8))
return 0;
length = (length << 8) | val;
}
int
asn1_get_object_cbs(CBS *cbs, int der_mode, uint8_t *out_tag_class,
int *out_constructed, uint32_t *out_tag_number, int *out_indefinite,
- uint32_t *out_length)
+ size_t *out_length)
{
int constructed, indefinite;
- uint32_t tag_number, length;
+ uint32_t tag_number;
uint8_t tag_class;
+ size_t length;
*out_tag_class = 0;
*out_constructed = 0;
CBS *out_content)
{
int constructed, indefinite;
- uint32_t tag_number, length;
+ uint32_t tag_number;
uint8_t tag_class;
+ size_t length;
*out_tag_number = 0;
-/* $OpenBSD: asn1_locl.h,v 1.28 2022/04/28 18:30:57 jsing Exp $ */
+/* $OpenBSD: asn1_locl.h,v 1.29 2022/05/05 19:18:56 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
int asn1_get_identifier_cbs(CBS *cbs, int der_mode, uint8_t *out_class,
int *out_constructed, uint32_t *out_tag_number);
int asn1_get_length_cbs(CBS *cbs, int der_mode, int *out_indefinite,
- uint32_t *out_length);
+ size_t *out_length);
int asn1_get_object_cbs(CBS *cbs, int der_mode, uint8_t *out_class,
int *out_constructed, uint32_t *out_tag_number, int *out_indefinite,
- uint32_t *out_length);
+ size_t *out_length);
int asn1_get_primitive(CBS *cbs, int der_mode, uint32_t *out_tag_number,
CBS *out_content);
-/* $OpenBSD: asn1_old_lib.c,v 1.3 2022/01/14 07:57:17 tb Exp $ */
+/* $OpenBSD: asn1_old_lib.c,v 1.4 2022/05/05 19:18:56 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
int *pclass, long omax)
{
int constructed, indefinite;
- uint32_t tag_number, length;
+ uint32_t tag_number;
uint8_t tag_class;
+ size_t length;
CBS cbs;
int ret = 0;
* signal an error by setting the 8th bit in the return value... but we
* still provide all of the decoded data.
*/
- if (length > CBS_len(&cbs)) {
+ if (length > CBS_len(&cbs) || length > LONG_MAX) {
ASN1error(ASN1_R_TOO_LONG);
ret = 0x80;
}
-/* $OpenBSD: tasn_dec.c,v 1.57 2022/05/04 10:57:48 jsing Exp $ */
+/* $OpenBSD: tasn_dec.c,v 1.58 2022/05/05 19:18:56 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
char *out_indefinite, char *out_constructed, int expected_tag,
int expected_class, char optional)
{
- uint32_t tag_number, length;
int constructed, indefinite;
+ uint32_t tag_number;
uint8_t tag_class;
+ size_t length;
if (out_len != NULL)
*out_len = 0;
return 0;
}
- if (tag_number > INT_MAX || CBS_len(cbs) > INT_MAX) {
+ if (tag_number > INT_MAX) {
ASN1error(ASN1_R_TOO_LONG);
return 0;
}