aboutsummaryrefslogtreecommitdiff
path: root/openssl/crypto/jpake/jpake.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-01-23 19:50:13 +0000
committermarha <marha@users.sourceforge.net>2011-01-23 19:50:13 +0000
commitb680cf39ed5bc37e0eb7eb86ad8599bf92df3f2b (patch)
tree4722cd31e41fdda28e5c2b37bdf8500d27868384 /openssl/crypto/jpake/jpake.c
parent8cd59857a99c534c560f58c931f5c2466d4c1f9b (diff)
downloadvcxsrv-b680cf39ed5bc37e0eb7eb86ad8599bf92df3f2b.tar.gz
vcxsrv-b680cf39ed5bc37e0eb7eb86ad8599bf92df3f2b.tar.bz2
vcxsrv-b680cf39ed5bc37e0eb7eb86ad8599bf92df3f2b.zip
Updated to openssl-1.0.0c
Diffstat (limited to 'openssl/crypto/jpake/jpake.c')
-rw-r--r--openssl/crypto/jpake/jpake.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/openssl/crypto/jpake/jpake.c b/openssl/crypto/jpake/jpake.c
index 086d9f47e..8e4b633cc 100644
--- a/openssl/crypto/jpake/jpake.c
+++ b/openssl/crypto/jpake/jpake.c
@@ -282,8 +282,37 @@ int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx)
return 1;
}
+/* g^x is a legal value */
+static int is_legal(const BIGNUM *gx, const JPAKE_CTX *ctx)
+ {
+ BIGNUM *t;
+ int res;
+
+ if(BN_is_negative(gx) || BN_is_zero(gx) || BN_cmp(gx, ctx->p.p) >= 0)
+ return 0;
+
+ t = BN_new();
+ BN_mod_exp(t, gx, ctx->p.q, ctx->p.p, ctx->ctx);
+ res = BN_is_one(t);
+ BN_free(t);
+
+ return res;
+ }
+
int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received)
{
+ if(!is_legal(received->p1.gx, ctx))
+ {
+ JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL);
+ return 0;
+ }
+
+ if(!is_legal(received->p2.gx, ctx))
+ {
+ JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL);
+ return 0;
+ }
+
/* verify their ZKP(xc) */
if(!verify_zkp(&received->p1, ctx->p.g, ctx))
{