~ubuntu-branches/ubuntu/utopic/openssl/utopic

« back to all changes in this revision

Viewing changes to crypto/bn/bn_blind.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-11 13:27:31 UTC
  • mfrom: (11.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120211132731-ff58ncra13oof2r1
Tags: 1.0.0g-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification on libssl1.0.0
      upgrade on servers.
    + Use a different priority for libssl1.0.0/restart-services depending
      on whether a desktop, or server dist-upgrade is being performed.
  - debian/{libssl1.0.0-udeb.dirs, control, rules}: Create
    libssl1.0.0-udeb, for the benefit of wget-udeb (no wget-udeb package
    in Debian).
  - debian/{libcrypto1.0.0-udeb.dirs, libssl1.0.0.dirs, libssl1.0.0.files,
    rules}: Move runtime libraries to /lib, for the benefit of
    wpasupplicant.
  - debian/patches/aesni.patch: Backport Intel AES-NI support, now from
    http://rt.openssl.org/Ticket/Display.html?id=2065 rather than the
    0.9.8 variant.
  - debian/patches/Bsymbolic-functions.patch: Link using
    -Bsymbolic-functions.
  - debian/patches/perlpath-quilt.patch: Don't change perl #! paths under
    .pc.
  - debian/rules:
    + Don't run 'make test' when cross-building.
    + Use host compiler when cross-building.  Patch from Neil Williams.
    + Don't build for processors no longer supported: i586 (on i386)
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
  - Unapply patch c_rehash-multi and comment it out in the series as it
    breaks parsing of certificates with CRLF line endings and other cases
    (see Debian #642314 for discussion), it also changes the semantics of
    c_rehash directories by requiring applications to parse hash link
    targets as files containing potentially *multiple* certificates
    rather than exactly one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
                                  * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */
127
127
#endif
128
128
        CRYPTO_THREADID tid;
129
 
        unsigned int  counter;
 
129
        int counter;
130
130
        unsigned long flags;
131
131
        BN_MONT_CTX *m_ctx;
132
132
        int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
160
160
        if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)
161
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
167
        CRYPTO_THREADID_current(&ret->tid);
165
168
        return(ret);
166
169
err:
190
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
200
                !(b->flags & BN_BLINDING_NO_RECREATE))
195
201
                {
196
202
                /* re-create blinding parameters */
205
211
 
206
212
        ret=1;
207
213
err:
208
 
        if (b->counter == 0)
209
 
                b->counter = BN_BLINDING_COUNTER;
 
214
        if (b->counter == BN_BLINDING_COUNTER)
 
215
                b->counter = 0;
210
216
        return(ret);
211
217
        }
212
218
 
227
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
242
        if (r != NULL)
231
243
                {
232
244
                if (!BN_copy(r, b->Ai)) ret=0;
247
259
        int ret;
248
260
 
249
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
263
        if (r != NULL)
257
264
                ret = BN_mod_mul(n, n, r, b->mod, ctx);
258
265
        else
 
266
                {
 
267
                if (b->Ai == NULL)
 
268
                        {
 
269
                        BNerr(BN_F_BN_BLINDING_INVERT_EX,BN_R_NOT_INITIALIZED);
 
270
                        return(0);
 
271
                        }
259
272
                ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);
260
 
 
261
 
        if (ret >= 0)
262
 
                {
263
 
                if (!BN_BLINDING_update(b,ctx))
264
 
                        return(0);
265
273
                }
 
274
 
266
275
        bn_check_top(n);
267
276
        return(ret);
268
277
        }