⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ltc_gcm.h

📁 加密认证联合模式的VS2005工程文件
💻 H
字号:
/*
 ---------------------------------------------------------------------------
 Copyright (c) 1998-2006, Brian Gladman, Worcester, UK. All rights reserved.

 LICENSE TERMS

 The free distribution and use of this software in both source and binary
 form is allowed (with or without changes) provided that:

   1. distributions of this source code include the above copyright
      notice, this list of conditions and the following disclaimer;

   2. distributions in binary form include the above copyright
      notice, this list of conditions and the following disclaimer
      in the documentation and/or other associated materials;

   3. the copyright holder's name is not used to endorse products
      built using this software without specific written permission.

 ALTERNATIVELY, provided that this notice is retained in full, this product
 may be distributed under the terms of the GNU General Public License (GPL),
 in which case the provisions of the GPL apply INSTEAD OF those given above.

 DISCLAIMER

 This software is provided 'as is' with no explicit or implied warranties
 in respect of its properties, including, but not limited to, correctness
 and/or fitness for purpose.
 ---------------------------------------------------------------------------
 Issue Date: 13/10/2006

 This code has been derived from LibTomCrypt, the cryptographic library
 authored by Tom St Denis.  His contribution is hence acknowledged. This
 code has been developed to obtain two independent implementations of the
 combined AES encryption/authentication modes (CCM, GCM and EAX) in order
 to be able to check test vectors before their publication.
*/

#ifndef LTC_GCM_H
#define LTC_GCM_H

#include "aes.h"

#define GCM_TABLES

#define GCM_ENCRYPT 0
#define GCM_DECRYPT 1

typedef struct
{
    aes_encrypt_ctx ctx[1];
    uint_8t hh[16],     /* multiplier                           */
    acc[16],            /* accumulator                          */
    ctr[16],            /* counter                              */
    ctr_0[16],          /* initial counter                      */
    buf[16];            /* buffer for stuff                     */
    int iv_mode,        /* Which mode is the iv in?             */
    mode,               /* mode the GCM code is in              */
    bfr_len;            /* length of data in buf                */
    uint_64t auth_len,  /* 64-bit counter used for iv and AAD   */
    ptxt_len;           /* 64-bit counter for the PT            */
#ifdef GCM_TABLES
    uint_8t gf_tab[16][256][16];    /* 16 tables of 8x128       */
#endif
} gcm_state;

int gcm_init( const unsigned char key[], int key_len, gcm_state gcm[1] );

int gcm_add_iv( const unsigned char iv[], unsigned long iv_len, gcm_state gcm[1] );

int gcm_add_aad( const unsigned char data[], unsigned long data_len, gcm_state gcm[1] );

int gcm_process( unsigned char pt[], unsigned long pt_len, unsigned char ct[], int dir, gcm_state gcm[1] );

int gcm_reset( gcm_state gcm[1] );

int gcm_done( unsigned char tag[], unsigned long *taglen, gcm_state gcm[1] );

int gcm_memory( const unsigned char key[], unsigned long key_len,
                const unsigned char iv[], unsigned long iv_len,
                const unsigned char data[], unsigned long data_len,
                unsigned char pt[], unsigned long pt_len,
                unsigned char ct[],
                unsigned char tag[], unsigned long taglen,
                int dir, int *stat);
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -