Rate This Document
Findability
Accuracy
Completeness
Readability

Encryption and Decryption

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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