libctru
v2.4.1
|
PS service. More...
Go to the source code of this file.
Data Structures | |
struct | psRSAContext |
RSA context. More... | |
Enumerations | |
enum | PS_AESAlgorithm { PS_ALGORITHM_CBC_ENC , PS_ALGORITHM_CBC_DEC , PS_ALGORITHM_CTR_ENC , PS_ALGORITHM_CTR_DEC , PS_ALGORITHM_CCM_ENC , PS_ALGORITHM_CCM_DEC } |
PS AES algorithms. More... | |
enum | PS_AESKeyType { PS_KEYSLOT_0D , PS_KEYSLOT_2D , PS_KEYSLOT_31 , PS_KEYSLOT_38 , PS_KEYSLOT_32 , PS_KEYSLOT_39_DLP , PS_KEYSLOT_2E , PS_KEYSLOT_INVALID , PS_KEYSLOT_36 , PS_KEYSLOT_39_NFC } |
PS key slots. More... | |
Functions | |
Result | psInit (void) |
Initializes PS. | |
Result | psInitHandle (Handle handle) |
Initializes PS with the specified session handle. More... | |
void | psExit (void) |
Exits PS. | |
Handle | psGetSessionHandle (void) |
Returns the PS session handle. | |
Result | PS_SignRsaSha256 (u8 *hash, psRSAContext *ctx, u8 *signature) |
Signs a RSA signature. More... | |
Result | PS_VerifyRsaSha256 (u8 *hash, psRSAContext *ctx, u8 *signature) |
Verifies a RSA signature. More... | |
Result | PS_EncryptDecryptAes (u32 size, u8 *in, u8 *out, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8 *iv) |
Encrypts/Decrypts AES data. More... | |
Result | PS_EncryptSignDecryptVerifyAesCcm (u8 *in, u32 in_size, u8 *out, u32 out_size, u32 data_len, u32 mac_data_len, u32 mac_len, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8 *nonce) |
Encrypts/Decrypts signed AES CCM data. More... | |
Result | PS_GetLocalFriendCodeSeed (u64 *seed) |
Gets the 64-bit console friend code seed. More... | |
Result | PS_GetDeviceId (u32 *device_id) |
Gets the 32-bit device ID. More... | |
Result | PS_GenerateRandomBytes (void *out, size_t len) |
Generates cryptographically secure random bytes. More... | |
PS service.
enum PS_AESAlgorithm |
enum PS_AESKeyType |
PS key slots.
Result PS_EncryptDecryptAes | ( | u32 | size, |
u8 * | in, | ||
u8 * | out, | ||
PS_AESAlgorithm | aes_algo, | ||
PS_AESKeyType | key_type, | ||
u8 * | iv | ||
) |
Encrypts/Decrypts AES data.
Does not support AES CCM.
size | Size of the data. |
in | Input buffer. |
out | Output buffer. |
aes_algo | AES algorithm to use. |
key_type | Key type to use. |
iv | Pointer to the CTR/IV. The output CTR/IV is also written here. |
Result PS_EncryptSignDecryptVerifyAesCcm | ( | u8 * | in, |
u32 | in_size, | ||
u8 * | out, | ||
u32 | out_size, | ||
u32 | data_len, | ||
u32 | mac_data_len, | ||
u32 | mac_len, | ||
PS_AESAlgorithm | aes_algo, | ||
PS_AESKeyType | key_type, | ||
u8 * | nonce | ||
) |
Encrypts/Decrypts signed AES CCM data.
When decrypting, if the MAC is invalid, 0xC9010401 is returned. After encrypting the MAC is located at inputbufptr.
in | Input buffer. |
in_size | Size of the input buffer. Must include MAC size when decrypting. |
out | Output buffer. |
out_size | Size of the output buffer. Must include MAC size when encrypting. |
data_len | Length of the data to be encrypted/decrypted. |
mac_data_len | Length of the MAC data. |
mac_len | Length of the MAC. |
aes_algo | AES algorithm to use. |
key_type | Key type to use. |
nonce | Pointer to the nonce. |
Result PS_GenerateRandomBytes | ( | void * | out, |
size_t | len | ||
) |
Generates cryptographically secure random bytes.
out | Pointer to the buffer to write the bytes to. |
len | Number of bytes to write. |
Gets the 32-bit device ID.
device_id | Pointer to write the device ID to. |
Gets the 64-bit console friend code seed.
seed | Pointer to write the friend code seed to. |
Result PS_SignRsaSha256 | ( | u8 * | hash, |
psRSAContext * | ctx, | ||
u8 * | signature | ||
) |
Signs a RSA signature.
hash | SHA256 hash to sign. |
ctx | RSA context. |
signature | RSA signature. |
Result PS_VerifyRsaSha256 | ( | u8 * | hash, |
psRSAContext * | ctx, | ||
u8 * | signature | ||
) |
Verifies a RSA signature.
hash | SHA256 hash to compare with. |
ctx | RSA context. |
signature | RSA signature. |