Skip to content

salsa20: support 16 byte keys #432

@micolous

Description

@micolous

16 and 10 byte keys use different constants, as described in the Salsa20 paper:

The diagonal constants are the same for every block, every nonce, and every
32-byte key. As an extra (non-recommended) option, Salsa20 can use a 16-byte
key, repeated to form a 32-byte key; in this case the diagonal constants change to
0x61707865, 0x3120646e, 0x79622d36, 0x6b206574. Salsa20 can also use a 10-
byte key, zero-padded to form a 16-byte key; in this case the diagonal constants
change to 0x61707865, 0x3120646e, 0x79622d30, 0x6b206574.

RustCrypto only supports the 32-byte key:

/// State initialization constant ("expand 32-byte k")
const CONSTANTS: [u32; 4] = [0x6170_7865, 0x3320_646e, 0x7962_2d32, 0x6b20_6574];

So it's not possible to "extend" the key without changing the constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions