summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn.h')
-rw-r--r--src/lib/libcrypto/bn/bn.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h
index 2c648ba2ee..5efccd180b 100644
--- a/src/lib/libcrypto/bn/bn.h
+++ b/src/lib/libcrypto/bn/bn.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn.h,v 1.28 2015/10/21 19:02:22 miod Exp $ */ 1/* $OpenBSD: bn.h,v 1.29 2016/03/02 06:16:11 doug Exp $ */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -125,6 +125,7 @@
125#ifndef HEADER_BN_H 125#ifndef HEADER_BN_H
126#define HEADER_BN_H 126#define HEADER_BN_H
127 127
128#include <limits.h>
128#include <stdio.h> 129#include <stdio.h>
129#include <stdlib.h> 130#include <stdlib.h>
130 131
@@ -619,10 +620,20 @@ const BIGNUM *BN_get0_nist_prime_521(void);
619 620
620/* library internal functions */ 621/* library internal functions */
621 622
622#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
623 (a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
624#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) 623#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
625BIGNUM *bn_expand2(BIGNUM *a, int words); 624BIGNUM *bn_expand2(BIGNUM *a, int words);
625
626static inline BIGNUM *bn_expand(BIGNUM *a, int bits)
627{
628 if (bits > (INT_MAX - BN_BITS2 + 1))
629 return (NULL);
630
631 if (((bits + BN_BITS2 - 1) / BN_BITS2) <= a->dmax)
632 return (a);
633
634 return bn_expand2(a, (bits + BN_BITS2 - 1) / BN_BITS2);
635}
636
626#ifndef OPENSSL_NO_DEPRECATED 637#ifndef OPENSSL_NO_DEPRECATED
627BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */ 638BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
628#endif 639#endif