Ÿë        `  `  ·         
»,             Ë‰    I          
Ì‰           a        V  É     ´8    ø            a        b—  Ò‰ @   a   €   Ë  a       V  ö  €   ´8 Ç~  h  b—  õ‰ €  %a ø‰ À  w   û‰    0a ý‰ @  Aa ÿ‰ €  rô
 �   À  @�        Pa    @  Í;    `  Za    €  ¹;       o     À  óæ     Ð         
Ð‰        Ð‰           ˜B  Î‰     ,
 Ï‰     a        ea       \¼  Ó‰     "  â            
Ô‰           –e
        V  É     ´8    ø            –e
        €  Ú‰ @   ta   €   Ë  a       V  ö  €   ´8 Ç~  h  €  Š €  %a Š À  w   Š    0a ý‰ @  Aa ÿ‰ €  rô
 �   À  @�        ~a    @  Í;    `  Za    €  ¹;       o     À  óæ     Ð         
Ø‰        Ø‰           ˜B  Ö‰     ,
 ×‰     –e
        ‰a       \¼  Û‰     "  â            
Ü‰ ™a   (   €  Ü‰     ø�
              
Þ‰ ¬a   @   €  Ü‰     ¼a 9            
à‰ Æa      Òa !       ×a !   @   Üa   (   V  $      í­       u  ä‰ @             â‰                 b—  æ‰     €  ç‰            Ñ‰        Ù‰          ía m       ÷a m        b           å‰         è‰ @   Å  óL  €   Áê    À   B '   à   b L   ð          
é‰ b   0   ¼£  ñ      @�     @   'b m   €   b—  æ‰ À   ía l      1b    @  óæ  Ç~  `  ;b L   h         
ë‰ Fb       ¼£  ñ      b—  æ‰ @   ía l   €   óæ  Ç~  À          
í‰ Vb   0   ¼£  ñ      @�     @   'b m   €   €  ç‰ À   ÷a l      1b    @  óæ  Ç~  `  ;b L   h         
ï‰ eb       ¼£  ñ      €  ç‰ @   ÷a l   €   óæ  Ç~  À          
ñ‰       L       Á      ô‰        é‰        ó‰              ÷‰        ì‰        ö‰               ú‰        î‰        ù‰               l       m          ü‰              l       m          þ‰              ›      Š        ê‰         Š              Š        ð‰        Š               Š        ò‰        Š ub   X   Ë  a       ~b    €   y%  Š À   Q)  ö     rô
 �   @  ý5 Ç~  €  Í(        V  �  À         
	Š Šb   @            åi        ˜b    @   ¨b Dz  `   ³b Dz     ½b       Çb ¯Ú  À  h  â            
Š        Š Ñb      s        Ù     @             a È~      V  É     ´8 Ç~  ø            a È~      b—  ¹                ˜B  Š     ,
 Š     a È~      ïb       \¼  Š     "  â               –e
 È~      V  É     ´8 Ç~  ø            –e
 È~      €  ¹                ˜B  Š     ,
 Š     –e
 È~      c       \¼  Š     "  â            
Š c      Òa 24      ×a 24  @   /c   $   V  $      í­ ÑY     u  Š               Š               â‰ Gc   @   Ë  a       Sc éL  €   rô
 �   À   V  $     ^c   °   D ãR      hc      ß"         1ë        uc   p   ð%  K      b—  a      €  a   €  {c K     ˆc  Š    åi    @  ty    `         Š        Š “c   $   s§ Š     ø�
 ÑY            
"Š ­c   @   s§ Š     ¼a 9            
$Š Äc      ©%  b       �š b   @   be  î  €          
&Š          Ñc     àc    õc    d           Š        Š        
Š        Š        'Š        &Š            ¢\               
/Š        	Š        Ý‰        Š        Ü‰        ã‰        ï‰        ß‰        á‰        Š        #Š        %Š        Õ‰        Š        Ô‰        Š        ë‰ d       d    q   'd    YO  3d    [O            u  Š ?d    EŠ       L   Å  *Š à  Š Vd    GŠ           ¼£  ñ  ý5 Ç~  nd    IŠ          ¼£  ñ  ý5 Ç~  |d    KŠ           @�  +Š Šd    MŠ          @�  +Š Sc éL  ¡d    OŠ       ö  @�  +Š ¹#  ÷L  ¶d    QŠ Èd    ((  Ûd    +œ  îd    G7  e    ((  e    +œ  &e    G7  9e    @7  Je    ((  \e    @7  ne    E7  €e    G7        l   @�  1Š “e    ^Š       1Š ¼£  ñ  §e +Š Ð” Š ³e Š »e    `Š       Š @�  1Š í­    ³e Š é    8  /ˆl–ß=¿J*ClÊ�~à¸Ð”Å£�þD0<³enXÊdn7�üÿâ„páÞÂÝ *   //* gcm.h

   Galois counter mode, specified by NIST,
   http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf

   Copyright (C) 2011 Katholieke Universiteit Leuven
   Copyright (C) 2011, 2014 Niels MÃ¶ller

   Contributed by Nikos Mavrogiannopoulos

   This file is part of GNU Nettle.

   GNU Nettle is free software: you can redistribute it and/or
   modify it under the terms of either:

     * the GNU Lesser General Public License as published by the Free
       Software Foundation; either version 3 of the License, or (at your
       option) any later version.

   or

     * the GNU General Public License as published by the Free
       Software Foundation; either version 2 of the License, or (at your
       option) any later version.

   or both in parallel, as here.

   GNU Nettle is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received copies of the GNU General Public License and
   the GNU Lesser General Public License along with this program.  If
   not, see http://www.gnu.org/licenses/.
*/

#ifndef NETTLE_GCM_H_INCLUDED
#define NETTLE_GCM_H_INCLUDED

#include "aes.h"
#include "camellia.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Name mangling */
#define gcm_set_key nettle_gcm_set_key
#define gcm_set_iv nettle_gcm_set_iv
#define gcm_update nettle_gcm_update
#define gcm_encrypt nettle_gcm_encrypt
#define gcm_decrypt nettle_gcm_decrypt
#define gcm_digest nettle_gcm_digest

#define gcm_aes128_set_key nettle_gcm_aes128_set_key
#define gcm_aes128_set_iv nettle_gcm_aes128_set_iv
#define gcm_aes128_update nettle_gcm_aes128_update
#define gcm_aes128_encrypt nettle_gcm_aes128_encrypt
#define gcm_aes128_decrypt nettle_gcm_aes128_decrypt
#define gcm_aes128_digest nettle_gcm_aes128_digest

#define gcm_aes192_set_key nettle_gcm_aes192_set_key
#define gcm_aes192_set_iv nettle_gcm_aes192_set_iv
#define gcm_aes192_update nettle_gcm_aes192_update
#define gcm_aes192_encrypt nettle_gcm_aes192_encrypt
#define gcm_aes192_decrypt nettle_gcm_aes192_decrypt
#define gcm_aes192_digest nettle_gcm_aes192_digest

#define gcm_aes256_set_key nettle_gcm_aes256_set_key
#define gcm_aes256_set_iv nettle_gcm_aes256_set_iv
#define gcm_aes256_update nettle_gcm_aes256_update
#define gcm_aes256_encrypt nettle_gcm_aes256_encrypt
#define gcm_aes256_decrypt nettle_gcm_aes256_decrypt
#define gcm_aes256_digest nettle_gcm_aes256_digest

#define gcm_aes_set_key nettle_gcm_aes_set_key
#define gcm_aes_set_iv nettle_gcm_aes_set_iv
#define gcm_aes_update nettle_gcm_aes_update
#define gcm_aes_encrypt nettle_gcm_aes_encrypt
#define gcm_aes_decrypt nettle_gcm_aes_decrypt
#define gcm_aes_digest nettle_gcm_aes_digest

#define gcm_camellia128_set_key nettle_gcm_camellia128_set_key
#define gcm_camellia128_set_iv nettle_gcm_camellia128_set_iv
#define gcm_camellia128_update nettle_gcm_camellia128_update
#define gcm_camellia128_encrypt nettle_gcm_camellia128_encrypt
#define gcm_camellia128_decrypt nettle_gcm_camellia128_decrypt
#define gcm_camellia128_digest nettle_gcm_camellia128_digest

#define gcm_camellia256_set_key nettle_gcm_camellia256_set_key
#define gcm_camellia256_set_iv nettle_gcm_camellia256_set_iv
#define gcm_camellia256_update nettle_gcm_camellia256_update
#define gcm_camellia256_encrypt nettle_gcm_camellia256_encrypt
#define gcm_camellia256_decrypt nettle_gcm_camellia256_decrypt
#define gcm_camellia256_digest nettle_gcm_camellia256_digest

#define GCM_BLOCK_SIZE 16
#define GCM_IV_SIZE (GCM_BLOCK_SIZE - 4)
#define GCM_DIGEST_SIZE 16
#define GCM_TABLE_BITS 8

/* Hashing subkey */
struct gcm_key
{
  union nettle_block16 h[1 << GCM_TABLE_BITS];
};

/* Per-message state, depending on the iv */
struct gcm_ctx {
  /* Original counter block */
  union nettle_block16 iv;
  /* Updated for each block. */
  union nettle_block16 ctr;
  /* Hashing state */
  union nettle_block16 x;
  uint64_t auth_size;
  uint64_t data_size;
};

void
