diff options
author | djm <> | 2011-11-03 02:32:21 +0000 |
---|---|---|
committer | djm <> | 2011-11-03 02:32:21 +0000 |
commit | 074782d395f8a140cd5120b87574dcd928bacd24 (patch) | |
tree | 79374ba6e81c08ba6e78220557d6f6e9ca03f7b7 /src/lib/libcrypto/jpake/jpake.c | |
parent | f6ca1ae73bb9eabfb510df2cffc2599db98d35a9 (diff) | |
download | openbsd-074782d395f8a140cd5120b87574dcd928bacd24.tar.gz openbsd-074782d395f8a140cd5120b87574dcd928bacd24.tar.bz2 openbsd-074782d395f8a140cd5120b87574dcd928bacd24.zip |
import OpenSSL 1.0.0e
Diffstat (limited to 'src/lib/libcrypto/jpake/jpake.c')
-rw-r--r-- | src/lib/libcrypto/jpake/jpake.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/lib/libcrypto/jpake/jpake.c b/src/lib/libcrypto/jpake/jpake.c index 086d9f47e0..8e4b633ccc 100644 --- a/src/lib/libcrypto/jpake/jpake.c +++ b/src/lib/libcrypto/jpake/jpake.c | |||
@@ -282,8 +282,37 @@ int JPAKE_STEP1_generate(JPAKE_STEP1 *send, JPAKE_CTX *ctx) | |||
282 | return 1; | 282 | return 1; |
283 | } | 283 | } |
284 | 284 | ||
285 | /* g^x is a legal value */ | ||
286 | static int is_legal(const BIGNUM *gx, const JPAKE_CTX *ctx) | ||
287 | { | ||
288 | BIGNUM *t; | ||
289 | int res; | ||
290 | |||
291 | if(BN_is_negative(gx) || BN_is_zero(gx) || BN_cmp(gx, ctx->p.p) >= 0) | ||
292 | return 0; | ||
293 | |||
294 | t = BN_new(); | ||
295 | BN_mod_exp(t, gx, ctx->p.q, ctx->p.p, ctx->ctx); | ||
296 | res = BN_is_one(t); | ||
297 | BN_free(t); | ||
298 | |||
299 | return res; | ||
300 | } | ||
301 | |||
285 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) | 302 | int JPAKE_STEP1_process(JPAKE_CTX *ctx, const JPAKE_STEP1 *received) |
286 | { | 303 | { |
304 | if(!is_legal(received->p1.gx, ctx)) | ||
305 | { | ||
306 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X3_IS_NOT_LEGAL); | ||
307 | return 0; | ||
308 | } | ||
309 | |||
310 | if(!is_legal(received->p2.gx, ctx)) | ||
311 | { | ||
312 | JPAKEerr(JPAKE_F_JPAKE_STEP1_PROCESS, JPAKE_R_G_TO_THE_X4_IS_NOT_LEGAL); | ||
313 | return 0; | ||
314 | } | ||
315 | |||
287 | /* verify their ZKP(xc) */ | 316 | /* verify their ZKP(xc) */ |
288 | if(!verify_zkp(&received->p1, ctx->p.g, ctx)) | 317 | if(!verify_zkp(&received->p1, ctx->p.g, ctx)) |
289 | { | 318 | { |