Mercurial > dropbear
comparison libtomcrypt/src/encauth/ocb/ocb_done_decrypt.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 | 9 |
12 /** | 10 /** |
13 @file ocb_done_decrypt.c | 11 @file ocb_done_decrypt.c |
14 OCB implementation, terminate decryption, by Tom St Denis | 12 OCB implementation, terminate decryption, by Tom St Denis |
15 */ | 13 */ |
16 #include "tomcrypt.h" | 14 #include "tomcrypt.h" |
17 | 15 |
26 @param tag The authentication tag (to compare against) | 24 @param tag The authentication tag (to compare against) |
27 @param taglen The length of the authentication tag provided | 25 @param taglen The length of the authentication tag provided |
28 @param stat [out] The result of the tag comparison | 26 @param stat [out] The result of the tag comparison |
29 @return CRYPT_OK if the process was successful regardless if the tag is valid | 27 @return CRYPT_OK if the process was successful regardless if the tag is valid |
30 */ | 28 */ |
31 int ocb_done_decrypt(ocb_state *ocb, | 29 int ocb_done_decrypt(ocb_state *ocb, |
32 const unsigned char *ct, unsigned long ctlen, | 30 const unsigned char *ct, unsigned long ctlen, |
33 unsigned char *pt, | 31 unsigned char *pt, |
34 const unsigned char *tag, unsigned long taglen, int *stat) | 32 const unsigned char *tag, unsigned long taglen, int *stat) |
35 { | 33 { |
36 int err; | 34 int err; |
37 unsigned char *tagbuf; | 35 unsigned char *tagbuf; |
38 unsigned long tagbuflen; | 36 unsigned long tagbuflen; |
55 tagbuflen = MAXBLOCKSIZE; | 53 tagbuflen = MAXBLOCKSIZE; |
56 if ((err = s_ocb_done(ocb, ct, ctlen, pt, tagbuf, &tagbuflen, 1)) != CRYPT_OK) { | 54 if ((err = s_ocb_done(ocb, ct, ctlen, pt, tagbuf, &tagbuflen, 1)) != CRYPT_OK) { |
57 goto LBL_ERR; | 55 goto LBL_ERR; |
58 } | 56 } |
59 | 57 |
60 if (taglen <= tagbuflen && XMEMCMP(tagbuf, tag, taglen) == 0) { | 58 if (taglen <= tagbuflen && XMEM_NEQ(tagbuf, tag, taglen) == 0) { |
61 *stat = 1; | 59 *stat = 1; |
62 } | 60 } |
63 | 61 |
64 err = CRYPT_OK; | 62 err = CRYPT_OK; |
65 LBL_ERR: | 63 LBL_ERR: |
73 } | 71 } |
74 | 72 |
75 #endif | 73 #endif |
76 | 74 |
77 | 75 |
78 /* $Source$ */ | 76 /* ref: $Format:%D$ */ |
79 /* $Revision$ */ | 77 /* git commit: $Format:%H$ */ |
80 /* $Date$ */ | 78 /* commit time: $Format:%ai$ */ |