diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/bio/bf_buff.c | 15 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio.h | 9 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/asm/ppc.pl | 2 | ||||
| -rwxr-xr-x | src/lib/libcrypto/bn/asm/x86-mont.pl | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_blind.c | 37 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/opensslv.h | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_eay.c | 80 | ||||
| -rw-r--r-- | src/lib/libcrypto/util/mkerr.pl | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 2 |
10 files changed, 101 insertions, 58 deletions
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c index c1fd75aaad..4b5a132d8a 100644 --- a/src/lib/libcrypto/bio/bf_buff.c +++ b/src/lib/libcrypto/bio/bf_buff.c | |||
| @@ -209,7 +209,7 @@ start: | |||
| 209 | /* add to buffer and return */ | 209 | /* add to buffer and return */ |
| 210 | if (i >= inl) | 210 | if (i >= inl) |
| 211 | { | 211 | { |
| 212 | memcpy(&(ctx->obuf[ctx->obuf_len]),in,inl); | 212 | memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,inl); |
| 213 | ctx->obuf_len+=inl; | 213 | ctx->obuf_len+=inl; |
| 214 | return(num+inl); | 214 | return(num+inl); |
| 215 | } | 215 | } |
| @@ -219,7 +219,7 @@ start: | |||
| 219 | { | 219 | { |
| 220 | if (i > 0) /* lets fill it up if we can */ | 220 | if (i > 0) /* lets fill it up if we can */ |
| 221 | { | 221 | { |
| 222 | memcpy(&(ctx->obuf[ctx->obuf_len]),in,i); | 222 | memcpy(&(ctx->obuf[ctx->obuf_off+ctx->obuf_len]),in,i); |
| 223 | in+=i; | 223 | in+=i; |
| 224 | inl-=i; | 224 | inl-=i; |
| 225 | num+=i; | 225 | num+=i; |
| @@ -294,9 +294,9 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 294 | case BIO_C_GET_BUFF_NUM_LINES: | 294 | case BIO_C_GET_BUFF_NUM_LINES: |
| 295 | ret=0; | 295 | ret=0; |
| 296 | p1=ctx->ibuf; | 296 | p1=ctx->ibuf; |
| 297 | for (i=ctx->ibuf_off; i<ctx->ibuf_len; i++) | 297 | for (i=0; i<ctx->ibuf_len; i++) |
| 298 | { | 298 | { |
| 299 | if (p1[i] == '\n') ret++; | 299 | if (p1[ctx->ibuf_off + i] == '\n') ret++; |
| 300 | } | 300 | } |
| 301 | break; | 301 | break; |
| 302 | case BIO_CTRL_WPENDING: | 302 | case BIO_CTRL_WPENDING: |
| @@ -399,17 +399,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | |||
| 399 | for (;;) | 399 | for (;;) |
| 400 | { | 400 | { |
| 401 | BIO_clear_retry_flags(b); | 401 | BIO_clear_retry_flags(b); |
| 402 | if (ctx->obuf_len > ctx->obuf_off) | 402 | if (ctx->obuf_len > 0) |
| 403 | { | 403 | { |
| 404 | r=BIO_write(b->next_bio, | 404 | r=BIO_write(b->next_bio, |
| 405 | &(ctx->obuf[ctx->obuf_off]), | 405 | &(ctx->obuf[ctx->obuf_off]), |
| 406 | ctx->obuf_len-ctx->obuf_off); | 406 | ctx->obuf_len); |
| 407 | #if 0 | 407 | #if 0 |
| 408 | fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_off,r); | 408 | fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len,r); |
| 409 | #endif | 409 | #endif |
| 410 | BIO_copy_next_retry(b); | 410 | BIO_copy_next_retry(b); |
| 411 | if (r <= 0) return((long)r); | 411 | if (r <= 0) return((long)r); |
| 412 | ctx->obuf_off+=r; | 412 | ctx->obuf_off+=r; |
| 413 | ctx->obuf_len-=r; | ||
| 413 | } | 414 | } |
| 414 | else | 415 | else |
| 415 | { | 416 | { |
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 152802fbdf..ab47abcf14 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
| @@ -306,6 +306,15 @@ DECLARE_STACK_OF(BIO) | |||
| 306 | 306 | ||
| 307 | typedef struct bio_f_buffer_ctx_struct | 307 | typedef struct bio_f_buffer_ctx_struct |
| 308 | { | 308 | { |
| 309 | /* Buffers are setup like this: | ||
| 310 | * | ||
| 311 | * <---------------------- size -----------------------> | ||
| 312 | * +---------------------------------------------------+ | ||
| 313 | * | consumed | remaining | free space | | ||
| 314 | * +---------------------------------------------------+ | ||
| 315 | * <-- off --><------- len -------> | ||
| 316 | */ | ||
| 317 | |||
| 309 | /* BIO *bio; */ /* this is now in the BIO struct */ | 318 | /* BIO *bio; */ /* this is now in the BIO struct */ |
| 310 | int ibuf_size; /* how big is the input buffer */ | 319 | int ibuf_size; /* how big is the input buffer */ |
| 311 | int obuf_size; /* how big is the output buffer */ | 320 | int obuf_size; /* how big is the output buffer */ |
diff --git a/src/lib/libcrypto/bn/asm/ppc.pl b/src/lib/libcrypto/bn/asm/ppc.pl index 37c65d3511..f4093177e6 100644 --- a/src/lib/libcrypto/bn/asm/ppc.pl +++ b/src/lib/libcrypto/bn/asm/ppc.pl | |||
| @@ -949,7 +949,7 @@ $data=<<EOF; | |||
| 949 | addze r11,r0 | 949 | addze r11,r0 |
| 950 | #mul_add_c(a[3],b[2],c3,c1,c2); | 950 | #mul_add_c(a[3],b[2],c3,c1,c2); |
| 951 | $LD r6,`3*$BNSZ`(r4) | 951 | $LD r6,`3*$BNSZ`(r4) |
| 952 | $LD r7,`2*$BNSZ`(r4) | 952 | $LD r7,`2*$BNSZ`(r5) |
| 953 | $UMULL r8,r6,r7 | 953 | $UMULL r8,r6,r7 |
| 954 | $UMULH r9,r6,r7 | 954 | $UMULH r9,r6,r7 |
| 955 | addc r12,r8,r12 | 955 | addc r12,r8,r12 |
diff --git a/src/lib/libcrypto/bn/asm/x86-mont.pl b/src/lib/libcrypto/bn/asm/x86-mont.pl index 5cd3cd2ed5..e8f6b05084 100755 --- a/src/lib/libcrypto/bn/asm/x86-mont.pl +++ b/src/lib/libcrypto/bn/asm/x86-mont.pl | |||
| @@ -527,8 +527,10 @@ $sbit=$num; | |||
| 527 | &jle (&label("sqradd")); | 527 | &jle (&label("sqradd")); |
| 528 | 528 | ||
| 529 | &mov ($carry,"edx"); | 529 | &mov ($carry,"edx"); |
| 530 | &lea ("edx",&DWP(0,$sbit,"edx",2)); | 530 | &add ("edx","edx"); |
| 531 | &shr ($carry,31); | 531 | &shr ($carry,31); |
| 532 | &add ("edx",$sbit); | ||
| 533 | &adc ($carry,0); | ||
| 532 | &set_label("sqrlast"); | 534 | &set_label("sqrlast"); |
| 533 | &mov ($word,$_n0); | 535 | &mov ($word,$_n0); |
| 534 | &mov ($inp,$_np); | 536 | &mov ($inp,$_np); |
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c index e060592fdc..9ed8bc2b40 100644 --- a/src/lib/libcrypto/bn/bn_blind.c +++ b/src/lib/libcrypto/bn/bn_blind.c | |||
| @@ -126,7 +126,7 @@ struct bn_blinding_st | |||
| 126 | * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ | 126 | * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ |
| 127 | #endif | 127 | #endif |
| 128 | CRYPTO_THREADID tid; | 128 | CRYPTO_THREADID tid; |
| 129 | unsigned int counter; | 129 | int counter; |
| 130 | unsigned long flags; | 130 | unsigned long flags; |
| 131 | BN_MONT_CTX *m_ctx; | 131 | BN_MONT_CTX *m_ctx; |
| 132 | int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 132 | int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
| @@ -160,7 +160,10 @@ BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod) | |||
| 160 | if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0) | 160 | if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0) |
| 161 | BN_set_flags(ret->mod, BN_FLG_CONSTTIME); | 161 | BN_set_flags(ret->mod, BN_FLG_CONSTTIME); |
| 162 | 162 | ||
| 163 | ret->counter = BN_BLINDING_COUNTER; | 163 | /* Set the counter to the special value -1 |
| 164 | * to indicate that this is never-used fresh blinding | ||
| 165 | * that does not need updating before first use. */ | ||
| 166 | ret->counter = -1; | ||
| 164 | CRYPTO_THREADID_current(&ret->tid); | 167 | CRYPTO_THREADID_current(&ret->tid); |
| 165 | return(ret); | 168 | return(ret); |
| 166 | err: | 169 | err: |
| @@ -190,7 +193,10 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) | |||
| 190 | goto err; | 193 | goto err; |
| 191 | } | 194 | } |
| 192 | 195 | ||
| 193 | if (--(b->counter) == 0 && b->e != NULL && | 196 | if (b->counter == -1) |
| 197 | b->counter = 0; | ||
| 198 | |||
| 199 | if (++b->counter == BN_BLINDING_COUNTER && b->e != NULL && | ||
| 194 | !(b->flags & BN_BLINDING_NO_RECREATE)) | 200 | !(b->flags & BN_BLINDING_NO_RECREATE)) |
| 195 | { | 201 | { |
| 196 | /* re-create blinding parameters */ | 202 | /* re-create blinding parameters */ |
| @@ -205,8 +211,8 @@ int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) | |||
| 205 | 211 | ||
| 206 | ret=1; | 212 | ret=1; |
| 207 | err: | 213 | err: |
| 208 | if (b->counter == 0) | 214 | if (b->counter == BN_BLINDING_COUNTER) |
| 209 | b->counter = BN_BLINDING_COUNTER; | 215 | b->counter = 0; |
| 210 | return(ret); | 216 | return(ret); |
| 211 | } | 217 | } |
| 212 | 218 | ||
| @@ -227,6 +233,12 @@ int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) | |||
| 227 | return(0); | 233 | return(0); |
| 228 | } | 234 | } |
| 229 | 235 | ||
| 236 | if (b->counter == -1) | ||
| 237 | /* Fresh blinding, doesn't need updating. */ | ||
| 238 | b->counter = 0; | ||
| 239 | else if (!BN_BLINDING_update(b,ctx)) | ||
| 240 | return(0); | ||
| 241 | |||
| 230 | if (r != NULL) | 242 | if (r != NULL) |
| 231 | { | 243 | { |
| 232 | if (!BN_copy(r, b->Ai)) ret=0; | 244 | if (!BN_copy(r, b->Ai)) ret=0; |
| @@ -247,22 +259,19 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ct | |||
| 247 | int ret; | 259 | int ret; |
| 248 | 260 | ||
| 249 | bn_check_top(n); | 261 | bn_check_top(n); |
| 250 | if ((b->A == NULL) || (b->Ai == NULL)) | ||
| 251 | { | ||
| 252 | BNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED); | ||
| 253 | return(0); | ||
| 254 | } | ||
| 255 | 262 | ||
| 256 | if (r != NULL) | 263 | if (r != NULL) |
| 257 | ret = BN_mod_mul(n, n, r, b->mod, ctx); | 264 | ret = BN_mod_mul(n, n, r, b->mod, ctx); |
| 258 | else | 265 | else |
| 259 | ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); | ||
| 260 | |||
| 261 | if (ret >= 0) | ||
| 262 | { | 266 | { |
| 263 | if (!BN_BLINDING_update(b,ctx)) | 267 | if (b->Ai == NULL) |
| 268 | { | ||
| 269 | BNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED); | ||
| 264 | return(0); | 270 | return(0); |
| 271 | } | ||
| 272 | ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); | ||
| 265 | } | 273 | } |
| 274 | |||
| 266 | bn_check_top(n); | 275 | bn_check_top(n); |
| 267 | return(ret); | 276 | return(ret); |
| 268 | } | 277 | } |
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index af94458ca7..03deae6674 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
| @@ -887,7 +887,7 @@ int ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_ | |||
| 887 | field_sqr = group->meth->field_sqr; | 887 | field_sqr = group->meth->field_sqr; |
| 888 | 888 | ||
| 889 | /* only support affine coordinates */ | 889 | /* only support affine coordinates */ |
| 890 | if (!point->Z_is_one) goto err; | 890 | if (!point->Z_is_one) return -1; |
| 891 | 891 | ||
| 892 | if (ctx == NULL) | 892 | if (ctx == NULL) |
| 893 | { | 893 | { |
diff --git a/src/lib/libcrypto/opensslv.h b/src/lib/libcrypto/opensslv.h index 310a3387be..d6d61a0c7d 100644 --- a/src/lib/libcrypto/opensslv.h +++ b/src/lib/libcrypto/opensslv.h | |||
| @@ -25,11 +25,11 @@ | |||
| 25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for | 25 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for |
| 26 | * major minor fix final patch/beta) | 26 | * major minor fix final patch/beta) |
| 27 | */ | 27 | */ |
| 28 | #define OPENSSL_VERSION_NUMBER 0x1000005fL | 28 | #define OPENSSL_VERSION_NUMBER 0x1000006fL |
| 29 | #ifdef OPENSSL_FIPS | 29 | #ifdef OPENSSL_FIPS |
| 30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e-fips 6 Sep 2011" | 30 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0f-fips 4 Jan 2012" |
| 31 | #else | 31 | #else |
| 32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0e 6 Sep 2011" | 32 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.0.0f 4 Jan 2012" |
| 33 | #endif | 33 | #endif |
| 34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT | 34 | #define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT |
| 35 | 35 | ||
diff --git a/src/lib/libcrypto/rsa/rsa_eay.c b/src/lib/libcrypto/rsa/rsa_eay.c index 7c941885f0..2e1ddd48d3 100644 --- a/src/lib/libcrypto/rsa/rsa_eay.c +++ b/src/lib/libcrypto/rsa/rsa_eay.c | |||
| @@ -314,51 +314,56 @@ static BN_BLINDING *rsa_get_blinding(RSA *rsa, int *local, BN_CTX *ctx) | |||
| 314 | return ret; | 314 | return ret; |
| 315 | } | 315 | } |
| 316 | 316 | ||
| 317 | static int rsa_blinding_convert(BN_BLINDING *b, int local, BIGNUM *f, | 317 | static int rsa_blinding_convert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, |
| 318 | BIGNUM *r, BN_CTX *ctx) | 318 | BN_CTX *ctx) |
| 319 | { | 319 | { |
| 320 | if (local) | 320 | if (unblind == NULL) |
| 321 | /* Local blinding: store the unblinding factor | ||
| 322 | * in BN_BLINDING. */ | ||
| 321 | return BN_BLINDING_convert_ex(f, NULL, b, ctx); | 323 | return BN_BLINDING_convert_ex(f, NULL, b, ctx); |
| 322 | else | 324 | else |
| 323 | { | 325 | { |
| 324 | int ret; | 326 | /* Shared blinding: store the unblinding factor |
| 325 | CRYPTO_r_lock(CRYPTO_LOCK_RSA_BLINDING); | 327 | * outside BN_BLINDING. */ |
| 326 | ret = BN_BLINDING_convert_ex(f, r, b, ctx); | ||
| 327 | CRYPTO_r_unlock(CRYPTO_LOCK_RSA_BLINDING); | ||
| 328 | return ret; | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | static int rsa_blinding_invert(BN_BLINDING *b, int local, BIGNUM *f, | ||
| 333 | BIGNUM *r, BN_CTX *ctx) | ||
| 334 | { | ||
| 335 | if (local) | ||
| 336 | return BN_BLINDING_invert_ex(f, NULL, b, ctx); | ||
| 337 | else | ||
| 338 | { | ||
| 339 | int ret; | 328 | int ret; |
| 340 | CRYPTO_w_lock(CRYPTO_LOCK_RSA_BLINDING); | 329 | CRYPTO_w_lock(CRYPTO_LOCK_RSA_BLINDING); |
| 341 | ret = BN_BLINDING_invert_ex(f, r, b, ctx); | 330 | ret = BN_BLINDING_convert_ex(f, unblind, b, ctx); |
| 342 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA_BLINDING); | 331 | CRYPTO_w_unlock(CRYPTO_LOCK_RSA_BLINDING); |
| 343 | return ret; | 332 | return ret; |
| 344 | } | 333 | } |
| 345 | } | 334 | } |
| 335 | |||
| 336 | static int rsa_blinding_invert(BN_BLINDING *b, BIGNUM *f, BIGNUM *unblind, | ||
| 337 | BN_CTX *ctx) | ||
| 338 | { | ||
| 339 | /* For local blinding, unblind is set to NULL, and BN_BLINDING_invert_ex | ||
| 340 | * will use the unblinding factor stored in BN_BLINDING. | ||
| 341 | * If BN_BLINDING is shared between threads, unblind must be non-null: | ||
| 342 | * BN_BLINDING_invert_ex will then use the local unblinding factor, | ||
| 343 | * and will only read the modulus from BN_BLINDING. | ||
| 344 | * In both cases it's safe to access the blinding without a lock. | ||
| 345 | */ | ||
| 346 | return BN_BLINDING_invert_ex(f, unblind, b, ctx); | ||
| 347 | } | ||
| 346 | 348 | ||
| 347 | /* signing */ | 349 | /* signing */ |
| 348 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | 350 | static int RSA_eay_private_encrypt(int flen, const unsigned char *from, |
| 349 | unsigned char *to, RSA *rsa, int padding) | 351 | unsigned char *to, RSA *rsa, int padding) |
| 350 | { | 352 | { |
| 351 | BIGNUM *f, *ret, *br, *res; | 353 | BIGNUM *f, *ret, *res; |
| 352 | int i,j,k,num=0,r= -1; | 354 | int i,j,k,num=0,r= -1; |
| 353 | unsigned char *buf=NULL; | 355 | unsigned char *buf=NULL; |
| 354 | BN_CTX *ctx=NULL; | 356 | BN_CTX *ctx=NULL; |
| 355 | int local_blinding = 0; | 357 | int local_blinding = 0; |
| 358 | /* Used only if the blinding structure is shared. A non-NULL unblind | ||
| 359 | * instructs rsa_blinding_convert() and rsa_blinding_invert() to store | ||
| 360 | * the unblinding factor outside the blinding structure. */ | ||
| 361 | BIGNUM *unblind = NULL; | ||
| 356 | BN_BLINDING *blinding = NULL; | 362 | BN_BLINDING *blinding = NULL; |
| 357 | 363 | ||
| 358 | if ((ctx=BN_CTX_new()) == NULL) goto err; | 364 | if ((ctx=BN_CTX_new()) == NULL) goto err; |
| 359 | BN_CTX_start(ctx); | 365 | BN_CTX_start(ctx); |
| 360 | f = BN_CTX_get(ctx); | 366 | f = BN_CTX_get(ctx); |
| 361 | br = BN_CTX_get(ctx); | ||
| 362 | ret = BN_CTX_get(ctx); | 367 | ret = BN_CTX_get(ctx); |
| 363 | num = BN_num_bytes(rsa->n); | 368 | num = BN_num_bytes(rsa->n); |
| 364 | buf = OPENSSL_malloc(num); | 369 | buf = OPENSSL_malloc(num); |
| @@ -406,8 +411,15 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | |||
| 406 | } | 411 | } |
| 407 | 412 | ||
| 408 | if (blinding != NULL) | 413 | if (blinding != NULL) |
| 409 | if (!rsa_blinding_convert(blinding, local_blinding, f, br, ctx)) | 414 | { |
| 415 | if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) | ||
| 416 | { | ||
| 417 | RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE); | ||
| 418 | goto err; | ||
| 419 | } | ||
| 420 | if (!rsa_blinding_convert(blinding, f, unblind, ctx)) | ||
| 410 | goto err; | 421 | goto err; |
| 422 | } | ||
| 411 | 423 | ||
| 412 | if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || | 424 | if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || |
| 413 | ((rsa->p != NULL) && | 425 | ((rsa->p != NULL) && |
| @@ -441,7 +453,7 @@ static int RSA_eay_private_encrypt(int flen, const unsigned char *from, | |||
| 441 | } | 453 | } |
| 442 | 454 | ||
| 443 | if (blinding) | 455 | if (blinding) |
| 444 | if (!rsa_blinding_invert(blinding, local_blinding, ret, br, ctx)) | 456 | if (!rsa_blinding_invert(blinding, ret, unblind, ctx)) |
| 445 | goto err; | 457 | goto err; |
| 446 | 458 | ||
| 447 | if (padding == RSA_X931_PADDING) | 459 | if (padding == RSA_X931_PADDING) |
| @@ -480,18 +492,21 @@ err: | |||
| 480 | static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | 492 | static int RSA_eay_private_decrypt(int flen, const unsigned char *from, |
| 481 | unsigned char *to, RSA *rsa, int padding) | 493 | unsigned char *to, RSA *rsa, int padding) |
| 482 | { | 494 | { |
| 483 | BIGNUM *f, *ret, *br; | 495 | BIGNUM *f, *ret; |
| 484 | int j,num=0,r= -1; | 496 | int j,num=0,r= -1; |
| 485 | unsigned char *p; | 497 | unsigned char *p; |
| 486 | unsigned char *buf=NULL; | 498 | unsigned char *buf=NULL; |
| 487 | BN_CTX *ctx=NULL; | 499 | BN_CTX *ctx=NULL; |
| 488 | int local_blinding = 0; | 500 | int local_blinding = 0; |
| 501 | /* Used only if the blinding structure is shared. A non-NULL unblind | ||
| 502 | * instructs rsa_blinding_convert() and rsa_blinding_invert() to store | ||
| 503 | * the unblinding factor outside the blinding structure. */ | ||
| 504 | BIGNUM *unblind = NULL; | ||
| 489 | BN_BLINDING *blinding = NULL; | 505 | BN_BLINDING *blinding = NULL; |
| 490 | 506 | ||
| 491 | if((ctx = BN_CTX_new()) == NULL) goto err; | 507 | if((ctx = BN_CTX_new()) == NULL) goto err; |
| 492 | BN_CTX_start(ctx); | 508 | BN_CTX_start(ctx); |
| 493 | f = BN_CTX_get(ctx); | 509 | f = BN_CTX_get(ctx); |
| 494 | br = BN_CTX_get(ctx); | ||
| 495 | ret = BN_CTX_get(ctx); | 510 | ret = BN_CTX_get(ctx); |
| 496 | num = BN_num_bytes(rsa->n); | 511 | num = BN_num_bytes(rsa->n); |
| 497 | buf = OPENSSL_malloc(num); | 512 | buf = OPENSSL_malloc(num); |
| @@ -529,8 +544,15 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | |||
| 529 | } | 544 | } |
| 530 | 545 | ||
| 531 | if (blinding != NULL) | 546 | if (blinding != NULL) |
| 532 | if (!rsa_blinding_convert(blinding, local_blinding, f, br, ctx)) | 547 | { |
| 548 | if (!local_blinding && ((unblind = BN_CTX_get(ctx)) == NULL)) | ||
| 549 | { | ||
| 550 | RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE); | ||
| 533 | goto err; | 551 | goto err; |
| 552 | } | ||
| 553 | if (!rsa_blinding_convert(blinding, f, unblind, ctx)) | ||
| 554 | goto err; | ||
| 555 | } | ||
| 534 | 556 | ||
| 535 | /* do the decrypt */ | 557 | /* do the decrypt */ |
| 536 | if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || | 558 | if ( (rsa->flags & RSA_FLAG_EXT_PKEY) || |
| @@ -564,7 +586,7 @@ static int RSA_eay_private_decrypt(int flen, const unsigned char *from, | |||
| 564 | } | 586 | } |
| 565 | 587 | ||
| 566 | if (blinding) | 588 | if (blinding) |
| 567 | if (!rsa_blinding_invert(blinding, local_blinding, ret, br, ctx)) | 589 | if (!rsa_blinding_invert(blinding, ret, unblind, ctx)) |
| 568 | goto err; | 590 | goto err; |
| 569 | 591 | ||
| 570 | p=buf; | 592 | p=buf; |
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl index 2c99467d34..aec401c773 100644 --- a/src/lib/libcrypto/util/mkerr.pl +++ b/src/lib/libcrypto/util/mkerr.pl | |||
| @@ -769,7 +769,7 @@ EOF | |||
| 769 | undef %err_reason_strings; | 769 | undef %err_reason_strings; |
| 770 | } | 770 | } |
| 771 | 771 | ||
| 772 | if($debug && defined(%notrans)) { | 772 | if($debug && %notrans) { |
| 773 | print STDERR "The following function codes were not translated:\n"; | 773 | print STDERR "The following function codes were not translated:\n"; |
| 774 | foreach(sort keys %notrans) | 774 | foreach(sort keys %notrans) |
| 775 | { | 775 | { |
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 5a0b0249b4..701ec565e9 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
| @@ -1732,7 +1732,7 @@ int X509_cmp_time(const ASN1_TIME *ctm, time_t *cmp_time) | |||
| 1732 | atm.length=sizeof(buff2); | 1732 | atm.length=sizeof(buff2); |
| 1733 | atm.data=(unsigned char *)buff2; | 1733 | atm.data=(unsigned char *)buff2; |
| 1734 | 1734 | ||
| 1735 | if (X509_time_adj(&atm,-offset*60, cmp_time) == NULL) | 1735 | if (X509_time_adj(&atm, offset*60, cmp_time) == NULL) |
| 1736 | return 0; | 1736 | return 0; |
| 1737 | 1737 | ||
| 1738 | if (ctm->type == V_ASN1_UTCTIME) | 1738 | if (ctm->type == V_ASN1_UTCTIME) |
