summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_lib.c')
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c
index e4085c9d67..77ee3b1fdc 100644
--- a/src/lib/libcrypto/bn/bn_lib.c
+++ b/src/lib/libcrypto/bn/bn_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_lib.c,v 1.50 2021/12/04 15:53:01 tb Exp $ */ 1/* $OpenBSD: bn_lib.c,v 1.51 2021/12/04 15:59:52 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1061,6 +1061,44 @@ BN_swap_ct(BN_ULONG condition, BIGNUM *a, BIGNUM *b, size_t nwords)
1061 return 1; 1061 return 1;
1062} 1062}
1063 1063
1064void
1065BN_zero_ex(BIGNUM *a)
1066{
1067 a->neg = 0;
1068 a->top = 0;
1069 /* XXX: a->flags &= ~BN_FIXED_TOP */
1070}
1071
1072int
1073BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
1074{
1075 return (a->top == 1 && a->d[0] == w) || (w == 0 && a->top == 0);
1076}
1077
1078int
1079BN_is_zero(const BIGNUM *a)
1080{
1081 return a->top == 0;
1082}
1083
1084int
1085BN_is_one(const BIGNUM *a)
1086{
1087 return BN_abs_is_word(a, 1) && !a->neg;
1088}
1089
1090int
1091BN_is_word(const BIGNUM *a, const BN_ULONG w)
1092{
1093 return BN_abs_is_word(a, w) && (w == 0 || !a->neg);
1094}
1095
1096int
1097BN_is_odd(const BIGNUM *a)
1098{
1099 return a->top > 0 && (a->d[0] & 1);
1100}
1101
1064BN_GENCB * 1102BN_GENCB *
1065BN_GENCB_new(void) 1103BN_GENCB_new(void)
1066{ 1104{