-/* $OpenBSD: bn_lib.c,v 1.92 2024/04/16 13:04:05 jsing Exp $ */
+/* $OpenBSD: bn_lib.c,v 1.93 2024/04/16 13:07:14 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
return bn_wexpand(bn, words);
}
+int
+bn_expand_bytes(BIGNUM *bn, size_t bytes)
+{
+ int words;
+
+ if (bytes > (INT_MAX - BN_BYTES + 1))
+ return 0;
+
+ words = (bytes + BN_BYTES - 1) / BN_BYTES;
+
+ return bn_wexpand(bn, words);
+}
+
int
bn_wexpand(BIGNUM *bn, int words)
{
-/* $OpenBSD: bn_local.h,v 1.42 2024/04/16 13:04:05 jsing Exp $ */
+/* $OpenBSD: bn_local.h,v 1.43 2024/04/16 13:07:14 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
void bn_correct_top(BIGNUM *a);
int bn_expand_bits(BIGNUM *a, size_t bits);
+int bn_expand_bytes(BIGNUM *a, size_t bytes);
int bn_wexpand(BIGNUM *a, int words);
BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,