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

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

LTC_OMAC a block of memory

cipherThe index of the desired cipher
keyThe secret key
keylenThe length of the secret key (octets)
inThe data to send through LTC_OMAC
inlenThe length of the data to send through LTC_OMAC (octets)
out[out] The destination of the authentication tag
outlen[in/out] The max size and resulting size of the authentication tag (octets)
CRYPT_OK if successful

Definition at line 31 of file omac_memory.c.

References omac_done(), omac_init(), ltc_cipher_descriptor::omac_memory, omac_process(), and zeromem().

Referenced by omac_test().

   int err;
   omac_state *omac;

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

   /* is the cipher valid? */
   if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
      return err;

   /* Use accelerator if found */
   if (cipher_descriptor[cipher].omac_memory != NULL) {
      return cipher_descriptor[cipher].omac_memory(key, keylen, in, inlen, out, outlen);

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

   /* omac process the message */
   if ((err = omac_init(omac, cipher, key, keylen)) != CRYPT_OK) {
      goto LBL_ERR;
   if ((err = omac_process(omac, in, inlen)) != CRYPT_OK) {
      goto LBL_ERR;
   if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) {
      goto LBL_ERR;

   err = CRYPT_OK;
   zeromem(omac, sizeof(omac_state));

   return err;   

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index