libnx  v4.6.0
spl.h
Go to the documentation of this file.
1 /**
2  * @file spl.h
3  * @brief Security Processor Liaison (spl*) service IPC wrapper.
4  * @author SciresM
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../kernel/event.h"
10 
11 #define SPL_RSA_BUFFER_SIZE (0x100)
12 
13 typedef enum {
14  SplConfigItem_DisableProgramVerification = 1,
15  SplConfigItem_DramId = 2,
16  SplConfigItem_SecurityEngineIrqNumber = 3,
17  SplConfigItem_Version = 4,
18  SplConfigItem_HardwareType = 5,
19  SplConfigItem_IsRetail = 6,
20  SplConfigItem_IsRecoveryBoot = 7,
21  SplConfigItem_DeviceId = 8,
22  SplConfigItem_BootReason = 9,
23  SplConfigItem_MemoryArrange = 10,
24  SplConfigItem_IsDebugMode = 11,
25  SplConfigItem_KernelMemoryConfiguration = 12,
26  SplConfigItem_IsChargerHiZModeEnabled = 13,
27  SplConfigItem_IsKiosk = 14,
28  SplConfigItem_NewHardwareType = 15,
29  SplConfigItem_NewKeyGeneration = 16,
30  SplConfigItem_Package2Hash = 17,
31 } SplConfigItem;
32 
33 typedef enum {
34  RsaKeyVersion_Deprecated = 0,
35  RsaKeyVersion_Extended = 1,
36 } RsaKeyVersion;
37 
38 /// Initialize 'spl:'.
40 
41 /// Exit 'spl:'.
42 void splExit(void);
43 
44 /// Gets the Service object for the IGeneralInterface usable with spl*().
46 
47 /// Initialize spl:mig. On pre-4.0.0 this just calls \ref splInitialize.
49 
50 /// Exit spl:mig. On pre-4.0.0 this just calls \ref splExit.
51 void splCryptoExit(void);
52 
53 /// Gets the Service object for the IGeneralInterface usable with splCrypto*().
55 
56 /// Initialize spl:ssl. On pre-4.0.0 this just calls \ref splInitialize.
58 
59 /// Exit spl:ssl. On pre-4.0.0 this just calls \ref splExit.
60 void splSslExit(void);
61 
62 /// Gets the Service object for the IGeneralInterface usable with splSsl*().
64 
65 /// Initialize spl:es. On pre-4.0.0 this just calls \ref splInitialize.
67 
68 /// Exit spl:es. On pre-4.0.0 this just calls \ref splExit.
69 void splEsExit(void);
70 
71 /// Gets the Service object for the IGeneralInterface usable with splEs*().
73 
74 /// Initialize spl:fs. On pre-4.0.0 this just calls \ref splInitialize.
76 
77 /// Exit spl:fs. On pre-4.0.0 this just calls \ref splExit.
78 void splFsExit(void);
79 
80 /// Gets the Service object for the IGeneralInterface usable with splFs*().
82 
83 /// Initialize spl:manu. On pre-4.0.0 this just calls \ref splInitialize.
85 
86 /// Exit spl:manu. On pre-4.0.0 this just calls \ref splExit.
87 void splManuExit(void);
88 
89 /// Gets the Service object for the IGeneralInterface usable with splManu*().
91 
92 Result splGetConfig(SplConfigItem config_item, u64 *out_config);
93 Result splUserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst);
94 Result splSetConfig(SplConfigItem config_item, u64 value);
95 Result splGetRandomBytes(void *out, size_t out_size);
96 Result splIsDevelopment(bool *out_is_development);
97 Result splSetBootReason(u32 value);
98 Result splGetBootReason(u32 *out_value);
99 
100 Result splCryptoGenerateAesKek(const void *wrapped_kek, u32 key_generation, u32 option, void *out_sealed_kek);
101 Result splCryptoLoadAesKey(const void *sealed_kek, const void *wrapped_key, u32 keyslot);
102 Result splCryptoGenerateAesKey(const void *sealed_kek, const void *wrapped_key, void *out_sealed_key);
103 Result splCryptoDecryptAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key);
104 Result splCryptoCryptAesCtr(const void *input, void *output, size_t size, u32 keyslot, const void *ctr);
105 Result splCryptoComputeCmac(const void *input, size_t size, u32 keyslot, void *out_cmac);
106 Result splCryptoLockAesEngine(u32 *out_keyslot);
107 Result splCryptoUnlockAesEngine(u32 keyslot);
108 Result splCryptoGetSecurityEngineEvent(Event *out_event);
109 
110 Result splRsaDecryptPrivateKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version, void *dst, size_t dst_size);
111 
112 Result splSslLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size);
113 Result splSslSecureExpMod(const void *input, const void *modulus, void *dst);
114 
115 Result splEsLoadRsaOaepKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version);
116 Result splEsUnwrapRsaOaepWrappedTitlekey(const void *rsa_wrapped_titlekey, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_titlekey);
117 Result splEsUnwrapAesWrappedTitlekey(const void *aes_wrapped_titlekey, u32 key_generation, void *out_sealed_titlekey);
118 Result splEsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size);
119 Result splEsSecureExpMod(const void *input, const void *modulus, void *dst);
120 Result splEsUnwrapElicenseKey(const void *rsa_wrapped_elicense_key, const void *modulus, const void *label_hash, size_t label_hash_size, u32 key_generation, void *out_sealed_elicense_key);
121 Result splEsLoadElicenseKey(const void *sealed_elicense_key, u32 keyslot);
122 
123 Result splFsLoadSecureExpModKey(const void *sealed_kek, const void *wrapped_key, const void *wrapped_rsa_key, size_t wrapped_rsa_key_size, RsaKeyVersion version);
124 Result splFsSecureExpMod(const void *input, const void *modulus, void *dst);
125 Result splFsGenerateSpecificAesKey(const void *wrapped_key, u32 key_generation, u32 option, void *out_sealed_key);
126 Result splFsLoadTitlekey(const void *sealed_titlekey, u32 keyslot);
127 Result splFsGetPackage2Hash(void *out_hash);
128 
129 Result splManuEncryptRsaKeyForImport(const void *sealed_kek_pre, const void *wrapped_key_pre, const void *sealed_kek_post, const void *wrapped_kek_post, u32 option, const void *wrapped_rsa_key, void *out_wrapped_rsa_key, size_t rsa_key_size);
Result splCryptoInitialize(void)
Initialize spl:mig. On pre-4.0.0 this just calls splInitialize.
Service * splSslGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with splSsl*().
Result splInitialize(void)
Initialize 'spl:'.
void splCryptoExit(void)
Exit spl:mig. On pre-4.0.0 this just calls splExit.
Service * splEsGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with splEs*().
Result splManuInitialize(void)
Initialize spl:manu. On pre-4.0.0 this just calls splInitialize.
Result splSslInitialize(void)
Initialize spl:ssl. On pre-4.0.0 this just calls splInitialize.
Service * splManuGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with splManu*().
void splExit(void)
Exit 'spl:'.
void splSslExit(void)
Exit spl:ssl. On pre-4.0.0 this just calls splExit.
Result splEsInitialize(void)
Initialize spl:es. On pre-4.0.0 this just calls splInitialize.
void splManuExit(void)
Exit spl:manu. On pre-4.0.0 this just calls splExit.
Service * splGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with spl*().
void splFsExit(void)
Exit spl:fs. On pre-4.0.0 this just calls splExit.
Result splFsInitialize(void)
Initialize spl:fs. On pre-4.0.0 this just calls splInitialize.
Service * splFsGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with splFs*().
Service * splCryptoGetServiceSession(void)
Gets the Service object for the IGeneralInterface usable with splCrypto*().
void splEsExit(void)
Exit spl:es. On pre-4.0.0 this just calls splExit.
Kernel-mode event structure.
Definition: event.h:13
Service object structure.
Definition: service.h:14
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
u32 Result
Function error code result type.
Definition: types.h:44
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21