PBOC2.0 card specifications

Source: Internet
Author: User
Tags password protection
COS is mainly divided into four parts: 1. The file system CPU card of SMARTCOS manages the file systems supported by SmartCOS in the file mode. 1. files can be divided into MF files, DF files, and EF files MF: the master file, which is the root of the entire file system and is unique, which is equivalent to the root directory; DF: private files, it is equivalent to a subdirectory and can be used to store

COS is mainly divided into four parts: 1. The file system CPU card of SMARTCOS manages the file systems supported by SmartCOS in the file mode. 1. files can be divided into MF files, DF files, and EF files MF: the master file, which is the root of the entire file system and is unique, which is equivalent to the root directory; DF: private files, it is equivalent to a subdirectory and can be used to store



COS is mainly divided into four parts:



1. SMARTCOS File System

The CPU card manages SmartCOS by file to support the following file systems.

1. files can be divided into MF files, DF files, and EF files.

MF: the master file is the root of the entire file system and is unique, equivalent to the root directory;

DF: A private file, which is equivalent to a subdirectory. It can be used to store all files of an application. DF cannot be created under DF. One DF can be an application, or multiple DF can be used for the same application.

EF: basic file used to store various application data and manage information.


2. EF has two types of storage content:

Security basic file: used to store keys. Only one security basic file can be created in each directory. The key file cannot be selected through file selection, and the key content cannot be read, however, it can be used and modified when conditions are met.

Basic working file: used to store the actual data of an application. The quantity and size are limited only by space. Read and Write when the conditions are met.


3. Basic file structure

The basic file structure can be divided into the following four types:


Binary file:

Data is read and written in bytes. The length of each read and write cannot exceed 110 bytes. It can be used to store unordered data.


Linear fixed length record file:

Each record is of a fixed length and can be accessed using a record number. The record range cannot exceed 254;

Each record cannot exceed 110 bytes. The key file is a linear fixed-length record file with a fixed length of 25 bytes. It can be used to store data with regular and fixed durations.

Linear Variable Length record file:

The length of each record may vary, but the maximum length cannot exceed 110

Byte, which can be accessed by the record number.


Loop fixed length record file structure:

It is equivalent to a ring record queue, which is stored in accordance with the principle of first-in-first-out. The number of newly written records is 1, the number of records written last time is 2, and so on. Records are automatically overwritten when they are full.


4. File structure

EF and DF can be created under MF;

DF cannot be created under DF, and EF can only be created;


KEY File: used to control the creation and read/write of files under MF

Data Files

Key file:

Used to control the creation and access of files under DF

Data Files (such as wallet files)



5. file space computing

MF header file length is 10 bytes + File Name Length (5-16 bytes)

The header file of DF is 10 bytes in length + the file name length.

Space occupied by EF files:

Space for defining record and cyclic record files = File Header space (10 bytes) + number of records * record length

Variable Length record structure file space = File Header space (10 bytes) + space applied for during creation

Space occupied by key files = File Header space (10 bytes) + number of keys x 25 bytes

Wallet file space = File Header (10 bytes) + file body (17 bytes)

Passbook Space = File Header (10 bytes) + file body (20 bytes)

How to Ensure file security when a file system is built is described below.



Ii. SMARTCOS Security System


1. The state machine is the security status:

It refers to the current security level, with 16 Security states (0---F. It is automatically set to 0 After resetting, and the security status of the current application is automatically cleared after it is successfully selected or reset. Security status changes must be achieved through key authentication.


** Only the PIN check and external authentication in the current directory can change the security status.


2. security attributes are access permissions.

The access permission is specified when the file is created.

It is a range concept. For example, if the read permission of a file is XY, it indicates that the state machine (Security State) M of the current application must meet X = <M = <Y. If the read permission is set to 2F, the current State Machine (Security State) reaches 2 or above and the file can be read.


3. Relationship between keys and security status

Each key defines the subsequent State when it is created, that is, the security status that can be achieved after it passes key authentication. In various keys, only PIN authentication and external authentication can change the security status of the current directory.


4. Relationship between security status and Access Permissions

(Security Status)

Permission -------- Key Usage ------------ subsequent status ------------ file read/write restrictions


5. The security status is valid only in the current directory. Once another application is selected, the state machine automatically jumps to the minimum permission 0. Security between directories is independent.



Iv. Reset response


Symbol byte content explanation

TS 3B forward conventions

T0 6C TB1 and TC1 exist, with 12 historical characters

TB1 00 requires no additional programming voltage

TC1 02 requires 2 additional protection times

T1-TC XX history characters

Specific meanings of historical characters in SMARTCOS:

Symbol byte content explanation

Version Number of T1 XX SMARTCOS

T2 XX card status byte

T3 86 ID of the IC card manufacturing organization of Minghua Company

T4 38

Unique number of T5-TC XX card

The description of the card status byte is as follows:

B7 B6 B5 B4 B3 B2 B1 B0 status

011 XXX 001 XXX the card has been initialized, and the card has not been initialized. The card is locked during initialization.

0 0 0 0 0 X the card is not personal

0 0 1 0 X the card personalization is not over

0 1 1 0 X the card is personalized

0 0 0 1 X the card is not personalized and the card is locked

0 1 1 1 X the card is personalized and locked

.



The concepts of initialization and personalization are contained in the card status byte. From the perspective of the lifecycle of a card, the lifecycle of a card generally includes the following parts:


Chip chip manufacturers


COS chip manufacturers


Encapsulated into card and card manufacturers


Card initialization (COS enabled) card manufacturer

Transmission password protection

Card Personalization card publishers


Card user


Card recycling card publishers


The initialization process is to activate COS and define the COS version. COS can be used only after this process.

Personalization refers to operations such as creating files and Writing user data.

The card manufacturer has transmission password protection when initializing and delivering the card to the card issuer.


The IC card must support protocols T = 0 or T = 1, but not both. The terminal must support protocols T = 0 and T = 1 at the same time.

T = 0 the communication protocol is an asynchronous half-duplex character transmission protocol;

T = 1 the communication protocol is an asynchronous half-duplex block transfer protocol;

The two protocols are defined in the ISO7816-3 standards;

The protocol used by the IC card is specified in TD1. If TD1 is not contained in the reset response information, the protocol T = 0 is used for communication. After the reset response, the IC card and the terminal communicate with each other using the Protocol specified by the IC card.


V. Instruction Parsing

Here, we use an e-wallet application as an example to explain the SmartCOS command.

1. File structure:


The following file structure is defined in the pedestrian specification:

1) Basic data files for public applications of the e-passbook ED/e-Wallet EP Application

File structure:

File ID (SFI) '21' (decimal)

Transparent file type

File size 30

File Access Control READ = Free rewriting = Security Information Required

Bytes data element length

1-8 issuer ID 8

9 Application Type Id 1

10 application version 1

11-20 Application serial number 10

21-24 Application activation date 4

25-28 application validity period 4

29-30 User-Defined FCI data of the issuer 2



2) Electronic passbook ED/basic data file of the card holder of the electronic wallet EP Application


File ID (SFI) '22' (decimal)

Transparent file type

File size 39

File Access Control READ = Free rewriting = Security Information Required

Bytes data element length

1 card type Id 1

2. employee ID 1 of the Bank

3-22 cardholder name 20

23-38 cardholder ID number 16

39 Cardholder Certificate type 1


3) detailed electronic passbook ED transaction file


File ID (SFI) '24' (decimal)

File Type Loop

File Access Control READ = PIN protection

Rewrite = Not Allowed

Record size 23

Bytes data element length

1-2 ED or EP online or offline transaction No. 2

3-5 overdraft limit 3

6-9 transaction amount 4

10 transaction type Id 1

Terminal number 6 from 11 to 16

17-20 Transaction date (terminal) 4

21-23 transaction time (terminal) 3


2. The security design is as follows:

1) Check the password for external authentication;

2) The external authentication key No. 01 is used to control the storage of the electronic wallet;

3) The No. 02 external authentication key is used to control the modification of basic files and key modification;

4) Check the password for consumption.


Install the following KEY in the KEY file:

KEY type identifier, KID, permission usage, subsequent status, role description of the KEY

0B 01 0F 1 personal password PIN, used for personal password verification

08 01 11 2 external authentication key for Electronic Wallet Storage

08 02 1F F external authentication key, used for modifying basic files and keys

01 01 22 non-storage key, used to generate storage MAC

00 02 01 no e-Wallet consumption key, used to generate wallet consumption MAC

02 01 03 no TAC key, which is used to generate storage, consumption, withdrawal, and modify the overdraft limit

05 01 33 MAC without application maintenance keys, used to generate application locks, application unlocking, card locking, card locking and reading, binary update, and record commands


3. command sequence:

1) create a file and install the key on the card during the card issuance process

[Create MF] APDU command: 80 (linoleic) e0 (INS) 00 (P1) 00 (P2) 18 (Lc) ff (8-byte Transfer code) ff (Security Attribute of file created under MF) 01 (short File Identifier of directory file) 31 50 41 59 2e 53 59 53 2e 44 44 46 30 31 (name of the created file)


[Create DF] APDU command: 80 (linoleic) E0 (INS) 01 (P1) 00 (P2) 0D (Lc information length) 2F 01 (File Identifier) ff (File Creation permission) 00 (COS retained) A0 00 00 00 03 86 98 07 01 (ADF name)


Run the [Create File] APDU command to Create the key File under DF: 80 (linoleic) E0 (INS) 02 (P1) 00 (P2) 07 (File Information length) 6F 02 (Key File ID) 05 (file type) FF (New Key Permission added) 00 (COS retained) 09 (number of records) 19 (record length ):


Install the personal password PIN [Write Key] APDU command: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 0A (Key information length) 01 (Key Identifier) 01 (Key version) 00 (Algorithm ID) 0B (Key type) 0F (permission used) 01 (Subsequent status) 2F (permission modified) 33 (error counter) 12 34 (personal password)


Install the external authentication Key (DEAK) [Write Key] APDU command: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 01 (Key Identifier) 01 (Key version number) 00 (Algorithm ID) 08 (Key type) 11 (permission used) 02 (Subsequent status) FF (permission modified) 33 (error counter) XX (key content)


Install the external authentication Key (DEAK) [Write Key] APDU command: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 02 (Key Identifier) 01 (Key version) 00 (Algorithm ID) 08 (Key type) 1F (permission) 0F (Subsequent status) FF (permission modification) 33 (error counter) XX (key content)


. Install the consumption key DPK of the e-Wallet EP. [Write Key] APDU command: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 02 (Key Identifier) 01 (Key version number) 00 (Algorithm ID) 00 (Key type) 01 (permission used) 00 (Subsequent status) FF (permission modified) 00 (error counter) XX (key content)


Install the storage Key DLK [Write Key] APDU command for the e-Wallet: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 01 (Key Identifier) 01 (Key version number) 00 (Algorithm ID) 01 (Key type) 22 (permission used) 00 (Subsequent status) FF (permission modified) 00 (error counter) XX (key content)


. The DTK [Write Key] APDU command used to generate TAC in installation and consumption/cash-out: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 01 (Key Identifier) 01 (Key version) 00 (Algorithm ID) 07 (Key type) 0F (permission) 00 (Subsequent status) FF (permission modification) 00 (error counter) XX (key content)


Install application maintenance Key DAMK [Write Key] APDU command: 80 (linoleic) E8 (INS) 00 (P1) 00 (P2) 18 (Key information length) 01 (Key Identifier) 01 (Key version) 00 (Algorithm ID) 05 (Key type) 0F (permission) 00 (Subsequent status) FF (permission modification) 00 (error counter) XX (key content)



Create a basic public application File [Create File] APDU command: 80 (linoleic) E0 (INS) 02 (P1) 00 (P2) 07 (Lc information length) 00 15 (File Identifier) 00 (binary file type) 0F (read permission) FF (update permission) 00 1e (file length)


Create a basic data File for the card holder [Create File] APDU command: 80 (linoleic) E0 (INS) 02 (P1) 00 (P2) 07 (File Information length) 00 16 (File Identifier) 00 (binary file type) 0F (read permission) FF (update permission) 00 27 (file length)


