- int byte_count = 0, offset = 0;
- sscanf(Cmd, "%i %i", &offset, &byte_count);
- if(byte_count == 0) byte_count = -1;
- if(byte_count + offset > 1024) byte_count = 1024 - offset;
+ uint32_t offset = 0, len = 0, IV = 1;
+ sscanf(Cmd, "%x %x %x", &offset, &len, &IV);
+
+ // OUT-OF-BOUNDS check
+ if(len + offset > MAX_LENGTH) len = MAX_LENGTH - offset;
+
+ if ( (IV & 0x7F) != IV ){
+ IV &= 0x7F;
+ PrintAndLog("Truncating IV to 7bits");
+ }
+ if ( (IV & 1) == 0 ){
+ IV |= 0x01; // IV must be odd
+ PrintAndLog("LSB of IV must be SET");
+ }
+ PrintAndLog("Current IV: 0x%02x", IV);
+
+ // get some prng bytes from
+ uint8_t temp[12];
+ legic_prng_init(IV);
+ for ( uint8_t j = 0; j < sizeof(temp); ++j)
+ temp[j] = legic_prng_get_bits(8);