# US 12,192,376 B2 · Method and apparatus for realizing secure signature

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,192,376 B2
- Document ID: US12192376B2
- Status: Granted
- Kind: B2
- Application number: 17/546,692
- Filed: 2021-12-09
- Published: 2022-03-31
- Granted: 2025-01-07
- Earliest claimed: 2019-06-11
- Assignees: Feitian Technologies Co., Ltd.
- Applicants: Feitian Technologies Co., Ltd.
- Inventors: Zhou Lu; Huazhang Yu
- Web page: https://patentgrep.com/patent/US12192376B2

## CPC

- H04L 9/3247: {involving digital signatures}
- H04L 9/0861: {Generation of secret information including derivation or calculation of cryptographic keys or passwords}
- H04L 9/0891: {Revocation or update of secret information, e.g. encryption key update or rekeying}
- H04L 9/3226: {using a predetermined code, e.g. password, passphrase or PIN (network architectures or network communication protocols for supporting authentication of entities using passwords in a packet data network H04L63/083)}
- H04L 9/3236: {using cryptographic hash functions}
- H04L 9/3242: {involving keyed hash functions, e.g. message authentication codes [MACs], CBC-MAC or HMAC}
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

A method and apparatus for realizing secure signature, the method includes: when a PIN verification instruction is received, verifying a first calculation result in the instruction by using a second shared key generated according to a terminal public key and a signature module private key, if the verifying is failed, replacing a stored signature module key pair with a regenerated signature module key pair; otherwise, generating PIN verification signature data and storing the PIN verification signature data, generating a second calculation result according to a second shared key and the PIN verification signature data and sending the second calculation result to the terminal; when a signature operation instruction is received, determining whether the PIN verification signature data in the instruction is consistent with the stored PIN verification signature data, if yes, signing an intermediate data to be signed by using a signature private key.

## Claims

### Claim 1

A method for realizing secure signature, comprising:
step F1, when a personal identification number (PIN) verification instruction sent by a terminal is received, generating, by a signature module, a shared key according to a terminal public key in the PIN verification instruction and a signature module private key stored in the signature module, and verifying first result data in the PIN verification instruction by using the shared key, if the verifying is successful, executing step F2; if the verifying is failed, regenerating a signature module key pair and replacing a stored signature module key pair; wherein the signature module key pair comprises a signature module private key and a signature module public key;
step F2, generating, by the signature module, a random number as first PIN verification signature data and storing the first PIN verification signature data, generating a calculation result by encrypting the first PIN verification signature data by using the shared key, and sending the second calculation result to the terminal;
step H1, when a signature operation instruction sent by the terminal is received, determining, by the signature module, whether second PIN verification signature data in the signature operation instruction is consistent with the first PIN verification signature data, if yes, executing step H2; otherwise, reporting an error;
step H2, signing, by the signature module, to-be-signed intermediate data in the signature operation instruction by using a stored signature private key to obtain a signature result; and
step H3, returning, by the signature module, the signature result to the termina, and determining whether a current state meets a preset condition, if yes, clearing the first PIN verification signature data, otherwise ending, wherein the current state comprises signature times or a signature valid duration;
wherein the step F2 further comprises: setting the signature times as an initial value;
and the determining whether the current state meets the preset condition comprises: updating the signature times, and determining whether the signature times equal to a preset value, if yes, determining that the current states meets the preset condition; otherwise, determining that the current states does not meet the preset condition;
or, the step F2 further comprises: setting the signature valid duration;
and the determining whether the current state meets the preset condition comprises:
determining whether a current time is in the signature valid duration; if yes, determining that the current states meets the preset condition; otherwise, determining that the current states does not meet the preset condition.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the verifying of the first result data in the PIN verification instruction by using the shared key comprises:
performing, by the signature module, decryption operation on the first result data in the PIN verification instruction by using the generated shared key to obtain a second result data, obtaining an PIN code stored internally and converting the PIN code stored internally to first byte stream data, performing hash operation on the first byte stream data and intercepting data in first 16 bytes of a hash result as intercepted data, and determining whether the intercepted data is consistent with the second result data, if yes, the verifying is successful; otherwise, the verifying is failed.

### Claim 3 (depends on 1)

The method according to claim 1, wherein the generating of the shared key according to the terminal public key in the PIN verification instruction and the stored signature module private key comprises: calculating, by the signature module, the terminal public key in the PIN verification instruction and the stored signature module private key to obtain a first calculation value, and performing hash operation on the first calculation value to obtain a first hash value and taking the first hash value as the shared key.

### Claim 4 (depends on 1)

The method according to claim 1, further comprising replace the step H1 and the step H2 with:
step P1, when a secure environment setting operation instruction sent by the terminal is received, determining, by the signature module, whether third PIN verification signature data in the secure environment setting operation instruction is consistent with the first PIN verification signature data, if yes, executing step P2; otherwise, ending;
step P2, determining, by the signature module, whether a signature setting algorithm is legitimate according to an algorithm identification (ID) and a key container ID in the secure environment setting instruction, if yes, executing step P3; otherwise, ending;
step P3, opening, by the signature module, a corresponding key container according to the key container ID, and setting a corresponding algorithm according to the algorithm ID, and returning a secure environment setting succeed response to the terminal;
step T1, when a hash operation instruction sent by the terminal is received, determining, by the signature module, whether fourth PIN verification signature data in the hash operation instruction is consistent with the first PIN verification signature data, if yes, executing step T2; otherwise, ending;
step T2, parsing, by the signature module, the hash operation instruction to obtain data to be signed and storing the data to be signed;
step T3, performing, by the signature module, hash operation on the data to be signed according to a set algorithm to obtain a hash value and storing the hash value, and returning a hash operation successful response to the terminal;
step Q1, when the signature operation instruction sent by the terminal is received, determining, by the signature module, whether second PIN verification signature data in the signature operation instruction is consistent with the first PIN verification signature data, if yes, executing step Q2; otherwise, ending;
step Q2, intercepting, by the signature module, key information from the stored data to be signed and determining whether the intercepting is successful, if yes, executing step Q3; otherwise, ending;
step Q3, displaying, by the signature module, the key information and determining whether user confirmation information is received, if yes, signing, by the signature module, the stored hash value by using a signature private key in a container corresponding to a container ID in the signature operation instruction to obtain a signature result and storing the signature result; otherwise, ending;
step Q4, determining, by the signature module, whether the current state meets the preset condition, if yes, clearing the first PIN verification signature data, and returning signature success information to the terminal; otherwise, returning signature failure information to the terminal; and
step L1, when a signature result acquisition instruction sent by the terminal is received, returning, by the signature module, the signature result to the terminal.

### Claim 5 (depends on 1)

The method according to claim 1, further comprising:
when a PIN code setting instruction is received, determining, by the signature module, whether a PIN code is set, if yes, reporting an error; otherwise, verifying the PIN code setting instruction, if the verifying is successful, generating a PIN code according to a first ciphertext in the PIN code setting instruction and storing the PIN code; if the verifying is failed, ending a process of verifying the PIN code setting instruction.

### Claim 6 (depends on 5)

The method according to claim 5, wherein verifying, by the signature module, the PIN code setting instruction comprises:
step M1, calculating, by the signature module, the stored signature module private key and a terminal public key in the PIN code setting instruction to obtain a first calculation value, performing hash operation on the first calculation value, and taking a hash result as the shared key;
step M2, performing, by the signature module, hash-based message authentication code (HMAC) operation on the first ciphertext in the PIN code setting instruction by using the shared key to obtain a second operation result, and intercepting data in first 16 bytes of the second operation result to obtain the intercepted data; and
step M3, determining, by the signature module, whether the intercepted data is consistent with first result data in the PIN code setting instruction, if yes, the verifying is successful;
otherwise, the verifying is failed.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the generating of the PIN code according to the first ciphertext in the PIN code setting instruction and storing the PIN code comprises:
step N1, decrypting, by the signature module, the first ciphertext in the PIN code setting instruction by using the shared key to obtain a first decrypted value, removing padding data in the first decrypted value to obtain a password intermediate value;
step N2, determining, by the signature module, whether the password intermediate value is less than a first preset value, if yes, reporting an error; otherwise, executing step N3; and
step N3, performing, by the signature module, hash operation on the password intermediate value to obtain a hash result, and intercepting data in first 16 bytes of the hash result and storing the intercepted data as the PIN code.

### Claim 8 (depends on 7)

The method according to claim 7, further comprising:
when a PIN verification signature data acquisition instruction is received, verifying, by the signature module, the PIN verification signature data acquisition instruction, if the verifying is successful, generating the first PIN verification signature data and sending the first PIN verification signature data to the terminal; and if the verifying is failed, ending.

### Claim 9 (depends on 8)

