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

int xcbc_memory_multi ( int  cipher,
const unsigned char *  key,
unsigned long  keylen,
unsigned char *  out,
unsigned long *  outlen,
const unsigned char *  in,
unsigned long  inlen,

XCBC multiple blocks of memory

cipherThe index of the desired cipher
keyThe secret key
keylenThe length of the secret key (octets)
out[out] The destination of the authentication tag
outlen[in/out] The max size and resulting size of the authentication tag (octets)
inThe data to send through XCBC
inlenThe length of the data to send through XCBC (octets)
...tuples of (data,len) pairs to XCBC, terminated with a (NULL,x) (x=don't care)
CRYPT_OK if successful

Definition at line 33 of file xcbc_memory_multi.c.

References xcbc_done(), xcbc_init(), xcbc_process(), and zeromem().

   int                  err;
   xcbc_state          *xcbc;
   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 xcbc state */
   xcbc = XMALLOC(sizeof(xcbc_state));
   if (xcbc == NULL) {
      return CRYPT_MEM;

   /* xcbc process the message */
   if ((err = xcbc_init(xcbc, cipher, key, keylen)) != CRYPT_OK) {
      goto LBL_ERR;
   va_start(args, inlen);
   curptr = in; 
   curlen = inlen;
   for (;;) {
      /* process buf */
      if ((err = xcbc_process(xcbc, 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 = xcbc_done(xcbc, out, outlen)) != CRYPT_OK) {
      goto LBL_ERR;
   zeromem(xcbc, sizeof(xcbc_state));
   return err;   

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index