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
9
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.org
14
GCM implementation, process a packet, by Tom St Denis
21
Process an entire GCM packet in one call.
22
@param cipher Index of cipher to use
23
@param key The secret key
24
@param keylen The length of the secret key
25
@param IV The initial vector
26
@param IVlen The length of the initial vector
27
@param adata The additional authentication data (header)
28
@param adatalen The length of the adata
29
@param pt The plaintext
30
@param ptlen The length of the plaintext (ciphertext length is the same)
31
@param ct The ciphertext
32
@param tag [out] The MAC tag
33
@param taglen [in/out] The MAC tag length
34
@param direction Encrypt or Decrypt mode (GCM_ENCRYPT or GCM_DECRYPT)
35
@return CRYPT_OK on success
37
int gcm_memory( int cipher,
38
const unsigned char *key, unsigned long keylen,
39
const unsigned char *IV, unsigned long IVlen,
40
const unsigned char *adata, unsigned long adatalen,
41
unsigned char *pt, unsigned long ptlen,
43
unsigned char *tag, unsigned long *taglen,
49
if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {
53
if (cipher_descriptor[cipher].accel_gcm_memory != NULL) {
54
cipher_descriptor[cipher].accel_gcm_memory
66
gcm = XMALLOC(sizeof(*gcm));
71
if ((err = gcm_init(gcm, cipher, key, keylen)) != CRYPT_OK) {
74
if ((err = gcm_add_iv(gcm, IV, IVlen)) != CRYPT_OK) {
77
if ((err = gcm_add_aad(gcm, adata, adatalen)) != CRYPT_OK) {
80
if ((err = gcm_process(gcm, pt, ptlen, ct, direction)) != CRYPT_OK) {
83
err = gcm_done(gcm, tag, taglen);
91
/* $Source: /cvs/libtom/libtomcrypt/src/encauth/gcm/gcm_memory.c,v $ */
92
/* $Revision: 1.19 $ */
93
/* $Date: 2005/05/05 14:35:58 $ */