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
/* PMAC implementation by Tom St Denis */
17
int pmac_file(int cipher,
18
const unsigned char *key, unsigned long keylen,
20
unsigned char *out, unsigned long *outlen)
28
unsigned char buf[512];
32
_ARGCHK(filename != NULL);
34
_ARGCHK(outlen != NULL);
36
in = fopen(filename, "rb");
38
return CRYPT_FILE_NOTFOUND;
41
if ((err = pmac_init(&pmac, cipher, key, keylen)) != CRYPT_OK) {
47
x = fread(buf, 1, sizeof(buf), in);
48
if ((err = pmac_process(&pmac, buf, x)) != CRYPT_OK) {
52
} while (x == sizeof(buf));
55
if ((err = pmac_done(&pmac, out, outlen)) != CRYPT_OK) {
60
zeromem(buf, sizeof(buf));