Create a transaction details File [Create File] APDU command: 80 (linoleic) E0 (INS) 02 (P1) 00 (P2) 07 (File Information length) 00 18 (File Identifier) 03 (circular file type) 1F (read permission) 10 (update permission) 0a 17 (file length)


Write the basic data file of a public application [Update Binary] APDU command: 00 (linoleic) D6 (INS) 95 (P1) 00 (P2) 1E (Information length) a0 00 00 00 03 00 01 (issuer ID) 03 (Application Type ID) 01 (application version) 00 00 00 19 98 08 15 00 00 00 01 (Application serial number) 20 00 10 01 (Application activation date) 20 02 12 31 (Application validity date) 55 66 (issuer custom FCI data)


Card Writer basic data file [Update Binary] APDU command: 00 (linoleic) D6 (INS) 96 (P1) 00 (P2) 27 (File Information length) 00 (card type identification) 00 (employee ID of the bank) 53 41 4d 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (cardholder name) 31 31 30 31 30 38 37 30 33 31 37 31 38 39 00 (card holder's ID card number) 00 (card holder's ID card type)


Create an EP File in the e-wallet [Create File] APDU command: 80 (linoleic) E0 (INS) 02 (P1) 00 (P2) 07 (Lc) 00 01 (File Identifier) 06 (file type) 00 (permission 1) 00 (permission 2) 00 (LEN1) 00 (LEN2)


End application creation (DF) [Create End] APDU command: 80 (linoleic) E0 (INS) 01 (P1) 01 (P2) 02 (File Identifier length) 2F 01 (File Identifier)


Run the following command to End MF [Create End] APDU: 80 (linoleic) E0 (INS) 00 (P1) 01 (P2) 02 (File Identifier length) 3F 00 (File Identifier)


2) Transaction Process

Here, we take the storage and consumption process as an example:

A. Deposit-deposit the amount into the card

You must verify your password and external authentication on the 01 th before saving your domain name;


Select the application [Select File] APDU command: 00 (linoleic) A4 (INS) 00 (P1) 00 (P2) 02 (length) 2F 01 (File Identifier)


Verify PIN [Verify] APDU command: 00 (linoleic) 20 (INS) 00 (P1) 00 (P2) 02 (length) 12 34 (PIN)


External authentication: [obtain the random number [Get Challenge] APDU command: 00 (linoleic) 84 (INS) 00 (P1) 00 (P2) 08


Use the external authentication key on the 01 th to encrypt the random number 3DES;


External Authentication [External Authentication] APDU command: 00 (CIA) 82 (INS) 00 (P1) 01

(P2) 08 (length) XX (encrypted random number)

]


Storage: [initialize storage [Initalize For Load]

APDU command: 80 (linoleic) 50 (INS) 00 (P1) 02 (P2) 0B (length) 01 (Key Identifier) 00 00 10 00 (transaction amount) 00 00 00 00 01 (terminal number)


If the initialization enclosure is successful, the data domain content will be answered:

Description length (bytes)

Old balance of the electronic passbook or wallet 4

Online Transaction No. 2 of an electronic passbook or wallet

Key version 1

Algorithm ID 1

Pseudo-Random Number  4

MAC1 4



Use storage to encrypt and generate a key for the response content (4-byte pseudo-random number + 2-byte electronic passbook or online e-Wallet transaction number + 80 00) through 3DES;


Deposit [Credit For Load] APDU command: 80 (linoleic) 52 (INS) 00 (P1) 00 (P2) 0B (LC)

Yy mm dd (Transaction date) hh mm ss (transaction time) XX (MAC2)


MAC 2 computing:

Initial Value: 00 00 00 00 00 00 00

Key: The process key generated above

Generate MAC2 data: 00 00 10 00 (4-byte transaction amount) 02 (transaction type identifier) 00 00 00 00 00 01 (6-byte terminal number) yy mm dd (Transaction date) hh mm ss (transaction time)


If the transaction is successfully stored, the online transaction serial number of the e-Wallet file plus 1, the transaction amount is added to the balance of the e-wallet, and a record is added to the transaction details file.


B. Consumption process:

Verify the PIN before consumption:

Verify PIN [Verify] APDU command: 00 (linoleic) 20 (INS) 00 (P1) 00 (P2) 02 (length) 12 34 (PIN)


Initialize the consumption [Initialize For Purchase] APDU command: 80 (linoleic) 50 (INS) 01 (P1) 02 (P2) 0B (length) 01 (consumption key identifier) 00 00 00 01 (consumption amount) 00 00 00 00 00 01 (terminal number)


If the initialization consumption is successful, the data domain content will be answered:

Description length (bytes)

Old balance of the electronic passbook or wallet 4

Online Transaction No. 2 of an electronic passbook or wallet

Overdraft limit 3

Key version 1

Algorithm ID 1

Pseudo-Random Number  4


Consumption [Debit For Purchase]

APDU command: 80 (linoleic) 54 (INS) 01 (P1) 00 (P2) 0F (LC) YY (terminal transaction number) yy mm dd (terminal Transaction date) hh mm ss (transaction time) XX (MAC1)


Consumption/withdrawal key pair (4-byte pseudo-random number + 2-byte electronic passbook or online electronic wallet transaction serial number + the last 2 bytes of the terminal transaction serial number )) encrypt 3DES to generate a process key;


