# Nonce of AES-GCM generated by Counters

i am trying to generate the nonce for AES-GCM. I know people usually generate it by Counters and LFSRs. I am confused about the meaning of Counters. Is that means Counter (CTR)? Why it can generate unique nonce?

• Thank you so much! – FRANKfisher Apr 12 '20 at 11:03
• How do you do AES-GCM on linux? Which program? – eli Apr 13 '20 at 15:13

Counters are storing values and have usually clear, set, and increment functions. A counter can be implemented in software very easily by using an integer with enough size or using a library like Java BigInteger or Gnu/GMP for C/C++.
• clear() makes the all bits zero: unsigned int counter=0
• set(y) set the counter value to y : counter = y
• increment() increase the current value by 1; counter++
Take a 128-bit unsigned integer and init to zero. Then GCM will use it like $$J_0 = IV || 0^{31} ||1$$ so during the implementation, you need to take a copy of the counter, shift 32 to left, and OR with 0x01.