Mercurial > dropbear
comparison eax_encrypt_authenticate_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 |
---|---|
21 const unsigned char *pt, unsigned long ptlen, | 21 const unsigned char *pt, unsigned long ptlen, |
22 unsigned char *ct, | 22 unsigned char *ct, |
23 unsigned char *tag, unsigned long *taglen) | 23 unsigned char *tag, unsigned long *taglen) |
24 { | 24 { |
25 int err; | 25 int err; |
26 eax_state eax; | 26 eax_state *eax; |
27 | 27 |
28 if ((err = eax_init(&eax, cipher, key, keylen, nonce, noncelen, header, headerlen)) != CRYPT_OK) { | 28 eax = XMALLOC(sizeof(eax_state)); |
29 return err; | 29 |
30 if ((err = eax_init(eax, cipher, key, keylen, nonce, noncelen, header, headerlen)) != CRYPT_OK) { | |
31 goto __ERR; | |
30 } | 32 } |
31 | 33 |
32 if ((err = eax_encrypt(&eax, pt, ct, ptlen)) != CRYPT_OK) { | 34 if ((err = eax_encrypt(eax, pt, ct, ptlen)) != CRYPT_OK) { |
33 return err; | 35 goto __ERR; |
34 } | 36 } |
35 | 37 |
36 if ((err = eax_done(&eax, tag, taglen)) != CRYPT_OK) { | 38 if ((err = eax_done(eax, tag, taglen)) != CRYPT_OK) { |
37 return err; | 39 goto __ERR; |
38 } | 40 } |
39 | 41 |
40 return CRYPT_OK; | 42 err = CRYPT_OK; |
43 __ERR: | |
44 #ifdef CLEAN_STACK | |
45 zeromem(eax, sizeof(eax_state)); | |
46 #endif | |
47 | |
48 XFREE(eax); | |
49 | |
50 return err; | |
41 } | 51 } |
42 | 52 |
43 #endif | 53 #endif |