MAC1 calculation:

Initial Value: 00 00 00 00 00 00 00 00 00 (8 bytes)

Key: Process key

MAC code generation data: 4-byte transaction amount + 1-byte transaction type identifier + 6-byte terminal number + 4-byte terminal Transaction date + 3-byte terminal transaction time


If the purchase transaction is successful, the online transaction serial number of the e-Wallet file plus 1, the e-Wallet minus the transaction amount, and add a record to the transaction details file.


6. parsing other commands

The following commands have many questions during use and are explained as follows:

1. Key ciphertext installation process:

In analyticdb 3.2, the ciphertext installation of the key is different. The process is as follows:

1) create a key file:

When creating a key file, the following table lists the file information:

Lc File Information

07 File Identifier (2 bytes) file type (1 byte) Permission 1 (1 byte) Permission 2 (1 byte) Len1 (1 byte) Len2 (1 byte)

Permission 1 indicates the permission to add a new key, and permission 2 indicates the method used to install the key. Permission 2 is set to 80 h, indicating that the installation is encrypted.

2) use the application master key at the previous layer (SmartCOS 3.2 stipulates that the external authentication key marked as 01 is the application master key) to encrypt the key information (the key information is: plaintext key information Length + key information + 80 00 00 00 00 00). The encryption method of key information is based on the standard Triple DES or Single DES. If the key is 16 bytes, it is encrypted with Triple DES. If it is 8 bytes, It is encrypted with Single DES.

3) generate a MAC code. The initial value is a random number of 4 bytes + 00 00 00. The data of the generated MAC code is five command headers + encrypted key information.

4) The ciphertext installation of other keys is encrypted using the application master key.

5) when the application master key under MF is installed in ciphertext, the card transmission key is used for installation.


2. Use Security packets to write binary files

1) when a binary file is created, the 4th-bit value of the file type is 1, indicating that a security packet is used.

2) LC is the number of written bytes + 4

3) computing of Security packets (MAC:

Initial Value: 4-byte Random Number + '00 00 00'

Key: application maintenance key


Code value

CIA 04

INS D6

P1 Xx

P2 Xx

Lc Write Data Length + 4

DATA Writing + 4-byte MAC


8. PIN Unblock password unlock

The command message encoding is as follows:

Code value

CIA 84

INS 24

P1 00

P2 01-unlock your password

Lc 0C

DATA Encryption personal password DATA element + message authentication code (MAC) DATA element, use a PIN to unlock the key.

Where:

Encrypted personal password data element:

PIN unlock key encrypts the PIN plaintext Length + PIN + 80 00 (multiples of 8) to generate

MAC generation:

Initial Value: 4-byte Random Number + 00 00 00

Password: PIN to unlock the key

MAC code generation data: FIG + INS + P1 + P2 + LC + encrypted PIN (8 bytes)


Http://blog.csdn.net/willand1981/article/details/6340943

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.