PBOC-based electronic wallet storage process

Source: Internet
Author: User

The PBOC-based electronic wallet storage process for the reference of developers in the Smart Card Industry

1. Storage

First, the terminal and the card have a common key called the storage key: loadkey

Assume loadkey = 11223344556677888877665544332211

When security conditions are met:

Step 1: The terminal sends the deposit initialization command to the card:

APDU:80 50 00 01 0b 0b 01 00001000 001122334455

TLS ins P1 P2 LC keyindex transaction amount terminal No.

The card returns 16 bytes of data (excluding 9000) as follows ):

00000000 0000 02 00 11223344 2988ae5a

Card balance transaction No. Key version number algorithm ID random number mac1

The mac1 calculation process is as follows:

1. computing process key: sessionkey

Inputdata =11223344 0000 8000 (8 bytes)

Random Number transaction number filling data

Loadkey = 11223344556677888877665544332211.

Sessionkey =3des_enypt (inputdata, loadkey)= 9b1d924e05595603

Use loadkey to encrypt inputdata with 3DES

2. Calculate mac1

Inputdata1 =00000000 00001000 01 001122334455

Card balance transaction amount transaction type terminal No.

Sessionkey = 9b1d924e05595603

Mac1 =MAC (inputdata1 sessionkey)= 2988ae5a

Use sessionkey to perform Mac operations on inputdata1

Step 2: the terminal calculates mac1 in the same way and verifies that mac1 returned by the card is correct to check whether the card is valid. If mac1 verification fails, the token terminates the transaction. If mac1 passes verification, perform step 3.

Step 3: terminal computing mac2

Inputdata2 =00001000 01 001122334455 20111221 214822

Transaction amount transaction type terminal number Transaction date transaction time

Sessionkey = 9b1d924e05595603

Mac2 =MAC (inputdata2 sessionkey)= 3a845bf0

Use sessionkey to perform Mac operations on inputdata2

Step 4: The terminal sends the deposit labeling command to the card:

APDU:80 52 00 00 0b 20111221 214822 3a845bf0

TLS ins P1 P2 LC Transaction date transaction time mac2

Step 5: After the card receives the deposit labeling command, calculate mac2 in the same way as the terminal, and verify mac2 in the Command sent by the terminal. If mac2 verification fails, the card returns Sw = 9302 (MAC error). If mac2 passes verification, the card balance plus the transaction amount will be used as the new card balance to update the balance. The transaction counter will add 1, calculate the TAC and return it to the terminal. The calculation process of the TAC is as follows:

The card and terminal also have a common key TAC key: tackey

Assume tackey = 00112233445566778899 aabbccddeeff

Tacsessionkey =XOR (left (8), right (8 ))= 8888888888888888

About 8 bytes of tackey for exclusive or operation

Inputdata3 =00001000 0000 00001000 01 001122334455 20111221 214822

New Balance transaction No. Old transaction amount transaction type terminal No. Transaction date transaction time

Tac = MAC (inputdata3, tacsessionkey) = 6314e5f5

As the data returned by the deposit command, TAC is returned to the terminal. The transaction ends at this point. TAC is an important basis for verifying the authenticity and integrity of the transaction data during liquidation, the transaction records are stored on the terminal.

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.