summaryrefslogtreecommitdiffstats
path: root/src/crypto/bn/shift.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/bn/shift.c')
-rw-r--r--src/crypto/bn/shift.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/crypto/bn/shift.c b/src/crypto/bn/shift.c
index 1e3b7c3..f143996 100644
--- a/src/crypto/bn/shift.c
+++ b/src/crypto/bn/shift.c
@@ -58,6 +58,8 @@
#include <string.h>
+#include <openssl/err.h>
+
#include "internal.h"
@@ -66,6 +68,11 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n) {
BN_ULONG *t, *f;
BN_ULONG l;
+ if (n < 0) {
+ OPENSSL_PUT_ERROR(BN, BN_lshift, BN_R_NEGATIVE_NUMBER);
+ return 0;
+ }
+
r->neg = a->neg;
nw = n / BN_BITS2;
if (bn_wexpand(r, a->top + nw + 1) == NULL) {
@@ -130,6 +137,11 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) {
BN_ULONG *t, *f;
BN_ULONG l, tmp;
+ if (n < 0) {
+ OPENSSL_PUT_ERROR(BN, BN_rshift, BN_R_NEGATIVE_NUMBER);
+ return 0;
+ }
+
nw = n / BN_BITS2;
rb = n % BN_BITS2;
lb = BN_BITS2 - rb;