1、KS X ISO/IEC 7816-7 KSKSKSKS SKSKSKS KSKSKS SKSKS KSKS SKS KS ID IC 7: (SCQL) KS X ISO/IEC 7816-7 : 2002 (2012 ) 2002 9 19 http:/www.kats.go.kr X ISO/IEC 78167:2002 : e- ( ) ( ) ( ) ( ) ( ) : (http:/www.standard.go.kr) : :1998 12 31 :2002 9 19 :2012 12 28 : e- 2012-0833 : ( 02-509-7262) (http:/www.k
2、ats.go.kr). 10 5 , . ICS 35.240.15 KS X ISO/IECID IC 7: (SCQL) 78167 :2002 (2012 ) Identification cardsIntegrated circuit(s) cards with contacts part 7:Interindustry commands for Structured Card Query Language(SCQL) ISO/IEC 78167 Identification cardsIntegrated circuit(s) cards with contactsPart 7: I
3、nterindustry commands for Structured Card Query Language(SCQL) . 1. . SCQL(SQL ) 2. . . ( .) . KS X ISO/IEC 78164:2001 ID IC 4: ISO/IEC 78164:1995 Information technologyIdentification cardsIntegrated circuit(s) cards with contactsPart 4:Interindustry commands for interchange KS X ISO/IEC 78166 ID IC
4、 6: ISO/IEC 78166:1996 Identification cardsIntegrated circuit(s) cards with contactsPart 6:Interindustry data elements ISO/IEC 9075:1992 Information technologyDatabase languagesSQL2 KS X 2017:1990 ( SQL) . 3. 3.1 3.1.1 (Database File) (, , ) 3.1.2 (Dictionary) (View) 3.1.3 (System Table) (Table) 3.1
5、.4 (Table) 3.1.5 (View) 3.2 X ISO/IEC 78167:2002 2 APDU Application Protocol Data Unit( ) API Application Programming Interface ( ) DB Database() DB_O Database Owner( ) DBBU Database Basic User( ) DBF Datbase File ( ) DBOO Database Object Owner( ) DF Dedicated File( ) DO Data Object( ) ICC Integrate
6、d Circuit(s) Card( ) IFD Interface Device ( ) MF Master File ( ) SCQL Structured Card Query Language( ) SQL Structured Query Language( ) TLV Tag, Length, Value (, , ) 4. SCQL 4.1 SCQL ICC SCQL . SQL(KS X 2017 ) , KS X ISO/IEC 78164 . DBF . DF DBF DF DBF . MF . 1 . 1 () EF / (working) EF X ISO/IEC 78
7、167:2002 3 SQLAPI(API=Application Programming Interface) SCQL SQL . SCQL ICC (distributed) SQL . 2 ICC SQL . 2 (distributed) SQL SCQL 4.2 SCQL SCQL , . . . (named) . ICC . 3 . :, 8 : . :, 8 :115 : . (size): 0 254 :(string) 3 SCQL () SQLAPI SQL SQL SQL SCQL SCQL IFD/ICC 1 2 1 3 2 3 X ISO/IEC 78167:20
8、02 4 . read(select) insert update delete 4.3 SCQL . 2 . ( 4 ). (, 20 ) ( 5 ). 4 SCQL () 5 SCQL () . SCQL . . . 1 2 3 2 3 1 2 3 2 3 . 1 2 3 1 2 3 () . X ISO/IEC 78167:2002 5 read(select) update 4.4 SCQL . 3 . ( *O) ( *U) ( *P) . . . (action) . 68 . 6 * O ( ) () id T= V= : : (:) . X ISO/IEC 78167:2002
9、 6 7 8 . SCQL . (select). 4.5 SCQL SCQL . (identifier) . 1 . * U ( ) () id DB_ODB DBOODB DBBUDB id id . * P ( ) id (grantee) id (grantor) . X ISO/IEC 78167:2002 7 1 SCQL DB_O DBOO DBBU / (, ) / DBOO DBBU / (, ) / DBOO *O, *P, *U OBJOWN DBBU id id S C Q L DB_O (inserted) . 5. SCQL 5.1 (Structured Car
10、d Query Language, SCQL) (Structured Query Language, SQL) ICC . SQL PERFORM SCQL OPERATION( 9 2 ) SCQL (operation) . 1. TLV . . 2. SQL word . 3. Parameter Ln(number ) N( Parameter ) . 9 SQL SCQL SQL SCQL X ISO/IEC 78167:2002 8 (instruction) (parameter) . . (parameter) TLV . PERFORM SCQL OPERAT10N 2 S
11、CQL SCQL . PERFORM TRANSACTION OPERATION ( 10 ) PERFORM USER OPERATION ( 10 ) 5.2 SCQL 10 . 10 SCQL (instruction) (code) (operation) 2 . SCQL X ISO/IEC 78167:2002 9 2 (instruction code) (operation) INScode 10 PERFORM SCQL OPERATION P2 80=CREATE TABLE 81=CREATE VIEW 82=CREATE DICTIONARY 83=DROP TABLE
12、 84=DROP VIEW 85=GRANT 86=REVOKE 87=DECLARE CURSOR 88=OPEN 89=NEXT 8 A = F ET CH 8B=FETCH NEXT 8 C = I N SER T 8 D = UP DA T E 8E=DELETE 12 PERFORM TRANSACTION OPERATION P2 80=BEGIN 81=COMMIT 82=ROLLBACK 14 PERFORM USER OPERATION P2 80=PRESENT USER 81=CREATE USER 82=DELETE USER A . 5.3 SQL . SQL (SQ
13、L ). : := | or . * . Lp ( ) Lp Ln = 01 N = , 3 . X ISO/IEC 78167:2002 10 3 = 3D 3C 3E 4C 47 23 . 5.4 SW1SW2 (response) . 4 ISO/IEC 7816 SW1SW2 . . SW . 4 (Status bytes) SW1SW2 Def. in part 9000 61xx 4 4 , GET RESPONSE xx . 6282 4 6500 6581 4 4 . (, .) 6700 4 6900 6982 6985 4 4 4 . . . . 6A00 6A80 6A
14、81 6A84 6A88 6A89 4 4 4 4 4 7 . . . . 6Cxx 4 Le:SW2 6D00 4 . 5.5 . : : = |,. : : = A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z : : = 0|1|2|3|4|5|6|7|8|9 : : = X ISO/IEC 78167:2002 11 : : = : : = : : = : : = |SYSTAB : : = | | | | | : : = : : = : : = | : : = . : : = * : : = | : : = CHOLDER : :
15、 = PUBLIC (*) (dont care), . id . id id id id . id id id . 1. id (full) . 2. .* . id id id . 1. id . 2. * . 3. .*.* . PRESENT USER (operation) id . , . (DECLARE CURSOR INSERT ) 5.6 , (security attribute) . : : = (part) X ISO/IEC 78167:2002 12 ( , ) , (security attribute) (authentication) (secure mes
16、saging) . (authentication) . 6. (Database operations) 6.1 CREATE TABLE 6.1.1 S C Q L CREATE TABLE (column) . (object description table) . 6.1.2 DB_O DBOO . 6.1.3 SCQL (operation) SQL . CREATE TABLE , . : : = : : = (,.) : : = : : = : : = : : = USER : : = U : : = . : : = : : = V : : = . ( ) . USER(col
17、umnUSER) INSERT UPDATE id USER(columnUSER) . X ISO/IEC 78167:2002 13 5 CREATE TABLE PERFORM SCQL OPERATION APDU CLA INS P1 P2 Lc Le KS X ISO/IEC 78164 10(=PERFORM SCQL OPERATION) 00, (RFU) 80= CREATE TABLE Lp Ln N : Lp : Lp Lp, . 6.1.4 6 CREATE TABLE PERFORM SCQL OPERATION APDU SW1SW2 6.1.5 . SW1 =
18、69, SW2 = 82: . SW1 = 6A, SW2 = 80: . S W2 = 84 : . S W2 = 89 : . 6.2 CREATE VIEW 6.2.1 SCQL CREATE VIEW . . 6.2.2 . 6.2.3 SCQL SQL . CREATE VIEW AS , . = : : = SELECT FROM WHEREAND, . : : = : : = *|, : : = : : = : : = =| : : = * = X ISO/IEC 78167:2002 14 7 CREATE VIEW PERFORM SCQL OPERATION APDU CL
19、A INS P1 P2 Lc Le KS X ISO/IEC 78164 10(=PERFORM SCQL OPERATION) 00, (RFU) 81=CREATE VIEW Lp Lp Ln N : Lp Ln 3 N : Lp Lp Lp Lp, (Empty) 1. AND . 2. Ln=00(= ) . 6.2.4 8 CREATE VIEW PERFORM SCQL OPERATION APDU SW1SW2 6.2.5 . SW1 = 69 SW2 = 82: . SW1 = 6A SW2 = 80: . S W2 = 84 : . S W2 = 88 : . S W2 =
20、89 : . 6.3 CREATE DICTIONARY 6.3.1 SCQL CREATE DICTIONARY *O, *U *P . (fixed) . 11, 12 . . 6.3.2 DB_O DBOO . 6.3.3 SCQL CREATE DICTIONARY SQL . CREATE DICTIONARY : : = | SYSTAB _O X ISO/IEC 78167:2002 15 , _U . _P . , SYSTAB . 9 CREATE DICTIONARY PERFORM SCQL OPERATION APDU CLA INS P1 P2 Lc Le KS X
21、ISO/IEC 78164 10(=PERFORM SCQL OPERATION) 00, (RFU) 82=CREATE DICTIONARY Lp . 10 id DB_O *O ( ) OBJNAM OBJOWN OBJTYP OBJDES _O _U _P 10 OBJOPT . 11 id DBOO *O ( ) OBJNAM OBJOWN OBJTYP OBJDES _O :OBJOWN= _U :OBJOWN= _P :OBJOWN= 11 OBJOPT . 6.3.4 12 CREATE DICTIONARY PERFORM SCQL OPERATION APDU SW1SW2
22、 6.3.5 . SW1 =69 SW2 =82: . X ISO/IEC 78167:2002 16 SW1 =6A SW2 =80: . S W2 = 8 4 : . S W2 = 8 9 : . 6.4 DROP TABLE 6.4.1 SCQL DROP TABLE . 6.4.2 . . 6.4.3 SCQL DROP TABLE SQL . DROP TABLE 13 DROP TABLE PERFORM SCQL OPERATION APDU CLA INS P1 P2 Lc Le KS X ISO/IEC 78164 10(=PERFORM SCQL OPERATION) 00, (RFU) 83=DROP TABLE Lp . 6.4.4 14 DROP TABLE PERFORM