projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Some crypto applications are now being built on Unix, so they should on VMS as well...
[oweals/openssl.git]
/
crypto
/
bn
/
bn_gcd.c
diff --git
a/crypto/bn/bn_gcd.c
b/crypto/bn/bn_gcd.c
index 9b0bc2b1002e325c49186d5a2641af27dd44ec37..64a76f4498965b0e912eece66863edead0e46d27 100644
(file)
--- a/
crypto/bn/bn_gcd.c
+++ b/
crypto/bn/bn_gcd.c
@@
-1,5
+1,5
@@
/* crypto/bn/bn_gcd.c */
/* crypto/bn/bn_gcd.c */
-/* Copyright (C) 1995-199
7
Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-199
8
Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* All rights reserved.
*
* This package is an SSL implementation written
@@
-60,21
+60,17
@@
#include "cryptlib.h"
#include "bn_lcl.h"
#include "cryptlib.h"
#include "bn_lcl.h"
-#ifndef NOPROTO
static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
static BIGNUM *euclid(BIGNUM *a, BIGNUM *b);
-#else
-static BIGNUM *euclid();
-#endif
-
-int BN_gcd(r,in_a,in_b,ctx)
-BIGNUM *r,*in_a,*in_b;
-BN_CTX *ctx;
+int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx)
{
BIGNUM *a,*b,*t;
int ret=0;
{
BIGNUM *a,*b,*t;
int ret=0;
- a=ctx->bn[ctx->tos];
- b=ctx->bn[ctx->tos+1];
+ bn_check_top(in_a);
+ bn_check_top(in_b);
+
+ a= &(ctx->bn[ctx->tos]);
+ b= &(ctx->bn[ctx->tos+1]);
if (BN_copy(a,in_a) == NULL) goto err;
if (BN_copy(b,in_b) == NULL) goto err;
if (BN_copy(a,in_a) == NULL) goto err;
if (BN_copy(b,in_b) == NULL) goto err;
@@
-89,12
+85,14
@@
err:
return(ret);
}
return(ret);
}
-static BIGNUM *euclid(a,b)
-BIGNUM *a,*b;
+static BIGNUM *euclid(BIGNUM *a, BIGNUM *b)
{
BIGNUM *t;
int shifts=0;
{
BIGNUM *t;
int shifts=0;
+ bn_check_top(a);
+ bn_check_top(b);
+
for (;;)
{
if (BN_is_zero(b))
for (;;)
{
if (BN_is_zero(b))
@@
-142,23
+140,26
@@
err:
}
/* solves ax == 1 (mod n) */
}
/* solves ax == 1 (mod n) */
-BIGNUM *BN_mod_inverse(a, n, ctx)
-BIGNUM *a;
-BIGNUM *n;
-BN_CTX *ctx;
+BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
{
BIGNUM *A,*B,*X,*Y,*M,*D,*R;
{
BIGNUM *A,*B,*X,*Y,*M,*D,*R;
- BIGNUM *
ret=NULL,*T
;
+ BIGNUM *
T,*ret=NULL
;
int sign;
int sign;
- A=ctx->bn[ctx->tos];
- B=ctx->bn[ctx->tos+1];
- X=ctx->bn[ctx->tos+2];
- D=ctx->bn[ctx->tos+3];
- M=ctx->bn[ctx->tos+4];
- Y=ctx->bn[ctx->tos+5];
+ bn_check_top(a);
+ bn_check_top(n);
+
+ A= &(ctx->bn[ctx->tos]);
+ B= &(ctx->bn[ctx->tos+1]);
+ X= &(ctx->bn[ctx->tos+2]);
+ D= &(ctx->bn[ctx->tos+3]);
+ M= &(ctx->bn[ctx->tos+4]);
+ Y= &(ctx->bn[ctx->tos+5]);
ctx->tos+=6;
ctx->tos+=6;
- R=BN_new();
+ if (in == NULL)
+ R=BN_new();
+ else
+ R=in;
if (R == NULL) goto err;
BN_zero(X);
if (R == NULL) goto err;
BN_zero(X);
@@
-175,7
+176,7
@@
BN_CTX *ctx;
B=M;
/* T has a struct, M does not */
B=M;
/* T has a struct, M does not */
- if (!BN_mul(T,D,X)) goto err;
+ if (!BN_mul(T,D,X
,ctx
)) goto err;
if (!BN_add(T,T,Y)) goto err;
M=Y;
Y=X;
if (!BN_add(T,T,Y)) goto err;
M=Y;
Y=X;
@@
-196,7
+197,7
@@
BN_CTX *ctx;
}
ret=R;
err:
}
ret=R;
err:
- if ((ret == NULL) && (
R !
= NULL)) BN_free(R);
+ if ((ret == NULL) && (
in =
= NULL)) BN_free(R);
ctx->tos-=6;
return(ret);
}
ctx->tos-=6;
return(ret);
}