1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
6
* The library is free for all purposes without any express
9
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
13
@file ocb_done_decrypt.c
14
OCB implementation, terminate decryption, by Tom St Denis
21
Terminate a decrypting OCB state
22
@param ocb The OCB state
23
@param ct The ciphertext (if any)
24
@param ctlen The length of the ciphertext (octets)
25
@param pt [out] The plaintext
26
@param tag The authentication tag (to compare against)
27
@param taglen The length of the authentication tag provided
28
@param stat [out] The result of the tag comparison
29
@return CRYPT_OK if the process was successful regardless if the tag is valid
31
int ocb_done_decrypt(ocb_state *ocb,
32
const unsigned char *ct, unsigned long ctlen,
34
const unsigned char *tag, unsigned long taglen, int *stat)
37
unsigned char *tagbuf;
38
unsigned long tagbuflen;
40
LTC_ARGCHK(ocb != NULL);
41
LTC_ARGCHK(pt != NULL);
42
LTC_ARGCHK(ct != NULL);
43
LTC_ARGCHK(tag != NULL);
44
LTC_ARGCHK(stat != NULL);
46
/* default to failed */
50
tagbuf = XMALLOC(MAXBLOCKSIZE);
55
tagbuflen = MAXBLOCKSIZE;
56
if ((err = s_ocb_done(ocb, ct, ctlen, pt, tagbuf, &tagbuflen, 1)) != CRYPT_OK) {
60
if (taglen <= tagbuflen && memcmp(tagbuf, tag, taglen) == 0) {
66
#ifdef LTC_CLEAN_STACK
67
zeromem(tagbuf, MAXBLOCKSIZE);
78
/* $Source: /cvs/libtom/libtomcrypt/src/encauth/ocb/ocb_done_decrypt.c,v $ */
79
/* $Revision: 1.3 $ */
80
/* $Date: 2005/05/05 14:35:58 $ */