AES-GMAC-CTR tweaks, self test tweaks, debian typo fix.
This commit is contained in:
parent
e29c2d0260
commit
185e90c40f
5 changed files with 57 additions and 24 deletions
|
@ -935,11 +935,19 @@ bool Packet::uncompress()
|
|||
|
||||
uint64_t Packet::nextPacketId()
|
||||
{
|
||||
// The packet ID which is also the packet's nonce/IV can be sequential but
|
||||
// it should never repeat. This scheme minimizes the chance of nonce
|
||||
// repetition if (as will usually be the case) the clock is relatively
|
||||
// accurate.
|
||||
|
||||
static uint64_t ctr = 0;
|
||||
static Mutex lock;
|
||||
lock.lock();
|
||||
while (ctr == 0)
|
||||
while (ctr == 0) {
|
||||
Utils::getSecureRandom(&ctr,sizeof(ctr));
|
||||
ctr <<= 32;
|
||||
ctr |= ((uint64_t)time(nullptr)) & 0x00000000ffffffffULL;
|
||||
}
|
||||
const uint64_t i = ctr++;
|
||||
lock.unlock();
|
||||
return i;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue