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

« back to all changes in this revision

Viewing changes to libtomcrypt/pmac_memory.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

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@iahu.ca, http://libtomcrypt.org
10
 
 */
11
 
 
12
 
/* PMAC implementation by Tom St Denis */
13
 
#include "mycrypt.h"
14
 
 
15
 
#ifdef PMAC
16
 
 
17
 
int pmac_memory(int cipher, 
18
 
                const unsigned char *key, unsigned long keylen,
19
 
                const unsigned char *msg, unsigned long msglen,
20
 
                      unsigned char *out, unsigned long *outlen)
21
 
{
22
 
   int err;
23
 
   pmac_state *pmac;
24
 
 
25
 
   _ARGCHK(key    != NULL);
26
 
   _ARGCHK(msg    != NULL);
27
 
   _ARGCHK(out    != NULL);
28
 
   _ARGCHK(outlen != NULL);
29
 
 
30
 
   /* allocate ram for pmac state */
31
 
   pmac = XMALLOC(sizeof(pmac_state));
32
 
   if (pmac == NULL) {
33
 
      return CRYPT_MEM;
34
 
   }
35
 
   
36
 
   if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) {
37
 
      goto __ERR;
38
 
   }
39
 
   if ((err = pmac_process(pmac, msg, msglen)) != CRYPT_OK) {
40
 
      goto __ERR;
41
 
   }
42
 
   if ((err = pmac_done(pmac, out, outlen)) != CRYPT_OK) {
43
 
      goto __ERR;
44
 
   }
45
 
 
46
 
   err = CRYPT_OK;
47
 
__ERR:
48
 
#ifdef CLEAN_STACK
49
 
   zeromem(pmac, sizeof(pmac_state));
50
 
#endif
51
 
 
52
 
   XFREE(pmac);
53
 
   return err;   
54
 
}
55
 
 
56
 
#endif