From 2f89c4687b258a5476576e47c6d436397b13db12 Mon Sep 17 00:00:00 2001 From: bg Date: Tue, 8 Jul 2014 21:16:21 +0200 Subject: [PATCH] C-code for gf256-multiplication in comment --- gf256mul/gf256mul.S | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/gf256mul/gf256mul.S b/gf256mul/gf256mul.S index b269d3a..d202d84 100644 --- a/gf256mul/gf256mul.S +++ b/gf256mul/gf256mul.S @@ -62,8 +62,26 @@ gf256mul: #else +/* + +uint8_t gf256mul(uint8_t a, uint8_t b, uint8_t p) { + uint8_t r = 0, c = 8; + do { + if (a & 1) { + r ^= b; + } + a >>= 1; + if (b & 0x80) { + b ^= p; + } + b <<= 1; + } while (--c); + return r; +} + + */ gf256mul: - mov r21, r24 + mov A, r24 clr r24 ldi r25, 8 1: -- 2.39.5