Two-way authentication for user cards and machines
Question:
1. Traditional "dark signs"
Classic clips:
Q: Tianwang gaidihu
A: Baota Zhenghe demon
Shake hands and hug each other, comrade! Finally, I found you.
I believe that everyone will have seen the dark part in the spy movies, but the dark part is easy to be stolen by the enemy, so there is a thrilling or tragic story of the revolutionaries, of course, there are some traitors selling.
Security Analysis:
We are very impressed with the fact that the hidden signs are prone to being stolen by third parties.
2. the reference for "dark signs" in cryptography
In the traditional symmetric cryptography system, keys are used to represent the hidden signs of both parties.
Password = Key
Of course, the more complex the code is, the longer the key length, the more secure it is.
However, the hidden signs are too complex to be remembered, so the length of the key in practical applications is not too long (currently, 128-bit keys are commonly used for price comparison)
Symmetric cryptographic algorithms: generally 3DES (112 bits) is used in CPU cards, and other 128 bits, such as idea and AES
3. Practices of two-way authentication in cryptography
Because there is an insecure hidden danger to the hidden signs directly, the two keys are not directly judged in cryptography to be equal.
Instead, the password is used once.
What is a unique password?
That is:
1. Each time one party generates a random number
2. Both parties calculate a random number using the key to obtain a value.
3. Compare whether the random number calculation value is equal
This avoids key leakage because every time a temporary value is obtained, the random number must be calculated.
The key is read again and can only be used for calculation (by using the specified key identifier ).
So even if the random number calculation value is leaked, it does not matter because the next calculation value cannot be used.
4. Implementation of two-way authentication in CPU cards
Entity: CPU card machine
Store a key in the CPU card
Store the same key as the CPU card in the Machine
External authentication steps for CPU cards:
1. The CPU card generates an 8-byte random number and sends it to an external program. The CPU card temporarily stores the random number in the card.
2. An external program sends an 8-byte random number to the machine. The machine uses the key to calculate the random number and obtain the 8-byte random number ciphertext.
3. The external program sends the 8-byte random number ciphertext to the CPU card
4. The CPU card decrypts the 8-byte random number inside the card to obtain the random number plaintext,
5. the CPU is stuck inside the card and the decrypted random number is compared with the random number temporarily stored in step 1. If they are equal, the external authentication is successful.
Therefore, external authentication is a CPU card authentication tool.
Internal machine authentication steps:
1. The machine generates an 8-byte random number and sends it to an external program. The machine temporarily stores the random number in the machine.
2. An external program sends an 8-byte random number to the CPU card. The CPU uses an internal authentication key to calculate the random number and obtain the 8-byte random number ciphertext.
3. The external program sends the 8-byte random number ciphertext to the machine
4. The machine decrypts an 8-byte random number to obtain the random number plaintext,
5. The machine compares the decrypted random number internally with the random number temporarily stored in step 1. If they are the same, internal authentication is successful.
Therefore, internal authentication is a machine-certified CPU card.
In this way, the machine and CPU card achieve two-way authentication.
5. Key Dispersion
Since a machine must be able to authenticate n cards, the keys of each card are different.
The general idea is that there must be n machines corresponding to N cards, but this is too costly and unrealistic.
Cryptography proposes a method called key distribution.
That is, the machine stores the CMK of the user card. During each authentication, the CMK is identified by the user card.
Calculate the key of the user card.