comparison ocb_done_decrypt.c @ 0:d7da3b1e1540 libtomcrypt

put back the 0.95 makefile which was inadvertently merged over
author Matt Johnston <matt@ucc.asn.au>
date Mon, 31 May 2004 18:21:40 +0000
parents
children 5d99163f7e32
comparison
equal deleted inserted replaced
-1:000000000000 0:d7da3b1e1540
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, [email protected], http://libtomcrypt.org
10 */
11
12 /* OCB Implementation by Tom St Denis */
13 #include "mycrypt.h"
14
15 #ifdef OCB_MODE
16
17 int ocb_done_decrypt(ocb_state *ocb,
18 const unsigned char *ct, unsigned long ctlen,
19 unsigned char *pt,
20 const unsigned char *tag, unsigned long taglen, int *res)
21 {
22 int err;
23 unsigned char tagbuf[MAXBLOCKSIZE];
24 unsigned long tagbuflen;
25
26 _ARGCHK(ocb != NULL);
27 _ARGCHK(pt != NULL);
28 _ARGCHK(ct != NULL);
29 _ARGCHK(tag != NULL);
30 _ARGCHK(res != NULL);
31
32 *res = 0;
33
34 tagbuflen = sizeof(tagbuf);
35 if ((err = __ocb_done(ocb, ct, ctlen, pt, tagbuf, &tagbuflen, 1)) != CRYPT_OK) {
36 return err;
37 }
38
39 if (taglen <= tagbuflen && memcmp(tagbuf, tag, taglen) == 0) {
40 *res = 1;
41 }
42
43 #ifdef CLEAN_STACK
44 zeromem(tagbuf, sizeof(tagbuf));
45 #endif
46
47 return CRYPT_OK;
48 }
49
50 #endif
51