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

« back to all changes in this revision

Viewing changes to libtomcrypt/src/ciphers/rc2.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
* To commemorate the 1996 RSA Data Security Conference, the following  *
36
36
   &rc2_test,
37
37
   &rc2_done,
38
38
   &rc2_keysize,
39
 
   NULL, NULL, NULL, NULL, NULL, NULL, NULL
 
39
   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
40
40
};
41
41
 
42
42
/* 256-entry permutation table, probably derived somehow from pi */
125
125
  @param pt The input plaintext (8 bytes)
126
126
  @param ct The output ciphertext (8 bytes)
127
127
  @param skey The key as scheduled
 
128
  @return CRYPT_OK if successful
128
129
*/
129
130
#ifdef LTC_CLEAN_STACK
130
 
static void _rc2_ecb_encrypt( const unsigned char *pt,
 
131
static int _rc2_ecb_encrypt( const unsigned char *pt,
131
132
                            unsigned char *ct,
132
133
                            symmetric_key *skey)
133
134
#else
134
 
void rc2_ecb_encrypt( const unsigned char *pt,
 
135
int rc2_ecb_encrypt( const unsigned char *pt,
135
136
                            unsigned char *ct,
136
137
                            symmetric_key *skey)
137
138
#endif
179
180
    ct[5] = (unsigned char)(x54 >> 8);
180
181
    ct[6] = (unsigned char)x76;
181
182
    ct[7] = (unsigned char)(x76 >> 8);
 
183
 
 
184
    return CRYPT_OK;
182
185
}
183
186
 
184
187
#ifdef LTC_CLEAN_STACK
185
 
void rc2_ecb_encrypt( const unsigned char *pt,
 
188
int rc2_ecb_encrypt( const unsigned char *pt,
186
189
                            unsigned char *ct,
187
190
                            symmetric_key *skey)
188
191
{
189
 
    _rc2_ecb_encrypt(pt, ct, skey);
 
192
    int err = _rc2_ecb_encrypt(pt, ct, skey);
190
193
    burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 5);
 
194
    return err;
191
195
}
192
196
#endif
193
197
 
199
203
  @param ct The input ciphertext (8 bytes)
200
204
  @param pt The output plaintext (8 bytes)
201
205
  @param skey The key as scheduled 
 
206
  @return CRYPT_OK if successful
202
207
*/
203
208
#ifdef LTC_CLEAN_STACK
204
 
static void _rc2_ecb_decrypt( const unsigned char *ct,
 
209
static int _rc2_ecb_decrypt( const unsigned char *ct,
205
210
                            unsigned char *pt,
206
211
                            symmetric_key *skey)
207
212
#else
208
 
void rc2_ecb_decrypt( const unsigned char *ct,
 
213
int rc2_ecb_decrypt( const unsigned char *ct,
209
214
                            unsigned char *pt,
210
215
                            symmetric_key *skey)
211
216
#endif
254
259
    pt[5] = (unsigned char)(x54 >> 8);
255
260
    pt[6] = (unsigned char)x76;
256
261
    pt[7] = (unsigned char)(x76 >> 8);
 
262
 
 
263
    return CRYPT_OK;
257
264
}
258
265
 
259
266
#ifdef LTC_CLEAN_STACK
260
 
void rc2_ecb_decrypt( const unsigned char *ct,
 
267
int rc2_ecb_decrypt( const unsigned char *ct,
261
268
                            unsigned char *pt,
262
269
                            symmetric_key *skey)
263
270
{
264
 
    _rc2_ecb_decrypt(ct, pt, skey);
 
271
    int err = _rc2_ecb_decrypt(ct, pt, skey);
265
272
    burn_stack(sizeof(unsigned *) + sizeof(unsigned) * 4 + sizeof(int));
 
273
    return err;
266
274
}
267
275
#endif
268
276
 
307
315
        rc2_ecb_encrypt(tests[x].pt, tmp[0], &skey);
308
316
        rc2_ecb_decrypt(tmp[0], tmp[1], &skey);
309
317
        
310
 
        if (memcmp(tmp[0], tests[x].ct, 8) != 0 || memcmp(tmp[1], tests[x].pt, 8) != 0) {
 
318
        if (XMEMCMP(tmp[0], tests[x].ct, 8) != 0 || XMEMCMP(tmp[1], tests[x].pt, 8) != 0) {
311
319
           return CRYPT_FAIL_TESTVECTOR;
312
320
        }
313
321
 
350
358
 
351
359
 
352
360
/* $Source: /cvs/libtom/libtomcrypt/src/ciphers/rc2.c,v $ */
353
 
/* $Revision: 1.7 $ */
354
 
/* $Date: 2005/05/05 14:35:58 $ */
 
361
/* $Revision: 1.12 $ */
 
362
/* $Date: 2006/11/08 23:01:06 $ */