// Mifare Ultralight Write Single Block
//
int CmdHF14AMfUWrBl(const char *Cmd){
- uint8_t blockNo = 0;
- bool chinese_card=0;
- uint8_t bldata[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ uint8_t blockNo = 0;
+ bool chinese_card = 0;
+ uint8_t bldata[16] = {0x00};
UsbCommand resp;
if (strlen(Cmd)<3) {
uint8_t BlockNo = 0;
int Pages=16;
uint8_t *lockbytes_t=NULL;
- uint8_t lockbytes[2]={0,0};
- bool bit[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ uint8_t lockbytes[2]={0x00};
+ bool bit[16]={0x00};
bool dump=false;
- uint8_t datatemp[5]={0,0,0,0,0};
+ uint8_t datatemp[7]= {0x00};
uint8_t isOK = 0;
uint8_t * data = NULL;
int CmdHF14AMfUDump(const char *Cmd){
int i;
- uint8_t BlockNo = 0;
- int Pages=16;
- uint8_t *lockbytes_t=NULL;
- uint8_t lockbytes[2]={0,0};
- bool bit[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- bool dump=false;
- uint8_t datatemp[5]={0,0,0,0,0};
-
- uint8_t isOK = 0;
- uint8_t * data = NULL;
+ uint8_t BlockNo = 0;
+ int Pages = 16;
+ uint8_t *lockbytes_t = NULL;
+ uint8_t lockbytes[2] = {0x00};
+ bool bit[16] = {0x00};
+ uint8_t datatemp[5] = {0x00};
+ bool dump = true;
+ uint8_t isOK = 0;
+ uint8_t * data = NULL;
FILE *fout;
- dump=true;
if ((fout = fopen("dump_ultralight_data.bin","wb")) == NULL) {
PrintAndLog("Could not create file name dumpdata.bin");
return 1;
int CmdHF14AMfucAuth(const char *Cmd){
uint8_t blockNo = 0, keyNo=0;
- uint8_t e_RndB[8];
+ uint8_t e_RndB[8] = {0x00};
uint32_t cuid=0;
- unsigned char RndARndB[16];
- uint8_t key[16];
+ unsigned char RndARndB[16] = {0x00};
+ uint8_t key[16] = {0x00};
DES_cblock RndA, RndB;
- DES_cblock iv={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+ DES_cblock iv[8] = {0x00};
DES_key_schedule ks1,ks2;
DES_cblock key1,key2;
//
int CmdHF14AMfUCRdBl(const char *Cmd)
{
-
uint8_t blockNo = 0;
if (strlen(Cmd)<1) {
uint8_t BlockNo = 0;
int Pages=44;
uint8_t *lockbytes_t=NULL;
- uint8_t lockbytes[2]={0,0};
+ uint8_t lockbytes[2]={0x00};
uint8_t *lockbytes_t2=NULL;
- uint8_t lockbytes2[2]={0,0};
- bool bit[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- bool bit2[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+ uint8_t lockbytes2[2]={0x00};
+ bool bit[16]={0x00};
+ bool bit2[16]={0x00};
bool dump=false;
- uint8_t datatemp[5]={0,0,0,0,0};
-
+ uint8_t datatemp[5]={0x00};
uint8_t isOK = 0;
uint8_t * data = NULL;
FILE *fout = NULL;
uint8_t BlockNo = 0;
int Pages=44;
uint8_t *lockbytes_t=NULL;
- uint8_t lockbytes[2]={0,0};
+ uint8_t lockbytes[2]={0x00};
uint8_t *lockbytes_t2=NULL;
- uint8_t lockbytes2[2]={0,0};
- bool bit[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- bool bit2[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
- bool dump=false;
- uint8_t datatemp[5]={0,0,0,0,0};
+ uint8_t lockbytes2[2]={0x00};
+ bool bit[16]={0x00};
+ bool bit2[16]={0x00};
+ bool dump=true;
+ uint8_t datatemp[5]={0x00};
uint8_t isOK = 0;
uint8_t * data = NULL;
FILE *fout;
- dump=true;
if ((fout = fopen("dump_ultralightc_data.bin","wb")) == NULL) {
PrintAndLog("Could not create file name dumpdata.bin");
return 1;
int CmdHF14AMfUCWrBl(const char *Cmd){
uint8_t blockNo = 0;
- bool chinese_card=0;
- uint8_t bldata[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ bool chinese_card = 0;
+ uint8_t bldata[16] = {0x00};
UsbCommand resp;
if (strlen(Cmd)<3) {
int i, clock, high, low, startindex;
low = startindex = 0;
high = 1;
- uint8_t bitStream[len];
-
+ uint8_t * bitStream = (uint8_t* ) malloc(sizeof(uint8_t) * len);
memset(bitStream, 0x00, len);
/* Detect high and lows */
startindex = DetectFirstTransition(data, len, high);
PrintAndLog(" Clock : %d", clock);
- //PrintAndLog(" startindex : %d", startindex);
-
+
if (high != 1)
bitlength = ManchesterConvertFrom255(data, len, bitStream, high, low, clock, startindex);
else
bitlength= ManchesterConvertFrom1(data, len, bitStream, clock, startindex);
memcpy(dataout, bitStream, bitlength);
+ free(bitStream);
return bitlength;
}
void iceFsk2(int * data, const size_t len){
int i, j;
- int output[len];
-
+ int * output = (int* ) malloc(sizeof(int) * len);
+ memset(output, 0x00, len);
+
// for (i=0; i<len-5; ++i){
// for ( j=1; j <=5; ++j) {
// output[i] += data[i*j];
for (j=0; j<len; ++j)
data[j] = output[j];
+
+ free(output);
}
void iceFsk3(int * data, const size_t len){
int i,j;
- int output[len];
- float fc = 0.1125f; // center frequency
+
+ int * output = (int* ) malloc(sizeof(int) * len);
+ memset(output, 0x00, len);
+ float fc = 0.1125f; // center frequency
size_t adjustedLen = len;
// create very simple low-pass filter to remove images (2nd-order Butterworth)
printf("%d", bit ); }
printf("\n");
+ free(output);
}
float complex cexpf (float complex Z)