DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
ssh_chacha20.cpp File Reference

ChaCha20 (RFC 8439) - implementation. See ssh_chacha20.h. More...

Go to the source code of this file.

Namespaces

namespace  DETWS_CRYPTO_HOT
 

Macros

#define QR(a, b, c, d)
 

Functions

uint32_t DETWS_CRYPTO_HOT::rd_le32 (const uint8_t *p)
 
uint32_t DETWS_CRYPTO_HOT::rotl32 (uint32_t v, int c)
 
void DETWS_CRYPTO_HOT::chacha_core (const uint32_t in[16], uint8_t out[64])
 
void ssh_chacha20_xor (const uint8_t key[SSH_CHACHA20_KEY_LEN], const uint8_t iv[8], uint64_t counter, const uint8_t *in, uint8_t *out, size_t len)
 XOR len bytes of in with the ChaCha20 keystream into out (OpenSSH layout).
 
void ssh_chacha20_block_ietf (const uint8_t key[SSH_CHACHA20_KEY_LEN], uint32_t counter, const uint8_t nonce[12], uint8_t out[SSH_CHACHA20_BLOCK_LEN])
 One 64-byte ChaCha20 keystream block in the RFC 8439 layout (for the KAT).
 

Variables

const uint32_t DETWS_CRYPTO_HOT::SIGMA0 = 0x61707865
 
const uint32_t DETWS_CRYPTO_HOT::SIGMA1 = 0x3320646e
 
const uint32_t DETWS_CRYPTO_HOT::SIGMA2 = 0x79622d32
 
const uint32_t DETWS_CRYPTO_HOT::SIGMA3 = 0x6b206574
 

Detailed Description

ChaCha20 (RFC 8439) - implementation. See ssh_chacha20.h.

Definition in file ssh_chacha20.cpp.

Macro Definition Documentation

◆ QR

#define QR (   a,
  b,
  c,
 
)
Value:
a += b; \
d ^= a; \
d = rotl32(d, 16); \
c += d; \
b ^= c; \
b = rotl32(b, 12); \
a += b; \
d ^= a; \
d = rotl32(d, 8); \
c += d; \
b ^= c; \
b = rotl32(b, 7)

Definition at line 31 of file ssh_chacha20.cpp.

Function Documentation

◆ ssh_chacha20_xor()

void ssh_chacha20_xor ( const uint8_t  key[SSH_CHACHA20_KEY_LEN],
const uint8_t  iv[8],
uint64_t  counter,
const uint8_t *  in,
uint8_t *  out,
size_t  len 
)

XOR len bytes of in with the ChaCha20 keystream into out (OpenSSH layout).

Parameters
key32-byte key.
iv8-byte nonce (OpenSSH uses the packet sequence number, big-endian).
counterinitial 64-bit block counter (0 for the Poly1305-key / length blocks, 1 for the packet payload); it increments per 64-byte block.
inplaintext (or ciphertext when decrypting); may be nullptr to emit raw keystream.
outoutput buffer (len bytes); may alias in.

Definition at line 79 of file ssh_chacha20.cpp.

Referenced by ssh_chachapoly_decrypt(), ssh_chachapoly_encrypt(), and ssh_chachapoly_get_length().

◆ ssh_chacha20_block_ietf()

void ssh_chacha20_block_ietf ( const uint8_t  key[SSH_CHACHA20_KEY_LEN],
uint32_t  counter,
const uint8_t  nonce[12],
uint8_t  out[SSH_CHACHA20_BLOCK_LEN] 
)

One 64-byte ChaCha20 keystream block in the RFC 8439 layout (for the KAT).

Parameters
key32-byte key.
counter32-bit block counter (word 12).
nonce12-byte nonce (words 13-15).
out64-byte keystream block.

Definition at line 106 of file ssh_chacha20.cpp.