8000
Skip to content

Error in non-optimized initialization implementation #2

Description

@acmo0

Hello,
I think there is an error in the file grain128aead.c at the root of the repository.

  • The error is in the next_z function at line 186,
  • It causes a wrong initialization of the cipher because the key is no more re-added.

Here is the presumed faulty code :

if (grain_round == INIT) {
	lfsr_out = shift(grain->lfsr, lfsr_fb ^ y);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out ^ y);
} else if (grain_round == NORMAL) {
	lfsr_out = shift(grain->lfsr, lfsr_fb ^ y ^ keybit_64);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out ^ y ^ keybit);
} else if (grain_round == NORMAL) {
	lfsr_out = shift(grain->lfsr, lfsr_fb);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out);
}

which should be replaced by :

if (grain_round == INIT) {
	lfsr_out = shift(grain->lfsr, lfsr_fb ^ y);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out ^ y);
} else if (grain_round == ADDKEY) {
	lfsr_out = shift(grain->lfsr, lfsr_fb ^ y ^ keybit_64);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out ^ y ^ keybit);
} else if (grain_round == NORMAL) {
	lfsr_out = shift(grain->lfsr, lfsr_fb);
	shift(grain->nfsr, nfsr_fb ^ lfsr_out);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0