Salsa20
Encrypt with Salsa20, its reduced-round variants or XSalsa20.
from oxcrypto.stream.salsa20 import SALSA
key = bytes(32)
nonce = bytes(24)
ciphertext = SALSA.XSALSA20.apply_keystream(key, nonce, b"hello")
assert SALSA.XSALSA20.apply_keystream(key, nonce, ciphertext) == b"hello"
cipher = SALSA.XSALSA20.new(key, nonce, counter=2)
assert cipher.position == 128| Variant | Key | Nonce |
|---|---|---|
SALSA8, SALSA12, SALSA20 | 32 bytes | 8 bytes |
XSALSA8, XSALSA12, XSALSA20 | 32 bytes | 24 bytes |
Salsa20 is in the eSTREAM software portfolio. Salsa20/12 is the variant the portfolio recommends; Salsa20/8 is a faster reduced-round variant. XSalsa20 extends the nonce to 192 bits. Only 256-bit keys are supported. The 64-bit counter gives 2⁶⁴ − 1 usable 64-byte blocks.