]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - grain/grain.c
trivium fixed; further migrating to SCAL
[avr-crypto-lib.git] / grain / grain.c
index 8d30d2266299a367a2f5891daa0220f58642fe2d..81117ed99524e7c000580fb0d5eef964a002abe8 100644 (file)
@@ -134,7 +134,17 @@ uint8_t grain_enc(grain_ctx_t* ctx){
        h = (pgm_read_byte(h_lut+(i/8)))>>(i%8);
        
        h ^= B(0) ^ B(1) ^ B(3) ^ B(9) ^ B(30) ^ B(42) ^ B(55);
-       return h&1;
+       return (h&1);
+}
+
+uint8_t grain_getbyte(grain_ctx_t* ctx){
+       uint8_t i=0;
+       uint8_t r=0;
+       do{
+               r >>= 1;
+               r |= grain_enc(ctx)?0x80:0x00;
+       }while(++i<8);
+       return r;
 }
 
 #ifdef GRAIN_REVERSEKEY