Secure Monitor: Difference between revisions
No edit summary |
|||
Line 34: | Line 34: | ||
| 0xC3000002 || GetConfig (Same as ID 1, Sub-ID 4) || || | | 0xC3000002 || GetConfig (Same as ID 1, Sub-ID 4) || || | ||
|- | |- | ||
| 0xC3000003 || | | 0xC3000003 || GetResult || || | ||
|- | |- | ||
| 0xC3000404 || | | 0xC3000404 || GetResultData || || | ||
|- | |- | ||
| 0xC3000E05 || ExpMod || || | | 0xC3000E05 || ExpMod || || | ||
|- | |- | ||
| 0xC3000006 || | | 0xC3000006 || GenerateRandomBytes (Same as ID 1, Sub-ID 5) || || | ||
|- | |- | ||
| 0xC3000007 || [[#GenerateAesKek]] || || | | 0xC3000007 || [[#GenerateAesKek]] || || | ||
Line 46: | Line 46: | ||
| 0xC3000008 || [[#LoadAesKey]] || || | | 0xC3000008 || [[#LoadAesKey]] || || | ||
|- | |- | ||
| 0xC3000009 || [[# | | 0xC3000009 || [[#ComputeAes]] || || | ||
|- | |- | ||
| 0xC300000A || [[#GenerateSpecificAesKey]] || || | | 0xC300000A || [[#GenerateSpecificAesKey]] || || | ||
Line 52: | Line 52: | ||
| 0xC300040B || [[#ComputeCmac]] || || | | 0xC300040B || [[#ComputeCmac]] || || | ||
|- | |- | ||
| [1.0.0-4.1.0] 0xC300100C || [[# | | [1.0.0-4.1.0] 0xC300100C || [[#ImportEsKey]] || || | ||
|- | |- | ||
| [5.0.0+] 0xC300D60C || [[# | | [5.0.0+] 0xC300D60C || [[#ReEncryptRsaPrivateKey]] || || | ||
|- | |- | ||
| [1.0.0-4.1.0] 0xC300100D || [[#DecryptRsaPrivateKey]] || || | | [1.0.0-4.1.0] 0xC300100D || [[#DecryptRsaPrivateKey]] || || | ||
|- | |- | ||
| [5.0.0] 0xC300100D || [[# | | [5.0.0+] 0xC300100D || [[#DecryptOrImportRsaPrivateKey]] || || | ||
|- | |- | ||
| [1.0.0-4.1.0] 0xC300100E || [[# | | [1.0.0-4.1.0] 0xC300100E || [[#ImportLotusKey]] || || | ||
|- | |- | ||
| 0xC300060F || [[# | | 0xC300060F || [[#StorageExpMod]] || || | ||
|- | |- | ||
| 0xC3000610 || [[# | | 0xC3000610 || [[#UnwrapTitleKey]] || || | ||
|- | |- | ||
| 0xC3000011 || [[#LoadTitleKey]] || || | | 0xC3000011 || [[#LoadTitleKey]] || || | ||
|- | |- | ||
| 0xC3000012 || [2.0.0+] | | 0xC3000012 || [2.0.0+] [[#UnwrapCommonTitleKey]] || || | ||
|} | |} | ||
Line 80: | Line 80: | ||
** This means: Plaintext kek keys never leave TrustZone. | ** This means: Plaintext kek keys never leave TrustZone. | ||
** Further, this means: Actual AES/RSA keys never leave TrustZone. | ** Further, this means: Actual AES/RSA keys never leave TrustZone. | ||
=== GenerateAesKek === | === GenerateAesKek === | ||
Line 94: | Line 91: | ||
The session kek must have been created with [[#enum_CryptoUsecase|CryptoUsecase_Aes]]. | The session kek must have been created with [[#enum_CryptoUsecase|CryptoUsecase_Aes]]. | ||
=== | === ComputeAes === | ||
Encrypts/decrypts using Aes (CTR and CBC). | Encrypts/decrypts using Aes (CTR and CBC). | ||
Key must be set prior using one of the [[#LoadAesKey]] | Key must be set prior using one of the [[#LoadAesKey]] or [[#GenerateSpecificAesKey]] commands. | ||
=== GenerateSpecificAesKey === | === GenerateSpecificAesKey === | ||
Takes a wrapped AES key and decrypts it using static data. | |||
=== | === ComputeCmac === | ||
Calculates CMAC over input data. | |||
=== ImportEsKey === | |||
Takes a session kek created with [[#GenerateAesKek]], a wrapped AES key, and a wrapped RSA private key. | Takes a session kek created with [[#GenerateAesKek]], a wrapped AES key, and a wrapped RSA private key. | ||
The session kek must have been created with [[#enum_CryptoUsecase| | The session kek must have been created with [[#enum_CryptoUsecase|CryptoUsecase_TitleKey]]. | ||
[5.0.0] This function was removed and replaced with [[#ReEncryptRsaPrivateKey]]. | |||
=== | === ReEncryptRsaPrivateKey === | ||
Takes in two session keks created with [[#GenerateAesKek]], two wrapped AES keys, an enum member, and a wrapped RSA private key. | Takes in two session keks created with [[#GenerateAesKek]], two wrapped AES keys, an enum member, and a wrapped RSA private key. | ||
Decrypts and validates the wrapped RSA private key with the first kek/wrapped key, and re-encrypts it with the second if valid. | Decrypts and validates the wrapped RSA private key with the first kek/wrapped key, and re-encrypts it with the second if valid. | ||
The re-encrypted key is then passed to the user, for use with [[# | The re-encrypted key is then passed to the user, for use with [[#DecryptOrImportRsaPrivateKey]]. | ||
=== DecryptRsaPrivateKey === | === DecryptRsaPrivateKey === | ||
Line 123: | Line 123: | ||
[4.0.0+] The SMC handler when certain conditions pass and SMC_ID==0xC300100D now returns error 0x6 instead of calling the handler funcptr. | [4.0.0+] The SMC handler when certain conditions pass and SMC_ID==0xC300100D now returns error 0x6 instead of calling the handler funcptr. | ||
[5.0.0+] This function was replaced by [[#DecryptOrImportRsaPrivateKey]]. | |||
=== DecryptOrImportRsaPrivateKey === | |||
This function replaced [[#DecryptRsaPrivateKey]] in [[5.0.0]], adding an additional enum member argument. | This function replaced [[#DecryptRsaPrivateKey]] in [[5.0.0]], adding an additional enum member argument. | ||
This SMC extends DecryptRsaPrivateKey's original functionality to enable importing private keys into the security engine instead of decrypting them, when certain enum members are passed. | This SMC extends DecryptRsaPrivateKey's original functionality to enable importing private keys into the security engine instead of decrypting them, when certain enum members are passed. | ||
=== | === ImportLotusKey === | ||
Takes a session kek created with [[#GenerateAesKek]], and a wrapped RSA key. | Takes a session kek created with [[#GenerateAesKek]], and a wrapped RSA key. | ||
The session kek must have been created with [[#enum_CryptoUsecase|CryptoUsecase_RsaSecureExpMod]]. | The session kek must have been created with [[#enum_CryptoUsecase|CryptoUsecase_RsaSecureExpMod]]. | ||
[5.0.0] This function was removed and replaced with [[#ReEncryptRsaPrivateKey]]. | |||
=== SecureExpMod === | === SecureExpMod === | ||
Performs an | Performs an ExpMod operation using an exponent previously loaded with the [[#ImportLotusKey]] command. | ||
[5.0.0+] This now uses any exponent previously loaded with [[#DecryptOrImportRsaPrivateKey]]. | |||
=== | === UnwrapTitleKey === | ||
Takes an Rsa-Oaep-wrapped TitleKey, an RSA Public Key, and a label hash. | Takes an Rsa-Oaep-wrapped TitleKey, an RSA Public Key, and a label hash. | ||
Performs an | Performs an ExpMod operation using an exponent previously loaded with the [[#ImportEsKey]] command, and then validates/extracts a Titlekey from the resulting message. | ||
Returns a session-unique AES key especially for use in [[#LoadTitleKey]]. | Returns a session-unique AES key especially for use in [[#LoadTitleKey]]. | ||
[5.0.0+] This now uses any exponent previously loaded with [[#DecryptOrImportRsaPrivateKey]]. | |||
=== LoadTitleKey === | === LoadTitleKey === | ||
Takes a session-unique AES key from [[# | Takes a session-unique AES key from [[#UnwrapCommonTitleKey]] or [[#UnwrapTitleKey]]. | ||
=== UnwrapCommonTitleKey === | |||
Takes an AES-wrapped TitleKey and returns a sealed AES key. | |||
=== enum CryptoUsecase === | === enum CryptoUsecase === | ||
Line 159: | Line 167: | ||
| 2 || CryptoUsecase_RsaSecureExpMod | | 2 || CryptoUsecase_RsaSecureExpMod | ||
|- | |- | ||
| 3 || | | 3 || CryptoUsecase_TitleKey | ||
|} | |} | ||
Note: | |||
The [[#enum_CryptoUsecase|CryptoUsecase_TitleKey]] represents a RSA wrapped AES key. | |||
== ID 1 == | == ID 1 == |