From f4a41502e680b3fdcfda0de68adfc7e1e685ec77 Mon Sep 17 00:00:00 2001 From: Makar Lill Date: Tue, 31 Mar 2026 21:11:53 +0300 Subject: [PATCH] fix: fixed logic error in generate next byte --- assets/expected1.bin | 2 +- prandom.c | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/assets/expected1.bin b/assets/expected1.bin index 67407da..0bfdca3 100644 --- a/assets/expected1.bin +++ b/assets/expected1.bin @@ -1 +1 @@ -Gkwy`½?ɲ \ No newline at end of file +GŽ­åú ŽŸ‚: \ No newline at end of file diff --git a/prandom.c b/prandom.c index a5be38c..1587b6d 100644 --- a/prandom.c +++ b/prandom.c @@ -54,16 +54,13 @@ GF256_t gf256_gprn_next(struct gf256_gprn* gprn) for (i = 0; i < POLY_DEGREE; i++) { - if (gprn->t[i] != 0) - { - idx = (gprn->index + i) % POLY_DEGREE; - new_byte = GF256_Add(new_byte, GF256_Mul(gprn->t[i], gprn->coeff[idx])); - } + idx = (gprn->index + i) % POLY_DEGREE; + new_byte = GF256_Add(new_byte, GF256_Mul(gprn->coeff[i], gprn->t[idx])); } // "circular" array - gprn->coeff[gprn->index] = new_byte; - gprn->index = (gprn->index + 1) % POLY_DEGREE; + gprn->t[gprn->index] = new_byte; + gprn->index = (gprn->index + 1) % POLY_DEGREE; return new_byte; }