~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to libtomcrypt/src/mac/f9/f9_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerrit Pape, Matt Johnston, Gerrit Pape
  • Date: 2008-03-27 20:08:06 UTC
  • mfrom: (1.4.1 upstream) (9 hardy)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20080327200806-c1hhdgt3ht2gk496
Tags: 0.51-1
[ Matt Johnston ]
* New upstream release.
  - Wait until a process exits before the server closes a connection,
    so that an exit code can be sent. This fixes problems with exit
    codes not being returned, which could cause scp to fail (closes:
    #448397, #472483).

[ Gerrit Pape ]
* debian/dropbear.postinst: don't print an error message if the
  update-service program is not installed (thx Matt).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
 
2
 *
 
3
 * LibTomCrypt is a library that provides various cryptographic
 
4
 * algorithms in a highly modular and flexible manner.
 
5
 *
 
6
 * The library is free for all purposes without any express
 
7
 * guarantee it works.
 
8
 *
 
9
 * Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
 
10
 */
 
11
#include "tomcrypt.h"
 
12
 
 
13
/**
 
14
  @file f9_init.c
 
15
  F9 Support, start an F9 state
 
16
*/
 
17
 
 
18
#ifdef LTC_F9_MODE
 
19
 
 
20
/** Initialize F9-MAC state
 
21
  @param f9    [out] f9 state to initialize
 
22
  @param cipher  Index of cipher to use
 
23
  @param key     [in]  Secret key
 
24
  @param keylen  Length of secret key in octets
 
25
  Return CRYPT_OK on success
 
26
*/
 
27
int f9_init(f9_state *f9, int cipher, const unsigned char *key, unsigned long keylen)
 
28
{
 
29
   int            x, err;
 
30
 
 
31
   LTC_ARGCHK(f9   != NULL);
 
32
   LTC_ARGCHK(key  != NULL);
 
33
 
 
34
   /* schedule the key */
 
35
   if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
 
36
      return err;
 
37
   }
 
38
 
 
39
#ifdef LTC_FAST
 
40
   if (cipher_descriptor[cipher].block_length % sizeof(LTC_FAST_TYPE)) {
 
41
       return CRYPT_INVALID_ARG;
 
42
   }
 
43
#endif
 
44
 
 
45
   if ((err = cipher_descriptor[cipher].setup(key, keylen, 0, &f9->key)) != CRYPT_OK) {
 
46
      goto done;
 
47
   }
 
48
   
 
49
   /* make the second key */
 
50
   for (x = 0; (unsigned)x < keylen; x++) {
 
51
      f9->akey[x] = key[x] ^ 0xAA;
 
52
   }
 
53
 
 
54
   /* setup struct */
 
55
   zeromem(f9->IV,  cipher_descriptor[cipher].block_length);
 
56
   zeromem(f9->ACC, cipher_descriptor[cipher].block_length);
 
57
   f9->blocksize = cipher_descriptor[cipher].block_length;
 
58
   f9->cipher    = cipher;
 
59
   f9->buflen    = 0;
 
60
   f9->keylen    = keylen;
 
61
done:
 
62
   return err;
 
63
}
 
64
 
 
65
#endif
 
66
 
 
67
/* $Source: /cvs/libtom/libtomcrypt/src/mac/f9/f9_init.c,v $ */
 
68
/* $Revision: 1.4 $ */
 
69
/* $Date: 2006/11/08 22:54:18 $ */
 
70