comparison ocb_decrypt_verify_memory.c @ 3:7faae8f46238 libtomcrypt-orig

Branch renaming
author Matt Johnston <matt@ucc.asn.au>
date Mon, 31 May 2004 18:25:41 +0000
parents
children 5d99163f7e32
comparison
equal deleted inserted replaced
-1:000000000000 3:7faae8f46238
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_decrypt_verify_memory(int cipher,
18 const unsigned char *key, unsigned long keylen,
19 const unsigned char *nonce,
20 const unsigned char *ct, unsigned long ctlen,
21 unsigned char *pt,
22 const unsigned char *tag, unsigned long taglen,
23 int *res)
24 {
25 int err;
26 ocb_state ocb;
27
28
29 _ARGCHK(key != NULL);
30 _ARGCHK(nonce != NULL);
31 _ARGCHK(pt != NULL);
32 _ARGCHK(ct != NULL);
33 _ARGCHK(tag != NULL);
34 _ARGCHK(res != NULL);
35
36 if ((err = ocb_init(&ocb, cipher, key, keylen, nonce)) != CRYPT_OK) {
37 return err;
38 }
39
40 while (ctlen > (unsigned long)ocb.block_len) {
41 if ((err = ocb_decrypt(&ocb, ct, pt)) != CRYPT_OK) {
42 return err;
43 }
44 ctlen -= ocb.block_len;
45 pt += ocb.block_len;
46 ct += ocb.block_len;
47 }
48
49 return ocb_done_decrypt(&ocb, ct, ctlen, pt, tag, taglen, res);
50 }
51
52 #endif