From b236d39f5e9575f185ee5507a2b5c278c503485f Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 21 Mar 2006 23:37:37 +0000 Subject: [PATCH] *** empty log message *** --- gemtag/gemtag.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/gemtag/gemtag.c b/gemtag/gemtag.c index d6191ba..121170f 100644 --- a/gemtag/gemtag.c +++ b/gemtag/gemtag.c @@ -252,8 +252,18 @@ int gemtag_transform_mifare_key(struct gemtag_handle *gh, return 0; } +int gemtag_auth_key(struct gemtag_handle *gh,unsigned char authmode, + int sector,unsigned char *key6) { + + unsigned char buf[32]; + unsigned int len,ret; + + /* to be continued */ + +} + int gemtag_auth_mifare_key(struct gemtag_handle *gh, - unsigned char *key6,int sector) { + unsigned char *key6,int sector) { unsigned char key12[12]; unsigned char buf[32]; @@ -289,10 +299,9 @@ int gemtag_write16(struct gemtag_handle *gh,int sector,unsigned char *data) { unsigned char buf[32]; int ret,len; - buf[0]=GEMTAG_PICC_WRITE16; - buf[1]=sector; - memcpy(buf+2,data,16); - ret=gemtag_transceive(gh,GEMTAG_CMD_COMMON_WRITE,buf,18,buf,&len); + buf[0]=sector; + memcpy(buf+1,data,16); + ret=gemtag_transceive(gh,GEMTAG_CMD_PICC_WRITE,buf,17,buf,&len); return ret; } @@ -361,17 +370,22 @@ int main(int argc, char **argv) { } printf("\n"); - /* try to write some data - printf("write some data to the 5th sector:\n"); + /* try to write some data */ + printf("write some data to the sector 04:\n"); for(i=0;i<16;i++) buf[i]=i; i=4; + ret=gemtag_auth_mifare_key(gh,key6,i); + printf("return = %d\n",ret); + if(ret) printf("auth failed!\n"); ret=gemtag_write16(gh,i,buf); + if(ret) printf("write failed!\n"); + printf("return = %d\n",ret); + ret=gemtag_read16(gh,i,buf); + if(ret) printf("read failed!\n"); printf("return = %d\n",ret); - gemtag_read16(gh,i,buf); printf("%02x: ",i); hexdump(buf,16); printf("\n"); - */ gemtag_close(gh); -- 2.39.2