~ubuntu-branches/ubuntu/precise/dropbear/precise

« back to all changes in this revision

Viewing changes to libtomcrypt/src/ciphers/noekeon.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerrit Pape
  • Date: 2007-03-02 20:48:18 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070302204818-ozmbou2sbyj7dus5
Tags: 0.49-1
* new upstream release, fixes
  * CVE-2007-1099: dropbear dbclient insufficient warning on hostkey
    mismatch (closes: #412899).
  * dbclient uses static "Password:" prompt instead of using the server's
    prompt (closes: #394996).
* debian/control: Suggests: openssh-client, not ssh (closes: #405686);
  Standards-Version: 3.7.2.2.
* debian/README.Debian: ssh -> openssh-server, openssh-client; remove
  'Replacing OpenSSH "sshd" with Dropbear' part, this is simply done by not
  installing the openssh-server package.
* debian/README.runit: runsvstat -> sv status.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * The library is free for all purposes without any express
7
7
 * guarantee it works.
8
8
 *
9
 
 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
 
9
 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
10
10
 */
11
11
/**
12
12
   @file noekeon.c
27
27
    &noekeon_test,
28
28
    &noekeon_done,
29
29
    &noekeon_keysize,
30
 
    NULL, NULL, NULL, NULL, NULL, NULL, NULL
 
30
    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
31
31
};
32
32
 
33
33
static const ulong32 RC[] = {
107
107
  @param pt The input plaintext (16 bytes)
108
108
  @param ct The output ciphertext (16 bytes)
109
109
  @param skey The key as scheduled
 
110
  @return CRYPT_OK if successful
110
111
*/
111
112
#ifdef LTC_CLEAN_STACK
112
 
static void _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
 
113
static int _noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
113
114
#else
114
 
void noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
 
115
int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
115
116
#endif
116
117
{
117
118
   ulong32 a,b,c,d,temp;
142
143
   
143
144
   STORE32H(a,&ct[0]); STORE32H(b,&ct[4]);
144
145
   STORE32H(c,&ct[8]); STORE32H(d,&ct[12]);
 
146
 
 
147
   return CRYPT_OK;
145
148
}
146
149
 
147
150
#ifdef LTC_CLEAN_STACK
148
 
void noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
 
151
int noekeon_ecb_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_key *skey)
149
152
{
150
 
   _noekeon_ecb_encrypt(pt, ct, skey);
 
153
   int err = _noekeon_ecb_encrypt(pt, ct, skey);
151
154
   burn_stack(sizeof(ulong32) * 5 + sizeof(int));
 
155
   return CRYPT_OK;
152
156
}
153
157
#endif
154
158
 
157
161
  @param ct The input ciphertext (16 bytes)
158
162
  @param pt The output plaintext (16 bytes)
159
163
  @param skey The key as scheduled 
 
164
  @return CRYPT_OK if successful
160
165
*/
161
166
#ifdef LTC_CLEAN_STACK
162
 
static void _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
 
167
static int _noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
163
168
#else
164
 
void noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
 
169
int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
165
170
#endif
166
171
{
167
172
   ulong32 a,b,c,d, temp;
192
197
   a ^= RC[0];
193
198
   STORE32H(a,&pt[0]); STORE32H(b, &pt[4]);
194
199
   STORE32H(c,&pt[8]); STORE32H(d, &pt[12]);
 
200
   return CRYPT_OK;
195
201
}
196
202
 
197
203
#ifdef LTC_CLEAN_STACK
198
 
void noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
 
204
int noekeon_ecb_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_key *skey)
199
205
{
200
 
   _noekeon_ecb_decrypt(ct, pt, skey);
 
206
   int err = _noekeon_ecb_decrypt(ct, pt, skey);
201
207
   burn_stack(sizeof(ulong32) * 5 + sizeof(int));
 
208
   return err;
202
209
}
203
210
#endif
204
211
 
235
242
  
236
243
    noekeon_ecb_encrypt(tests[i].pt, tmp[0], &key);
237
244
    noekeon_ecb_decrypt(tmp[0], tmp[1], &key);
238
 
    if (memcmp(tmp[0], tests[i].ct, 16) || memcmp(tmp[1], tests[i].pt, 16)) { 
 
245
    if (XMEMCMP(tmp[0], tests[i].ct, 16) || XMEMCMP(tmp[1], tests[i].pt, 16)) { 
239
246
#if 0
240
247
       printf("\n\nTest %d failed\n", i);
241
 
       if (memcmp(tmp[0], tests[i].ct, 16)) {
 
248
       if (XMEMCMP(tmp[0], tests[i].ct, 16)) {
242
249
          printf("CT: ");
243
250
          for (i = 0; i < 16; i++) {
244
251
             printf("%02x ", tmp[0][i]);
292
299
 
293
300
 
294
301
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/noekeon.c,v $ */
295
 
/* $Revision: 1.7 $ */
296
 
/* $Date: 2005/05/05 14:35:58 $ */
 
302
/* $Revision: 1.12 $ */
 
303
/* $Date: 2006/11/08 23:01:06 $ */