Beispiel #1
0
uint64_t emlGetKey(int sectorNum, int keyType) {
	uint8_t key[6];
	uint8_t* emCARD = BigBuf_get_EM_addr();
	
	memcpy(key, emCARD + 16 * (FirstBlockOfSector(sectorNum) + NumBlocksPerSector(sectorNum) - 1) + keyType * 10, 6);
	return bytes_to_num(key, 6);
}
Beispiel #2
0
int emlGetValBl(uint32_t *blReg, uint8_t *blBlock, int blockNum) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	uint8_t* data = emCARD + blockNum * 16;
	
	if (emlCheckValBl(blockNum)) {
		return 1;
	}
	
	memcpy(blReg, data, 4);
	*blBlock = data[12];
	return 0;
}
Beispiel #3
0
int emlCheckValBl(int blockNum) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	uint8_t* data = emCARD + blockNum * 16;

	if ((data[0] != (data[4] ^ 0xff)) || (data[0] != data[8]) ||
			(data[1] != (data[5] ^ 0xff)) || (data[1] != data[9]) ||
			(data[2] != (data[6] ^ 0xff)) || (data[2] != data[10]) ||
			(data[3] != (data[7] ^ 0xff)) || (data[3] != data[11]) ||
			(data[12] != (data[13] ^ 0xff)) || (data[12] != data[14]) ||
			(data[12] != (data[15] ^ 0xff))
		 ) 
		return 1;
	return 0;
}
Beispiel #4
0
int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	uint8_t* data = emCARD + blockNum * 16;
	
	memcpy(data + 0, &blReg, 4);
	memcpy(data + 8, &blReg, 4);
	blReg = blReg ^ 0xffffffff;
	memcpy(data + 4, &blReg, 4);
	
	data[12] = blBlock;
	data[13] = blBlock ^ 0xff;
	data[14] = blBlock;
	data[15] = blBlock ^ 0xff;
	
	return 0;
}
Beispiel #5
0
void emlClearMem(void) {
	int b;
	
	const uint8_t trailer[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0x80, 0x69, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
	const uint8_t uid[]   =   {0xe6, 0x84, 0x87, 0xf3, 0x16, 0x88, 0x04, 0x00, 0x46, 0x8e, 0x45, 0x55, 0x4d, 0x70, 0x41, 0x04};
	uint8_t* emCARD = BigBuf_get_EM_addr();
	
	memset(emCARD, 0, CARD_MEMORY_SIZE);
	
	// fill sectors trailer data
	for(b = 3; b < 256; b<127?(b+=4):(b+=16)) {
		emlSetMem((uint8_t *)trailer, b , 1);
	}	

	// uid
	emlSetMem((uint8_t *)uid, 0, 1);
	return;
}
Beispiel #6
0
void emlGetMemBt(uint8_t *data, int bytePtr, int byteCount) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	memcpy(data, emCARD + bytePtr, byteCount);
}
Beispiel #7
0
void emlGetMem(uint8_t *data, int blockNum, int blocksCount) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	memcpy(data, emCARD + blockNum * 16, blocksCount * 16);
}
Beispiel #8
0
void emlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth) {
	uint8_t* emCARD = BigBuf_get_EM_addr();
	memcpy(emCARD + blockNum * blockBtWidth, data, blocksCount * blockBtWidth);
}