4 ms·
https://github.com/yggdrasil-network/yggdrasil-go/blob/983dfdb5535124cf2663166db580387d7a8a149d/src/crypto/crypto.go#L265 https://github.com/yggdrasil-network/y
by some_furry 5y ago
https://github.com/yggdrasil-network/yggdrasil-go/blob/983dfdb5535124cf2663166db580387d7a8a149d/src/crypto/crypto.go#L265 https://github.com/yggdrasil-network/yggdrasil-go/blob/983df...
I've never seen anyone need to check the top byte of a nonce before. This looks very odd to me.
- jra_samba 5y agoI haven't checked, but this may be due to the restriction in CCM/GCM. Here is the relevant comment/code from Samba. * CCM and GCM algorithms must never have their * nonce wrap, or the security of the whole * communication and the keys is destroyed. * We must drop the connection once we have * transfered too much data. * * NOTE: We assume nonces greater than 8 bytes. */ ... switch (xconn->smb2.server.cipher) { case SMB2_ENCRYPTION_AES128_CCM: nonce_size = SMB2_AES_128_CCM_NONCE_SIZE; break; case SMB2_ENCRYPTION_AES128_GCM: nonce_size = gnutls_cipher_get_iv_size(GNUTLS_CIPHER_AES_128_GCM); break; default: nonce_size = 0; break; } x->nonce_high_max = SMB2_NONCE_HIGH_MAX(nonce_size); x->nonce_high = 0; x->nonce_low = 0; Where the definition of SMB2_NONCE_HIGH_MAX is: #define SMB2_NONCE_HIGH_MAX(nonce_len_bytes) ((uint64_t)(\ ((nonce_len_bytes) >= 16) ? UINT64_MAX : \ ((nonce_len_bytes) <= 8) ? 0 : \ (((uint64_t)1 << (((nonce_len_bytes) - 8)*8)) - 1) \ ))