📄 atr.c
字号:
/* ============================================================================ Project Name : jayaCard Module Name : proto/bios/init/atr.c Version : $Id: atr.c,v 1.14 2004/01/11 09:56:31 dgil Exp $ Description: ATR (except for the first byte 0x3B) The Original Code is jayaCard code. The Initial Developer of the Original Code is Gilles Dumortier. Portions created by the Initial Developer are Copyright (C) 2002-2004 the Initial Developer. All Rights Reserved. Contributor(s): This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see http://www.gnu.org/licenses/gpl.html History Rev Description 012603 dgil wrote it from scratch - today we have an entry point ! 031503 dgil use BIOS_SEND() to output the ATR because this function can be called from the T=CL layer (see ATR_GET command). ============================================================================*/#include "precomp.h"/* ============================================================================ __bios_atr() algo: if opcode ATR execute it else if ATR in EEPROM send it else build the default one calling cos_historical_bytes() endif endif ========================================================================= */void __bios_atr(void){ LOCAL(jbyte,i); /* opcode for ATR ? */ if (BIOS_CALL_OPCODE(OPCODE_ATR)==JSEC_OK) return; /* valid ATR in EEPROM ? */ HAL_EEPROM_READ(&u.bBlock[JAYA_BCRYPTO_INPUT0+0],ADDR_EEPROM_ATR,EEPROM_SIZEOF_ATR); if ((u.bBlock[JAYA_BCRYPTO_INPUT0+0]!=0) && (u.bBlock[JAYA_BCRYPTO_INPUT0+0]<=(EEPROM_SIZEOF_ATR-3))) { HAL_CRC_INIT(); for (i=1;i<=u.bBlock[JAYA_BCRYPTO_INPUT0+0];i++) { HAL_CRC_COMPUTE(u.bBlock[JAYA_BCRYPTO_INPUT0+i]); } if ( (HAL_CRC_LO()==u.bBlock[JAYA_BCRYPTO_INPUT0+EEPROM_SIZEOF_ATR-2]) && (HAL_CRC_HI()==u.bBlock[JAYA_BCRYPTO_INPUT0+EEPROM_SIZEOF_ATR-1]) ) { goto send_hist; } } /* send our ATR with the user historical bytes */ u.bBlock[JAYA_BCRYPTO_INPUT0+0] = (cos_historical_bytes(&u.bBlock[JAYA_BCRYPTO_INPUT0+1])&0x0F); BIOS_SEND(u.bBlock[JAYA_BCRYPTO_INPUT0+0] | 0x60); /* b8=!TD b7=TC b6=TB b5=!TA present */ /* send other mandatory part */ /* BIOS_SEND(); TA absent */ BIOS_SEND(0x00); /* TB = 00 VPP not required */ BIOS_SEND(0x00); /* TC = 00 no extra guard time */ /* BIOS_SEND(); TD = absent */ /* then send historical bytes with the check */send_hist: for (i=1;i<=u.bBlock[JAYA_BCRYPTO_INPUT0+0];i++) { BIOS_SEND(u.bBlock[JAYA_BCRYPTO_INPUT0+i]); }}/* ========================================================================= That's all folks ! ========================================================================= */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -