+
+int CmdteaSelfTest(const char *Cmd){
+
+ uint8_t v[8], v_le[8];
+ memset(v, 0x00, sizeof(v));
+ memset(v_le, 0x00, sizeof(v_le));
+ uint8_t* v_ptr = v_le;
+
+ uint8_t cmdlen = strlen(Cmd);
+ cmdlen = ( sizeof(v)<<2 < cmdlen ) ? sizeof(v)<<2 : cmdlen;
+
+ if ( param_gethex(Cmd, 0, v, cmdlen) > 0 ){
+ PrintAndLog("can't read hex chars, uneven? :: %u", cmdlen);
+ return 1;
+ }
+
+ SwapEndian64ex(v , 8, 4, v_ptr);
+
+
+
+ PrintAndLog("Modified Burtle");
+ prng_ctx ctx; // = { 0, 0, 0, 0 };
+ uint32_t num = bytes_to_num(v+1, 4);
+ burtle_init_mod( &ctx, num);
+ PrintAndLog("V : %X", num);
+ PrintAndLog("BURT: %X", burtle_get_mod( &ctx));
+ PrintAndLog("SIMP: %X", GetSimplePrng(num));
+
+ uint8_t calc[16];
+
+ for ( uint8_t i=0; i<8; ++i){
+ if ( i%2 == 0) {
+ calc[0] += v[i];
+ calc[1] += NibbleHigh( v[i]);
+ calc[2] += NibbleLow( v[i]);
+ calc[3] ^= v[i];
+ calc[4] ^= NibbleHigh(v[i]);
+ calc[5] ^= NibbleLow( v[i]);
+ }
+ else {
+ calc[6] += v[i];
+ calc[7] += NibbleHigh( v[i]);
+ calc[8] += NibbleLow( v[i]);
+ calc[9] ^= v[i];
+ calc[10] ^= NibbleHigh(v[i]);
+ calc[11] ^= NibbleLow( v[i]);
+ }
+ }
+ for ( uint8_t i=0; i<4; ++i) calc[12] += v[i];
+ for ( uint8_t i=1; i<5; ++i) calc[13] += v[i];
+ for ( uint8_t i=2; i<6; ++i) calc[14] += v[i];
+ for ( uint8_t i=3; i<7; ++i) calc[15] += v[i];
+
+ PrintAndLog("%s ", sprint_hex(calc, 16) );