The method according to claim 8, wherein the verifying of the PIN verification signature data acquisition instruction comprises:
step R1, calculating, by the signature module, a terminal public key in the PIN verification signature data acquisition instruction and the stored signature module private key to obtain a first calculation value, performing hash operation on the first calculation value to obtain a first hash value and taking the first hash value as the shared key;
step R2, performing, by the signature module, decryption operation on the first result data in the PIN verification signature data acquisition instruction by using the shared key to obtain second result data, obtaining a PIN code stored internally, and converting the PIN code stored internally to second byte stream data, performing hash operation on the second byte stream data and intercepting data in first 16 bytes of a hash result to obtain intercepted data; and
step R3, determining, by the signature module, whether the second result data is consistent with the intercepted data, if yes, the verifying is successful; otherwise, the verifying is failed, and regenerating a signature module key pair and replacing the stored signature module key pair.

### Claim 10 (depends on 8)

The method according to claim 8, wherein the generating of the first PIN verification signature data and sending the first PIN verification signature data to the terminal comprises: encrypting the first PIN verification signature data by using the shared key to obtain a ciphertext data, and returning the ciphertext data to the terminal.

### Claim 11

An apparatus for realizing secure signature, comprising a processor and a memory;
the processor is configured to call the operation instructions to execute steps of:
step F1, when a personal identification number (PIN) verification instruction sent by a terminal is received, generating a shared key according to a terminal public key in the PIN verification instruction and a signature module private key stored in the signature module, and verifying first result data in the PIN verification instruction by using the shared key, if the verifying is successful, executing step F2; if the verifying is failed, regenerating a signature module key pair and replacing a stored signature module key pair; wherein the signature module key pair comprises a signature module private key and a signature module public key;
step F2, generating a random number as first PIN verification signature data and storing the first PIN verification signature data, generating a calculation result by encrypting the first PIN verification signature data by using the shared key, and sending the calculation result to the terminal;
step H1, when a signature operation instruction sent by the terminal is received, determining whether second PIN verification signature data in the signature operation instruction is consistent with the first PIN verification signature data, if yes, executing step H2; otherwise, reporting an error;
step H2, signing to-be-signed intermediate data in the signature operation instruction by using a stored signature module private key to obtain a signature result; and
step H3, returning the signature result to the terminal, and determining whether a current state meets a preset condition, if yes, clearing the first PIN verification signature data; otherwise, ending, wherein the current state comprises signature times or a signature valid duration;
wherein the step F2 further comprises: setting the signature times as an initial value;
and the determining whether the current state meets the preset condition comprises: updating the signature times, and determining whether the signature times equal to a preset value, if yes, determining that the current states meets the preset condition; otherwise, determining that the current states does not meet the preset condition;
or, the step F2 further comprises: setting the signature valid duration;
and the determining whether the current state meets the preset condition comprises: determining whether a current time is in the signature valid duration; if yes, determining that the current states meets the preset condition; otherwise, determining that the current states does not meet the preset condition.

### Claim 12 (depends on 11)

The apparatus according to claim 11, wherein the processor is further configured to call the operation instructions to execute steps of:
performing decryption operation on the first result data in the PIN verification instruction by using the generated shared key to obtain a second result data, obtaining an PIN code stored internally and converting the PIN code stored internally to first byte stream data, performing hash operation on the first byte stream data and intercepting data in first 16 bytes of a hash result as intercepted data, and determining whether the intercepted data is consistent with the second result data, if yes, the verifying is successful; otherwise, the verifying is failed.

### Claim 13 (depends on 11)

The apparatus according to claim 11, wherein the processor is further configured to call the operation instructions to execute steps of: calculating the terminal public key in the PIN verification instruction and the stored signature module private key to obtain a first calculation value, and performing hash operation on the first calculation value to obtain a first hash value and taking the first hash value as the shared key.

### Claim 14 (depends on 11)

