如何将红色区域数据调用解密函数直接打印到输出控制台(例如:crt控制台)
int main(int argc, char *argv[])
{
unsigned char data[PACKET_MAX_LEN];
int data_len = 0;
int socket_fd = -1; //char test_flag = 0;
struct sockaddr_in dout;
unsigned short i = 0;
char enc_buf[70] = {
0x00,0x00,0x2B,0x72,0x31,0x53,0xA6,0x78,0x1B,0xEB,0xFC,0xD0,0xB9, 0xC8,0x82,0x27,0x09,0xC5,0x4E,0x7F,0xA4,0x07,0xA6,0x78,0x1B,0xEB, 0xFC,0xD0,0xB9,0xC8,0x82,0x27,0x09,0xC5,0x4E,0x7F,0xA4,0x07,0x74, 0x8F,0xC5,0x6F,0xBE,0x08,0x36,0x80,0x6F,0x79,0x81,0x32,0x97,0x38, 0x3D,0x6F,0x0A,0x9C,0xDD,0x96,0x2C,0x20,0x43,0x7D,0x0C,0x5D,0x4C,
0xA8,0x72,0xE6,0xBD,0x12};
char enc_buf1[64];
server_decrypt(enc_buf,enc_buf1,65);
for (i = 0; i < 64; i++) //test
printf("%02x ", enc_buf1[i]);
// unsigned char sent_data[PACKET_MAX_LEN];
//int j;
#if 0 unsigned short xxx; unsigned char zzz[74] = {
0x30, 0x6b, 0x00, 0xa8, 0x01, 0x00, 0x6c, 0x23, 0x31, 0x00, 0x30,
0x30, 0x31, 0x32, 0x33, 0x34, 0x2c, 0x10, 0x00, 0x00, 0x05, 0x80,
0xd9, 0x00};
xxx = calc_crc(zzz, 22);
printf("crc %04x\n", xxx);
#endif /* Initialize sent_apdu_function pointer */
//init_handler();
/* TCP socket server setup */
tcp_set_port(htons(0x1A85));//6789
printf("set udp port is 6789!\n");
printf ("this is first one\n");
if (tcp_init()) printf("udp server socket opened!\n");
int_packet();
while (1) {
/* Initialize test board */
//init_test_handler();
/* TCP process */
socket_fd = tcp_get_socket();
#if 0 decode_apdu_handler(socket_fd, zzz, 74, dout);
return 1;
#endif
#if 0
data_len = 32;
printf("------------------start---------------------\n");
if (decrypt(data, handle_data, data_len) == 0) {
printf("decrypt len = %d\n", data_len);
printf("unsigned char decrypt_data = {\n");
for (j = 0; j < data_len; j++) {
if (j != data_len - 1)
printf("0x%02x, ", handle_data[j]);
else
printf("0x%02x};\n", handle_data[j]);
}
} else
printf("decrypt error!!!\n");
for (j = 0; j < 13; j++) {
sent_data[j] = j;
}
apdu_sent(socket_fd, sent_data, 13, dout);
printf("--------------------------------------------\n");
return 1;
#endif
data_len = tcp_receive(socket_fd, data, PACKET_MAX_LEN, 10, &dout);
if (data_len > 0) {
printf("RX: ");
for (i = 0; i < data_len; i++) //test
printf("%02x ", data[i]);
printf("\n");
decode_apdu_handler(socket_fd, data, data_len, dout);
//apdu_sent(socket_fd, handle_data, data_len, dout);
data_len = 0;
}
usleep(20000);/* 20ms */
}
return 0;
}
/** * @} */
/******************* (C) COPYRIGHT 2012 THIT *****END OF FILE****/