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];
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;
}
}
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);