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

« back to all changes in this revision

Viewing changes to libtomcrypt/omac_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
 
/* OMAC1 Support by Tom St Denis (for 64 and 128 bit block ciphers only) */
12
 
#include "mycrypt.h"
13
 
 
14
 
#ifdef OMAC
15
 
 
16
 
int omac_memory(int cipher, 
17
 
                const unsigned char *key, unsigned long keylen,
18
 
                const unsigned char *msg, unsigned long msglen,
19
 
                      unsigned char *out, unsigned long *outlen)
20
 
{
21
 
   int err;
22
 
   omac_state *omac;
23
 
 
24
 
   _ARGCHK(key    != NULL);
25
 
   _ARGCHK(msg    != NULL);
26
 
   _ARGCHK(out    != NULL);
27
 
   _ARGCHK(outlen != NULL);
28
 
 
29
 
   /* allocate ram for omac state */
30
 
   omac = XMALLOC(sizeof(omac_state));
31
 
   if (omac == NULL) {
32
 
      return CRYPT_MEM;
33
 
   }
34
 
 
35
 
   /* omac process the message */
36
 
   if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
37
 
      goto __ERR;
38
 
   }
39
 
   if ((err = omac_process(omac, msg, msglen)) != CRYPT_OK) {
40
 
      goto __ERR;
41
 
   }
42
 
   if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) {
43
 
      goto __ERR;
44
 
   }
45
 
 
46
 
   err = CRYPT_OK;
47
 
__ERR:
48
 
#ifdef CLEAN_STACK
49
 
   zeromem(omac, sizeof(omac_state));
50
 
#endif
51
 
 
52
 
   XFREE(omac);
53
 
   return err;   
54
 
}
55
 
 
56
 
#endif