Encryption and Decryption
- The CA delivers the CMD_GENERATE_RANDOM command to the TA. The TA then calls the TEE_GenerateRandom function to generate a random number for generating a key.
Figure 1 Code execution process of generating a random number
- The CA delivers the CMD_GENERATE_KEYPAIR command. Based on the random number, the TA calls the TEE_GenerateKey function to generate a public-private key pair.
Figure 2 Code execution process of generating keys
- The CA delivers the CMD_SAVE_KEYPAIR command. The TA calls the CmdRSASaveKeypair function to store the generated key data to the specified path.
Figure 3 Code execution process of storing the key data
- The CA delivers the CMD_READ_KEYPAIR command. The TA calls the CmdRSAReadKeypair function to read the stored key file so as to obtain the public key data.
Figure 4 Code execution process of reading the key file
- The CA delivers the CMD_ENC_OAEP_MGF1_SHA512 command. The TA uses the public key data to encrypt the to-be-transmitted data in TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 mode.
Figure 5 Code execution process of AES encryption
- The CA delivers the CMD_DEC_OAEP_MGF1_SHA512 command. The TA uses the private key data to decrypt the encrypted data and compares the original data with the decrypted data.
Figure 6 Code execution process of AES decryption
Parent topic: Features