Mercurial > dropbear
comparison pmac_memory.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 7faae8f46238 |
children |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
18 const unsigned char *key, unsigned long keylen, | 18 const unsigned char *key, unsigned long keylen, |
19 const unsigned char *msg, unsigned long msglen, | 19 const unsigned char *msg, unsigned long msglen, |
20 unsigned char *out, unsigned long *outlen) | 20 unsigned char *out, unsigned long *outlen) |
21 { | 21 { |
22 int err; | 22 int err; |
23 pmac_state pmac; | 23 pmac_state *pmac; |
24 | 24 |
25 _ARGCHK(key != NULL); | 25 _ARGCHK(key != NULL); |
26 _ARGCHK(msg != NULL); | 26 _ARGCHK(msg != NULL); |
27 _ARGCHK(out != NULL); | 27 _ARGCHK(out != NULL); |
28 _ARGCHK(outlen != NULL); | 28 _ARGCHK(outlen != NULL); |
29 | 29 |
30 | 30 /* allocate ram for pmac state */ |
31 if ((err = pmac_init(&pmac, cipher, key, keylen)) != CRYPT_OK) { | 31 pmac = XMALLOC(sizeof(pmac_state)); |
32 return err; | 32 if (pmac == NULL) { |
33 return CRYPT_MEM; | |
33 } | 34 } |
34 if ((err = pmac_process(&pmac, msg, msglen)) != CRYPT_OK) { | 35 |
35 return err; | 36 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) { |
37 goto __ERR; | |
36 } | 38 } |
37 if ((err = pmac_done(&pmac, out, outlen)) != CRYPT_OK) { | 39 if ((err = pmac_process(pmac, msg, msglen)) != CRYPT_OK) { |
38 return err; | 40 goto __ERR; |
41 } | |
42 if ((err = pmac_done(pmac, out, outlen)) != CRYPT_OK) { | |
43 goto __ERR; | |
39 } | 44 } |
40 | 45 |
41 return CRYPT_OK; | 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; | |
42 } | 54 } |
43 | 55 |
44 #endif | 56 #endif |