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@iahu.ca, http://libtomcrypt.org
12
/* OCB Implementation by Tom St Denis */
17
int ocb_encrypt_authenticate_memory(int cipher,
18
const unsigned char *key, unsigned long keylen,
19
const unsigned char *nonce,
20
const unsigned char *pt, unsigned long ptlen,
22
unsigned char *tag, unsigned long *taglen)
28
_ARGCHK(nonce != NULL);
32
_ARGCHK(taglen != NULL);
35
ocb = XMALLOC(sizeof(ocb_state));
40
if ((err = ocb_init(ocb, cipher, key, keylen, nonce)) != CRYPT_OK) {
44
while (ptlen > (unsigned long)ocb->block_len) {
45
if ((err = ocb_encrypt(ocb, pt, ct)) != CRYPT_OK) {
48
ptlen -= ocb->block_len;
53
err = ocb_done_encrypt(ocb, pt, ptlen, ct, tag, taglen);
56
zeromem(ocb, sizeof(ocb_state));