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
13 PMAC implementation, process a block of memory, by Tom St Denis
19 PMAC a block of memory
20 @param cipher The index of the cipher desired
21 @param key The secret key
22 @param keylen The length of the secret key (octets)
23 @param in The data you wish to send through PMAC
24 @param inlen The length of data you wish to send through PMAC (octets)
25 @param out [out] Destination for the authentication tag
26 @param outlen [in/out] The max size and resulting size of the authentication tag
27 @return CRYPT_OK if successful
29 int pmac_memory(int cipher,
30 const unsigned char *key, unsigned long keylen,
31 const unsigned char *in, unsigned long inlen,
32 unsigned char *out, unsigned long *outlen)
37 LTC_ARGCHK(key != NULL);
38 LTC_ARGCHK(in != NULL);
39 LTC_ARGCHK(out != NULL);
40 LTC_ARGCHK(outlen != NULL);
42 /* allocate ram for pmac state */
43 pmac = XMALLOC(sizeof(pmac_state));
48 if ((err = pmac_init(pmac, cipher, key, keylen)) != CRYPT_OK) {
51 if ((err = pmac_process(pmac, in, inlen)) != CRYPT_OK) {
54 if ((err = pmac_done(pmac, out, outlen)) != CRYPT_OK) {
60 #ifdef LTC_CLEAN_STACK
61 zeromem(pmac, sizeof(pmac_state));
70 /* ref: $Format:%D$ */
71 /* git commit: $Format:%H$ */
72 /* commit time: $Format:%ai$ */