-/* $OpenBSD: x509.c,v 1.101 2024/09/12 10:33:25 tb Exp $ */
+/* $OpenBSD: x509.c,v 1.102 2024/10/07 12:18:31 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
{
BIGNUM *bn = NULL;
- if (ASN1_STRING_length(i) > 20) {
- warnx("%s: %s should fit in 20 octets", fn, descr);
- goto out;
- }
-
if ((bn = ASN1_INTEGER_to_BN(i, NULL)) == NULL) {
warnx("%s: %s: ASN1_INTEGER_to_BN error", fn, descr);
goto out;
goto out;
}
+ if (BN_num_bytes(bn) > 20 || BN_is_bit_set(bn, 159)) {
+ warnx("%s: %s should fit in 20 octets", fn, descr);
+ goto out;
+ }
+
return bn;
out: