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

chach.nosp@m.a20-.nosp@m.poly1.nosp@m.305@.nosp@m.opens.nosp@m.sh.c.nosp@m.om - implementation. See ssh_chachapoly.h. More...

Go to the source code of this file.

Functions

uint32_t ssh_chachapoly_get_length (const uint8_t key[SSH_CHACHAPOLY_KEY_LEN], uint32_t seqnr, const uint8_t enc_len[SSH_CHACHAPOLY_AAD_LEN])
 Decrypt just the 4-byte length field to learn the packet length before reading the body.
 
void ssh_chachapoly_encrypt (const uint8_t key[SSH_CHACHAPOLY_KEY_LEN], uint32_t seqnr, uint8_t *dest, const uint8_t *src, uint32_t payload_len)
 Encrypt+authenticate one packet.
 
bool ssh_chachapoly_decrypt (const uint8_t key[SSH_CHACHAPOLY_KEY_LEN], uint32_t seqnr, uint8_t *dest, const uint8_t *src, uint32_t payload_len)
 Verify+decrypt one packet.
 

Detailed Description

Function Documentation

◆ ssh_chachapoly_get_length()

uint32_t ssh_chachapoly_get_length ( const uint8_t  key[SSH_CHACHAPOLY_KEY_LEN],
uint32_t  seqnr,
const uint8_t  enc_len[SSH_CHACHAPOLY_AAD_LEN] 
)

Decrypt just the 4-byte length field to learn the packet length before reading the body.

Returns
the SSH packet_length (bytes of the packet after the length field, excluding the tag).

Definition at line 40 of file ssh_chachapoly.cpp.

References ssh_chacha20_xor().

Referenced by ssh_pkt_recv().

◆ ssh_chachapoly_encrypt()

void ssh_chachapoly_encrypt ( const uint8_t  key[SSH_CHACHAPOLY_KEY_LEN],
uint32_t  seqnr,
uint8_t *  dest,
const uint8_t *  src,
uint32_t  payload_len 
)

Encrypt+authenticate one packet.

Parameters
srcplaintext: 4-byte packet length (big-endian) || payload_len payload bytes.
destoutput: encrypted length (4) || encrypted payload (payload_len) || tag (16). May alias src. dest must hold 4 + payload_len + 16 bytes.

Definition at line 50 of file ssh_chachapoly.cpp.

References ssh_chacha20_xor(), and ssh_poly1305().

Referenced by ssh_pkt_send().

◆ ssh_chachapoly_decrypt()

bool ssh_chachapoly_decrypt ( const uint8_t  key[SSH_CHACHAPOLY_KEY_LEN],
uint32_t  seqnr,
uint8_t *  dest,
const uint8_t *  src,
uint32_t  payload_len 
)

Verify+decrypt one packet.

Parameters
srcciphertext: encrypted length (4) || encrypted payload (payload_len) || tag (16).
destoutput: plaintext length (4) || plaintext payload (payload_len). May alias src.
Returns
true if the Poly1305 tag verified; false (and no usable plaintext) otherwise.

Definition at line 62 of file ssh_chachapoly.cpp.

References ssh_chacha20_xor(), and ssh_poly1305().

Referenced by ssh_pkt_recv().