Logo Search packages:      
Sourcecode: libtomcrypt version File versions  Download package

int hmac_memory_multi ( int  hash,
const unsigned char *  key,
unsigned long  keylen,
unsigned char *  out,
unsigned long *  outlen,
const unsigned char *  in,
unsigned long  inlen,

LTC_HMAC multiple blocks of memory to produce the authentication tag

hashThe index of the hash to use
keyThe secret key
keylenThe length of the secret key (octets)
out[out] Destination of the authentication tag
outlen[in/out] Max size and resulting size of authentication tag
inThe data to LTC_HMAC
inlenThe length of the data to LTC_HMAC (octets)
...tuples of (data,len) pairs to LTC_HMAC, terminated with a (NULL,x) (x=don't care)
CRYPT_OK if successful

Definition at line 33 of file hmac_memory_multi.c.

References hmac_done(), hmac_init(), hmac_process(), and zeromem().

    hmac_state          *hmac;
    int                  err;
    va_list              args;
    const unsigned char *curptr;
    unsigned long        curlen;

    LTC_ARGCHK(key    != NULL);
    LTC_ARGCHK(in     != NULL);
    LTC_ARGCHK(out    != NULL); 
    LTC_ARGCHK(outlen != NULL);

    /* allocate ram for hmac state */
    hmac = XMALLOC(sizeof(hmac_state));
    if (hmac == NULL) {
       return CRYPT_MEM;

    if ((err = hmac_init(hmac, hash, key, keylen)) != CRYPT_OK) {
       goto LBL_ERR;

    va_start(args, inlen);
    curptr = in; 
    curlen = inlen;
    for (;;) {
       /* process buf */
       if ((err = hmac_process(hmac, curptr, curlen)) != CRYPT_OK) {
          goto LBL_ERR;
       /* step to next */
       curptr = va_arg(args, const unsigned char*);
       if (curptr == NULL) {
       curlen = va_arg(args, unsigned long);
    if ((err = hmac_done(hmac, out, outlen)) != CRYPT_OK) {
       goto LBL_ERR;
   zeromem(hmac, sizeof(hmac_state));
   return err;   

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index