~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to crypto/seed/seed.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-01 23:51:53 UTC
  • mfrom: (11.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20110501235153-bjcxitndquaezb68
Tags: 1.0.0d-2ubuntu1
* Resynchronise with Debian (LP: #675566).  Remaining changes:
  - debian/libssl1.0.0.postinst:
    + Display a system restart required notification bubble on libssl1.0.0
      upgrade.
    + 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: i486, i586 (on
      i386), v8 (on sparc).
    + Fix Makefile to properly clean up libs/ dirs in clean target.
    + Replace duplicate files in the doc directory with symlinks.
* Update architectures affected by Bsymbolic-functions.patch.
* Drop debian/patches/no-sslv2.patch; Debian now adds the 'no-ssl2'
  configure option, which compiles out SSLv2 support entirely, so this is
  no longer needed.
* Drop openssl-doc in favour of the libssl-doc package introduced by
  Debian.  Add Conflicts/Replaces until the next LTS release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include <openssl/seed.h>
36
36
#include "seed_locl.h"
37
37
 
38
 
static seed_word SS[4][256] = { {
 
38
static const seed_word SS[4][256] = {   {
39
39
        0x2989a1a8, 0x05858184, 0x16c6d2d4, 0x13c3d3d0, 0x14445054, 0x1d0d111c, 0x2c8ca0ac, 0x25052124,
40
40
        0x1d4d515c, 0x03434340, 0x18081018, 0x1e0e121c, 0x11415150, 0x3cccf0fc, 0x0acac2c8, 0x23436360,
41
41
        0x28082028, 0x04444044, 0x20002020, 0x1d8d919c, 0x20c0e0e0, 0x22c2e2e0, 0x08c8c0c8, 0x17071314,
187
187
#define KC14    0xde6e678d
188
188
#define KC15    0xbcdccf1b
189
189
 
 
190
#if defined(OPENSSL_SMALL_FOOTPRINT)
 
191
static const seed_word KC[] = {
 
192
        KC0,    KC1,    KC2,    KC3,    KC4,    KC5,    KC6,    KC7,
 
193
        KC8,    KC9,    KC10,   KC11,   KC12,   KC13,   KC14,   KC15    };
 
194
#endif
190
195
 
191
196
void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], SEED_KEY_SCHEDULE *ks)
192
197
{
201
206
        t0 = (x1 + x3 - KC0) & 0xffffffff;
202
207
        t1 = (x2 - x4 + KC0) & 0xffffffff;                     KEYUPDATE_TEMP(t0, t1, &ks->data[0]);
203
208
        KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC1);      KEYUPDATE_TEMP(t0, t1, &ks->data[2]);
 
209
 
 
210
#if !defined(OPENSSL_SMALL_FOOTPRINT)
204
211
        KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC2);      KEYUPDATE_TEMP(t0, t1, &ks->data[4]);
205
212
        KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC3);      KEYUPDATE_TEMP(t0, t1, &ks->data[6]);
206
213
        KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC4);      KEYUPDATE_TEMP(t0, t1, &ks->data[8]);
215
222
        KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC13);     KEYUPDATE_TEMP(t0, t1, &ks->data[26]);
216
223
        KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC14);     KEYUPDATE_TEMP(t0, t1, &ks->data[28]);
217
224
        KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC15);     KEYUPDATE_TEMP(t0, t1, &ks->data[30]);
 
225
#else
 
226
        {
 
227
            int i;
 
228
            for (i=2; i<16; i+=2) {
 
229
                KEYSCHEDULE_UPDATE0(t0, t1, x1, x2, x3, x4, KC[i]);
 
230
                KEYUPDATE_TEMP(t0, t1, &ks->data[i*2]);
 
231
                KEYSCHEDULE_UPDATE1(t0, t1, x1, x2, x3, x4, KC[i+1]);
 
232
                KEYUPDATE_TEMP(t0, t1, &ks->data[i*2+2]);
 
233
            }
 
234
        }
 
235
#endif
218
236
}
219
237
 
220
238
void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], unsigned char d[SEED_BLOCK_SIZE], const SEED_KEY_SCHEDULE *ks)
226
244
        char2word(s+4,  x2);
227
245
        char2word(s+8,  x3);
228
246
        char2word(s+12, x4);
229
 
        
 
247
 
 
248
#if !defined(OPENSSL_SMALL_FOOTPRINT)   
230
249
        E_SEED(t0, t1, x1, x2, x3, x4, 0);
231
250
        E_SEED(t0, t1, x3, x4, x1, x2, 2);
232
251
        E_SEED(t0, t1, x1, x2, x3, x4, 4);
243
262
        E_SEED(t0, t1, x3, x4, x1, x2, 26);
244
263
        E_SEED(t0, t1, x1, x2, x3, x4, 28);
245
264
        E_SEED(t0, t1, x3, x4, x1, x2, 30);
 
265
#else
 
266
        {
 
267
            int i;
 
268
            for (i=0;i<30;i+=4) {
 
269
                E_SEED(t0,t1,x1,x2,x3,x4,i);
 
270
                E_SEED(t0,t1,x3,x4,x1,x2,i+2);
 
271
            }
 
272
        }
 
273
#endif
246
274
 
247
275
        word2char(x3, d);
248
276
        word2char(x4, d+4);
259
287
        char2word(s+4,  x2);
260
288
        char2word(s+8,  x3);
261
289
        char2word(s+12, x4);
262
 
        
 
290
 
 
291
#if !defined(OPENSSL_SMALL_FOOTPRINT)
263
292
        E_SEED(t0, t1, x1, x2, x3, x4, 30);
264
293
        E_SEED(t0, t1, x3, x4, x1, x2, 28);
265
294
        E_SEED(t0, t1, x1, x2, x3, x4, 26);
276
305
        E_SEED(t0, t1, x3, x4, x1, x2, 4);
277
306
        E_SEED(t0, t1, x1, x2, x3, x4, 2);
278
307
        E_SEED(t0, t1, x3, x4, x1, x2, 0);
 
308
#else
 
309
        {
 
310
            int i;
 
311
            for (i=30; i>0; i-=4) {
 
312
                E_SEED(t0, t1, x1, x2, x3, x4, i);
 
313
                E_SEED(t0, t1, x3, x4, x1, x2, i-2);
 
314
 
 
315
            }
 
316
        }
 
317
#endif
279
318
 
280
319
        word2char(x3, d);
281
320
        word2char(x4, d+4);