The apparatus according to claim 11, wherein the step H1 and the step H2 can be replaced by:
step P1, when a secure environment setting operation instruction sent by the terminal is received, determining whether third PIN verification signature data in the secure environment setting operation instruction is consistent with the first PIN verification signature data, if yes, executing step P2; otherwise, ending;
step P2, determining whether a signature setting algorithm is legitimate according to an algorithm identification (ID) and a key container ID in the secure environment operation setting instruction, if yes, executing step P3; otherwise, ending;
step P3, opening a corresponding key container according to the key container ID, and setting a corresponding algorithm according to the algorithm ID, and returning a secure environment setting succeed response to the terminal;
step T1, when a hash operation instruction sent by the terminal is received, determining whether fourth PIN verification signature data in the hash operation instruction is consistent with the first PIN verification signature data, if yes, executing step T2; otherwise, ending;
step T2, parsing the hash operation instruction to obtain data to be signed and storing the data to be signed;
step T3, performing hash operation on the data to be signed according to a set algorithm to obtain a hash value and storing the hash value, and returning a hash operation successful response to the terminal;
step Q1, when the signature operation instruction sent by the terminal is received, determining whether second PIN verification signature data in the signature operation instruction is consistent with the first PIN verification signature data, if yes, executing step Q2; otherwise, ending;
step Q2, intercepting key information from the stored data to be signed and determining whether the intercepting is successful, if yes, executing step Q3; otherwise, ending;
step Q3, displaying the key information and determining whether user confirmation information is received, if yes, signing the stored hash value by using a signature private key in a container corresponding to a container ID in the signature operation instruction to obtain a signature result and storing the signature result; otherwise, ending;
step Q4, determining whether the current state meets the preset condition, if yes, clearing the first PIN verification signature data, and returning signature success information to the terminal; otherwise, returning signature failure information to the terminal; and
step L1, when a signature result acquisition instruction sent by the terminal is received, returning the signature result to the terminal.

### Claim 15 (depends on 11)

The apparatus according to claim 11, wherein the processor is further configured to call the operation instructions to execute steps of:
when a PIN code setting instruction is received, determining whether a PIN code is set, if yes, reporting an error; otherwise, verifying the PIN code setting instruction, if the verifying is successful, generating a PIN code according to a first ciphertext in the PIN code setting instruction and storing the PIN code; if the verifying is failed, ending a process of verifying the PIN code setting instruction.

### Claim 16 (depends on 15)

The apparatus according to claim 15, wherein the processor is further configured to call the operation instructions to execute steps of:
step M1, calculating the stored signature module private key and a terminal public key in the PIN code setting instruction to obtain a first calculation value, performing hash operation on the first calculation value, and taking a hash result as the shared key;
step M2, performing hash-based message authentication code (HMAC) operation on the first ciphertext in the PIN code setting instruction by using the shared key to obtain a second operation result, and intercepting data in first 16 bytes of the second operation result to obtain the intercepted data; and
step M3, determining whether the intercepted data is consistent with first result data in the PIN code setting instruction, if yes, the verifying is successful; otherwise, the verifying is failed.

### Claim 17 (depends on 16)

The apparatus according to claim 16, wherein the processor is further configured to call the operation instructions to execute steps of:
step N1, decrypting the first ciphertext in the PIN code setting instruction by using the shared key to obtain a first decrypted value, removing padding data in the first decrypted value to obtain a password intermediate value;
step N2, determining whether the password intermediate value is less than a first preset value, if yes, reporting an error; otherwise, executing step N3; and
step N3, performing hash operation on the password intermediate value to obtain a hash result, and intercepting data in first 16 bytes of the hash result and storing the intercepted data as the PIN code.

### Claim 18 (depends on 17)

The apparatus according to claim 17, the processor is further configured to call the operation instructions to execute steps of:
when a PIN verification signature data acquisition instruction is received, verifying the PIN verification signature data acquisition instruction, if the verifying is successful, generating the first PIN verification signature data and sending the first PIN verification signature data to the terminal; and if the verifying is failed, ending.

### Claim 19 (depends on 18)

The apparatus according to claim 18, wherein the processor is further configured to call the operation instructions to execute steps of:
step R1, calculating a terminal public key in the PIN verification signature data acquisition instruction and the stored signature module private key to obtain a first calculation value, performing hash operation on the first calculation value to obtain a first hash value and taking the first hash value as the shared key;
step R2, performing decryption operation on first result data in the PIN verification signature data acquisition instruction by using the shared key to obtain second result data, obtaining a PIN code stored internally, and converting the PIN code stored internally to second byte stream data, performing hash operation on the second byte stream data and intercepting data in first 16 bytes of a hash result to obtain intercepted data; and
step R3, determining whether the second result data is consistent with the intercepted data, if yes, the verifying is successful; otherwise, the verifying is failed, and regenerating a signature module key pair and replacing the stored signature module key pair.

### Claim 20 (depends on 18)

The apparatus according to claim 18, wherein the processor is further configured to call the operation instructions to execute steps of: encrypting the first PIN verification signature data by using the shared key to obtain a ciphertext data, and returning the ciphertext data to the terminal.
