1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
2 /* SPDX-License-Identifier: Unlicense */
3 
4 /**
5    @file gcm_reset.c
6    GCM implementation, reset a used state so it can accept IV data, by Tom St Denis
7 */
8 #include "tomcrypt_private.h"
9 
10 #ifdef LTC_GCM_MODE
11 
12 /**
13   Reset a GCM state to as if you just called gcm_init().  This saves the initialization time.
14   @param gcm   The GCM state to reset
15   @return CRYPT_OK on success
16 */
gcm_reset(gcm_state * gcm)17 int gcm_reset(gcm_state *gcm)
18 {
19    LTC_ARGCHK(gcm != NULL);
20 
21    zeromem(gcm->buf, sizeof(gcm->buf));
22    zeromem(gcm->X,   sizeof(gcm->X));
23    gcm->mode     = LTC_GCM_MODE_IV;
24    gcm->ivmode   = 0;
25    gcm->buflen   = 0;
26    gcm->totlen   = 0;
27    gcm->pttotlen = 0;
28 
29    return CRYPT_OK;
30 }
31 
32 #endif
33