Diff for /libaitio/src/crypt.c between versions 1.3 and 1.4

version 1.3, 2011/04/20 22:56:32 version 1.4, 2011/10/31 13:53:51
Line 169  io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp Line 169  io_Blowfish(u_char *pInput, int inLen, u_char **ppOutp
   
         return ret;          return ret;
 }  }
   
   /*
    * io_ctr_AES() Encrypt/Decrypt stream cipher CTR_AES
    * @pInput = Input buffer with ASCII
    * @inLen = Input buffer data length
    * @ppOutput = Output buffer with cipher data, must be free after use
    * @pKey = Key
    * @IV = IVector/Nonce/Counter, Warning: IV must be variable, because we write there!!!
    * return: -1 error or >-1 how many cipher blocks proceeded
    */
   int
   io_ctr_AES(u_char *pInput, int inLen, u_char **ppOutput, u_char *pKey, u_char IV[AES_BLOCK_SIZE])
   {
           u_int num;
           AES_KEY key;
           u_char ecount_buf[AES_BLOCK_SIZE] = { 0 };
           int total = 0;
   
           if (!pInput || !inLen || !ppOutput)
                   return -1;
   
           *ppOutput = malloc(inLen);
           if (!*ppOutput) {
                   LOGERR;
                   return -1;
           } else
                   memset(*ppOutput, 0, inLen);
   
           AES_set_encrypt_key(pKey, 128, &key);
   
           while (inLen) {
                   num = 0;
                   memset(ecount_buf, 0, sizeof ecount_buf);
                   AES_ctr128_encrypt(pInput + total, (*ppOutput) + total, 
                                   (inLen / (AES_BLOCK_SIZE - 1)) ? (AES_BLOCK_SIZE - 1) : inLen, 
                                   &key, IV, ecount_buf, &num);
                   if (num < 1) {
                           free(*ppOutput);
                           *ppOutput = NULL;
                           total = -1;
                           break;
                   } else {
                           total += num;
                           inLen -= num;
                   }
           }
   
           return total;
   }

Removed from v.1.3  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>