Skip to content

Commit c1b76fb

Browse files
Rework signature/cert/tik interfaces.
* signature: add comments to SignatureType enum entries about the exact signing algorithms and padding schemes used. * signature: rename signatureGetSigType() -> signatureGetTypeFromSignedBlob(). * signature: rename signatureIsValidSigType() -> signatureIsValidType(). * signature: rename signatureGetSigSize() -> signatureGetSigSizeByType(). * signature: rename signatureGetBlockSize() -> signatureGetBlockSizeByType(). * signature: rename signatureGetSig() -> signatureGetSigFromSignedBlob(). * signature: rename signatureGetPayload() -> signatureGetPayloadFromSignedBlob(). * signature: add signatureGetBlockSizeFromSignedBlob(). * cert: add more comments to the code. * cert: update code to match signature interface changes. * cert: add CERT_RSA_PUB_EXP_SIZE macro. * cert: change public_exponent field in CertPublicKeyBlockRsa* structs from u32 to u8 array. * cert: add size field to CertificateChain struct. * cert: rename certGetCommonBlock() -> certGetCommonBlockFromSignedCertBlob. * cert: rename certGetPublicKeySize() -> certGetPublicKeySizeByType(). * cert: rename certGetPublicKeyBlockSize() -> certGetPublicKeyBlockSizeByType(). * cert: rename certIsValidCertificate() -> certIsValidSignedCertBlob(). * cert: rename certGetSignedCertificateSize() -> certGetSignedCertBlobSize(). * cert: rename certGetSignedCertificateHashAreaSize() -> certGetSignedCertBlobHashAreaSize(). * cert: remove certGetPublicKey(), certGetPublicExponent() and certCalculateRawCertificateChainSize(). * cert: add certGetPublicKeyTypeFromCommonBlock(), certGetPublicKeyTypeFromSignedCertBlob(), certGetPublicKeySizeFromSignedCertBlob(), certGetPublicKeyBlockSizeFromSignedCertBlob(), certGetPublicKeyFromSignedCertBlob(), certGetPublicExponentFromSignedCertBlob(), certIsValidCertificate() (w/diff func sig), certGetCommonBlockFromCertificate(), certGetPublicKeyTypeFromCertificate(), certGetPublicKeySizeFromCertificate(), certGetPublicKeyBlockSizeFromCertificate(), certGetPublicKeyFromCertificate(), certGetPublicExponentFromCertificate() and certGetHashAreaSizeFromCertificate() functions. * cert: avoid byteswapping the public key type value in multiple places -- it is now only being done in certGetPublicKeyTypeFromCommonBlock(). * cert: call certFreeCertificateChain() in _certRetrieveCertificateChainBySignatureIssuer() before attempting to retrieve the certificate chain. * cert: other minor changes and corrections. * tik: update code to match signature interface changes. * tik: add missing comments to TikPropertyMask enum entries. * tik: add key_generation, enc_titlekey_str and dec_titlekey_str fields to Ticket struct. * tik: update tikRetrieveTicketByRightsId() to also take in a key_generation argument, instead of getting it from the rights ID (which could fail if it's using a key generation lower than HOS 3.0.1) or the key_generation field from the common ticket block (which could fail if the ticket has been tampered by certain tools). * tik: rename tikGetCommonBlock() -> tikGetCommonBlockFromSignedTicketBlob(). * tik: change function signature for tikGetTicketSectionRecordsBlockSize(). * tik: rename tikIsValidTicket() -> tikIsValidSignedTicketBlob(). * tik: rename tikGetSignedTicketSize() -> tikGetSignedTicketBlobSize(). * tik: rename tikGetSignedTicketHashAreaSize() -> tikGetSignedTicketBlobHashAreaSize(). * tik: rename tikGetEncryptedTitleKeyFromTicket() -> tikGetEncryptedTitleKey(). * tik: add tikIsValidTicket() (w/diff func sig), tikGetCommonBlockFromTicket(), tikGetHashAreaSizeFromTicket(), tikFixTamperedCommonTicket(), tikVerifyRsa2048Sha256Signature() and tikDecryptVolatileTicket() functions. Ticket signature verification is only carried out for common tickets in tikFixTamperedCommonTicket(). * tik: change argument order in tikGetTicketEntryOffsetFromTicketList() and tikRetrieveTicketEntryFromTicketBin(). * tik: add TIK_COMMON_CERT_NAME and TIK_DEV_CERT_ISSUER macros. * tik: use a scoped lock when calling tikRetrieveTicketFromEsSaveDataByRightsId(). * tik: simplify certificate chain retrieval steps in tikConvertPersonalizedTicketToCommonTicket() by always using the XS00000020 certificate. * tik: wipe license_type and property_mask fields in tikConvertPersonalizedTicketToCommonTicket(). * tik: other minor changes and corrections. Other changes include: * keys: fix key generation checks in keysGetNcaKeyAreaKeyEncryptionKey() and keysGetTicketCommonKey(). * rsa: move core logic from rsa2048VerifySha256BasedPssSignature() into a new function: rsa2048VerifySha256BasedSignature(). * rsa: add rsa2048VerifySha256BasedPkcs1v15Signature() function.
1 parent ecaeddf commit c1b76fb

File tree

12 files changed

+629
-353
lines changed

12 files changed

+629
-353
lines changed

code_templates/nxdt_rw_poc.c

+5-15
Original file line numberDiff line numberDiff line change
@@ -2869,8 +2869,6 @@ static bool saveTicket(void *userdata)
28692869
NcaContext *nca_ctx = NULL;
28702870

28712871
Ticket tik = {0};
2872-
TikCommonBlock *tik_common_block = NULL;
2873-
char enc_titlekey_str[33] = {0};
28742872

28752873
u32 crc = 0;
28762874
char *filename = NULL;
@@ -2916,21 +2914,14 @@ static bool saveTicket(void *userdata)
29162914
goto end;
29172915
}
29182916

2919-
if (!tik.size)
2917+
if (!nca_ctx->titlekey_retrieved)
29202918
{
29212919
consolePrint("failed to retrieve ticket (unavailable?)\ntry launching nxdumptool while overriding the title you wish to dump a ticket from\n");
29222920
goto end;
29232921
}
29242922

2925-
/* Retrieve ticket common block. */
2926-
if (!(tik_common_block = tikGetCommonBlock(tik.data)))
2927-
{
2928-
consolePrint("failed to get tik common block\n");
2929-
goto end;
2930-
}
2931-
29322923
/* Remove console-specific data, if needed. */
2933-
if (remove_console_data && tik_common_block->titlekey_type == TikTitleKeyType_Personalized && !tikConvertPersonalizedTicketToCommonTicket(&tik, NULL, NULL))
2924+
if (remove_console_data && tikIsPersonalizedTicket(&tik) && !tikConvertPersonalizedTicketToCommonTicket(&tik, NULL, NULL))
29342925
{
29352926
consolePrint("failed to convert personalized ticket to common ticket\n");
29362927
goto end;
@@ -2945,10 +2936,9 @@ static bool saveTicket(void *userdata)
29452936

29462937
if (!saveFileData(filename, tik.data, tik.size)) goto end;
29472938

2948-
utilsGenerateHexStringFromData(enc_titlekey_str, MAX_ELEMENTS(enc_titlekey_str), tik.enc_titlekey, sizeof(tik.enc_titlekey), false);
2949-
29502939
consolePrint("rights id: %s\n", tik.rights_id_str);
2951-
consolePrint("titlekey: %s\n\n", enc_titlekey_str);
2940+
consolePrint("encrypted titlekey: %s\n", tik.enc_titlekey_str);
2941+
consolePrint("decrypted titlekey: %s\n\n", tik.dec_titlekey_str);
29522942

29532943
consolePrint("successfully saved ticket as \"%s\"\n", filename);
29542944
success = true;
@@ -5003,7 +4993,7 @@ static void nspThreadFunc(void *arg)
50034993
bool retrieve_tik_cert = (!remove_titlekey_crypto && tik.size > 0);
50044994
if (retrieve_tik_cert)
50054995
{
5006-
if (!(tik_common_block = tikGetCommonBlock(tik.data)))
4996+
if (!(tik_common_block = tikGetCommonBlockFromTicket(&tik)))
50074997
{
50084998
consolePrint("tik common block failed");
50094999
goto end;

include/core/cert.h

+112-46
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
extern "C" {
3131
#endif
3232

33-
#define SIGNED_CERT_MAX_SIZE sizeof(CertSigRsa4096PubKeyRsa4096)
3433
#define SIGNED_CERT_MIN_SIZE sizeof(CertSigHmac160PubKeyEcc480)
34+
#define SIGNED_CERT_MAX_SIZE sizeof(CertSigRsa4096PubKeyRsa4096)
35+
36+
#define CERT_RSA_PUB_EXP_SIZE 4
3537

3638
#define GENERATE_CERT_STRUCT(sigtype, pubkeytype, certsize) \
37-
\
3839
typedef struct { \
3940
SignatureBlock##sigtype sig_block; \
4041
CertCommonBlock cert_common_block; \
4142
CertPublicKeyBlock##pubkeytype pub_key_block; \
4243
} CertSig##sigtype##PubKey##pubkeytype; \
43-
\
4444
NXDT_ASSERT(CertSig##sigtype##PubKey##pubkeytype, certsize);
4545

4646
typedef enum {
@@ -63,7 +63,7 @@ NXDT_ASSERT(CertCommonBlock, 0x88);
6363
/// RSA-4096 public key block. Placed after the certificate common block.
6464
typedef struct {
6565
u8 public_key[0x200];
66-
u32 public_exponent;
66+
u8 public_exponent[CERT_RSA_PUB_EXP_SIZE];
6767
u8 padding[0x34];
6868
} CertPublicKeyBlockRsa4096;
6969

@@ -72,7 +72,7 @@ NXDT_ASSERT(CertPublicKeyBlockRsa4096, 0x238);
7272
/// RSA-2048 public key block. Placed after the certificate common block.
7373
typedef struct {
7474
u8 public_key[0x100];
75-
u32 public_exponent;
75+
u8 public_exponent[CERT_RSA_PUB_EXP_SIZE];
7676
u8 padding[0x34];
7777
} CertPublicKeyBlockRsa2048;
7878

@@ -133,10 +133,11 @@ typedef struct {
133133
u8 data[SIGNED_CERT_MAX_SIZE]; ///< Raw certificate data.
134134
} Certificate;
135135

136-
/// Used to store two or more certificates.
136+
/// Used to store multiple certificates.
137137
typedef struct {
138-
u32 count;
139-
Certificate *certs;
138+
u32 count; ///< Number of certificates in this chain.
139+
u64 size; ///< Raw certificate chain size (when concatenated).
140+
Certificate *certs; ///< Certificate array.
140141
} CertificateChain;
141142

142143
/// Retrieves a certificate by its name (e.g. "CA00000003", "XS00000020", etc.).
@@ -145,77 +146,142 @@ bool certRetrieveCertificateByName(Certificate *dst, const char *name);
145146
/// Retrieves a certificate chain by a full signature issuer string (e.g. "Root-CA00000003-XS00000020").
146147
bool certRetrieveCertificateChainBySignatureIssuer(CertificateChain *dst, const char *issuer);
147148

148-
/// Returns a pointer to a dynamically allocated buffer that contains the raw contents from the certificate chain matching the input signature issuer. It must be freed by the user.
149-
/// NULL is returned if an error occurs.
149+
/// Returns a pointer to a dynamically allocated buffer that holds the concatenated raw contents from the certificate chain matching the input signature issuer.
150+
/// The returned buffer must be freed by the user.
151+
/// Returns NULL if an error occurs.
150152
u8 *certGenerateRawCertificateChainBySignatureIssuer(const char *issuer, u64 *out_size);
151153

152-
/// Returns a pointer to a dynamically allocated buffer that contains the raw contents from the certificate chain matching the input Rights ID (stored in the inserted gamecard).
153-
/// It must be freed by the user.
154-
/// NULL is returned if an error occurs.
154+
/// Returns a pointer to a dynamically allocated buffer that holds the concatenated raw contents from the certificate chain matching the input rights ID in the inserted gamecard.
155+
/// The returned buffer must be freed by the user.
156+
/// Returns NULL if an error occurs.
155157
u8 *certRetrieveRawCertificateChainFromGameCardByRightsId(const FsRightsId *id, u64 *out_size);
156158

157-
/// Helper inline functions.
159+
/// General purpose helper inline functions.
158160

159-
NX_INLINE void certFreeCertificateChain(CertificateChain *chain)
161+
NX_INLINE bool certIsValidPublicKeyType(u32 type)
160162
{
161-
if (!chain) return;
162-
if (chain->certs) free(chain->certs);
163-
memset(chain, 0, sizeof(CertificateChain));
163+
return (type < CertPubKeyType_Count);
164164
}
165165

166-
NX_INLINE CertCommonBlock *certGetCommonBlock(void *buf)
166+
NX_INLINE u64 certGetPublicKeySizeByType(u32 type)
167167
{
168-
return (CertCommonBlock*)signatureGetPayload(buf, true);
168+
return (u64)(type == CertPubKeyType_Rsa4096 ? MEMBER_SIZE(CertPublicKeyBlockRsa4096, public_key) : \
169+
(type == CertPubKeyType_Rsa2048 ? MEMBER_SIZE(CertPublicKeyBlockRsa2048, public_key) : \
170+
(type == CertPubKeyType_Ecc480 ? MEMBER_SIZE(CertPublicKeyBlockEcc480, public_key) : 0)));
169171
}
170172

171-
NX_INLINE bool certIsValidPublicKeyType(u32 type)
173+
NX_INLINE u64 certGetPublicKeyBlockSizeByType(u32 type)
174+
{
175+
return (u64)(type == CertPubKeyType_Rsa4096 ? sizeof(CertPublicKeyBlockRsa4096) : \
176+
(type == CertPubKeyType_Rsa2048 ? sizeof(CertPublicKeyBlockRsa2048) : \
177+
(type == CertPubKeyType_Ecc480 ? sizeof(CertPublicKeyBlockEcc480) : 0)));
178+
}
179+
180+
NX_INLINE u32 certGetPublicKeyTypeFromCommonBlock(CertCommonBlock *cert_common_block)
172181
{
173-
return (type == CertPubKeyType_Rsa4096 || type == CertPubKeyType_Rsa2048 || type == CertPubKeyType_Ecc480);
182+
return (cert_common_block ? __builtin_bswap32(cert_common_block->pub_key_type) : CertPubKeyType_Count);
174183
}
175184

176-
NX_INLINE u8 *certGetPublicKey(CertCommonBlock *cert_common_block)
185+
/// Helper inline functions for signed certificate blobs.
186+
187+
NX_INLINE CertCommonBlock *certGetCommonBlockFromSignedCertBlob(void *buf)
177188
{
178-
return ((cert_common_block != NULL && certIsValidPublicKeyType(__builtin_bswap32(cert_common_block->pub_key_type))) ? ((u8*)cert_common_block + sizeof(CertCommonBlock)) : NULL);
189+
return (CertCommonBlock*)signatureGetPayloadFromSignedBlob(buf, true);
179190
}
180191

181-
NX_INLINE u64 certGetPublicKeySize(u32 type)
192+
NX_INLINE bool certIsValidSignedCertBlob(void *buf)
182193
{
183-
return (u64)(type == CertPubKeyType_Rsa4096 ? MEMBER_SIZE(CertPublicKeyBlockRsa4096, public_key) : \
184-
(type == CertPubKeyType_Rsa2048 ? MEMBER_SIZE(CertPublicKeyBlockRsa2048, public_key) : \
185-
(type == CertPubKeyType_Ecc480 ? MEMBER_SIZE(CertPublicKeyBlockEcc480, public_key) : 0)));
194+
CertCommonBlock *cert_common_block = certGetCommonBlockFromSignedCertBlob(buf);
195+
return (cert_common_block && certIsValidPublicKeyType(certGetPublicKeyTypeFromCommonBlock(cert_common_block)));
186196
}
187197

188-
NX_INLINE u64 certGetPublicKeyBlockSize(u32 type)
198+
NX_INLINE u32 certGetPublicKeyTypeFromSignedCertBlob(void *buf)
189199
{
190-
return (u64)(type == CertPubKeyType_Rsa4096 ? sizeof(CertPublicKeyBlockRsa4096) : \
191-
(type == CertPubKeyType_Rsa2048 ? sizeof(CertPublicKeyBlockRsa2048) : \
192-
(type == CertPubKeyType_Ecc480 ? sizeof(CertPublicKeyBlockEcc480) : 0)));
200+
return (certIsValidSignedCertBlob(buf) ? certGetPublicKeyTypeFromCommonBlock(certGetCommonBlockFromSignedCertBlob(buf)) : CertPubKeyType_Count);
201+
}
202+
203+
NX_INLINE u64 certGetPublicKeySizeFromSignedCertBlob(void *buf)
204+
{
205+
return certGetPublicKeySizeByType(certGetPublicKeyTypeFromSignedCertBlob(buf));
206+
}
207+
208+
NX_INLINE u64 certGetPublicKeyBlockSizeFromSignedCertBlob(void *buf)
209+
{
210+
return certGetPublicKeyBlockSizeByType(certGetPublicKeyTypeFromSignedCertBlob(buf));
211+
}
212+
213+
NX_INLINE u8 *certGetPublicKeyFromSignedCertBlob(void *buf)
214+
{
215+
return (certIsValidSignedCertBlob(buf) ? ((u8*)certGetCommonBlockFromSignedCertBlob(buf) + sizeof(CertCommonBlock)) : NULL);
216+
}
217+
218+
NX_INLINE u8 *certGetPublicExponentFromSignedCertBlob(void *buf)
219+
{
220+
u32 pub_key_type = certGetPublicKeyTypeFromSignedCertBlob(buf);
221+
u8 *public_key = certGetPublicKeyFromSignedCertBlob(buf);
222+
return (pub_key_type < CertPubKeyType_Ecc480 ? (public_key + certGetPublicKeySizeByType(pub_key_type)) : NULL); // Only allow RSA public key types.
223+
}
224+
225+
NX_INLINE u64 certGetSignedCertBlobSize(void *buf)
226+
{
227+
return (certIsValidSignedCertBlob(buf) ? (signatureGetBlockSizeFromSignedBlob(buf, true) + sizeof(CertCommonBlock) + certGetPublicKeyBlockSizeFromSignedCertBlob(buf)) : 0);
228+
}
229+
230+
NX_INLINE u64 certGetSignedCertBlobHashAreaSize(void *buf)
231+
{
232+
return (certIsValidSignedCertBlob(buf) ? (sizeof(CertCommonBlock) + certGetPublicKeyBlockSizeFromSignedCertBlob(buf)) : 0);
233+
}
234+
235+
/// Helper inline functions for Certificate elements.
236+
237+
NX_INLINE bool certIsValidCertificate(Certificate *cert)
238+
{
239+
return (cert && cert->type > CertType_None && cert->type < CertType_Count && cert->size >= SIGNED_CERT_MIN_SIZE && cert->size <= SIGNED_CERT_MAX_SIZE && \
240+
certIsValidSignedCertBlob(cert->data));
241+
}
242+
243+
NX_INLINE CertCommonBlock *certGetCommonBlockFromCertificate(Certificate *cert)
244+
{
245+
return (certIsValidCertificate(cert) ? certGetCommonBlockFromSignedCertBlob(cert->data) : NULL);
246+
}
247+
248+
NX_INLINE u32 certGetPublicKeyTypeFromCertificate(Certificate *cert)
249+
{
250+
return (certIsValidCertificate(cert) ? certGetPublicKeyTypeFromSignedCertBlob(cert->data) : CertPubKeyType_Count);
251+
}
252+
253+
NX_INLINE u64 certGetPublicKeySizeFromCertificate(Certificate *cert)
254+
{
255+
return (certIsValidCertificate(cert) ? certGetPublicKeySizeFromSignedCertBlob(cert->data) : 0);
193256
}
194257

195-
NX_INLINE u32 certGetPublicExponent(CertCommonBlock *cert_common_block)
258+
NX_INLINE u64 certGetPublicKeyBlockSizeFromCertificate(Certificate *cert)
196259
{
197-
u8 *public_key = certGetPublicKey(cert_common_block);
198-
return ((cert_common_block != NULL && public_key != NULL) ? __builtin_bswap32(*((u32*)(public_key + certGetPublicKeySize(__builtin_bswap32(cert_common_block->pub_key_type))))) : 0);
260+
return (certIsValidCertificate(cert) ? certGetPublicKeyBlockSizeFromSignedCertBlob(cert->data) : 0);
199261
}
200262

201-
NX_INLINE bool certIsValidCertificate(void *buf)
263+
NX_INLINE u8 *certGetPublicKeyFromCertificate(Certificate *cert)
202264
{
203-
CertCommonBlock *cert_common_block = certGetCommonBlock(buf);
204-
return (cert_common_block != NULL && certIsValidPublicKeyType(__builtin_bswap32(cert_common_block->pub_key_type)));
265+
return (certIsValidCertificate(cert) ? certGetPublicKeyFromSignedCertBlob(cert->data) : NULL);
205266
}
206267

207-
NX_INLINE u64 certGetSignedCertificateSize(void *buf)
268+
NX_INLINE u8 *certGetPublicExponentFromCertificate(Certificate *cert)
208269
{
209-
if (!certIsValidCertificate(buf)) return 0;
210-
CertCommonBlock *cert_common_block = certGetCommonBlock(buf);
211-
return (signatureGetBlockSize(signatureGetSigType(buf, true)) + (u64)sizeof(CertCommonBlock) + certGetPublicKeyBlockSize(__builtin_bswap32(cert_common_block->pub_key_type)));
270+
return (certIsValidCertificate(cert) ? certGetPublicExponentFromSignedCertBlob(cert->data) : NULL);
212271
}
213272

214-
NX_INLINE u64 certGetSignedCertificateHashAreaSize(void *buf)
273+
NX_INLINE u64 certGetHashAreaSizeFromCertificate(Certificate *cert)
215274
{
216-
if (!certIsValidCertificate(buf)) return 0;
217-
CertCommonBlock *cert_common_block = certGetCommonBlock(buf);
218-
return ((u64)sizeof(CertCommonBlock) + certGetPublicKeyBlockSize(__builtin_bswap32(cert_common_block->pub_key_type)));
275+
return (certIsValidCertificate(cert) ? certGetSignedCertBlobHashAreaSize(cert->data) : 0);
276+
}
277+
278+
/// Helper inline functions for CertificateChain elements.
279+
280+
NX_INLINE void certFreeCertificateChain(CertificateChain *chain)
281+
{
282+
if (!chain) return;
283+
if (chain->certs) free(chain->certs);
284+
memset(chain, 0, sizeof(CertificateChain));
219285
}
220286

221287
#ifdef __cplusplus

include/core/nca.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ typedef enum {
9595
NcaKeyGeneration_Since1400NUP = 14, ///< 14.0.0 - 14.1.2.
9696
NcaKeyGeneration_Since1500NUP = 15, ///< 15.0.0 - 15.0.1.
9797
NcaKeyGeneration_Since1600NUP = 16, ///< 16.0.0 - 16.1.0.
98-
NcaKeyGeneration_Since1700NUP = 17, ///< 17.0.0.
98+
NcaKeyGeneration_Since1700NUP = 17, ///< 17.0.0+.
9999
NcaKeyGeneration_Current = NcaKeyGeneration_Since1700NUP,
100100
NcaKeyGeneration_Max = 32
101101
} NcaKeyGeneration;
@@ -111,7 +111,7 @@ typedef enum {
111111
/// TODO: update on signature keygen changes.
112112
typedef enum {
113113
NcaSignatureKeyGeneration_Since100NUP = 0, ///< 1.0.0 - 8.1.1.
114-
NcaSignatureKeyGeneration_Since900NUP = 1, ///< 9.0.0 - 17.0.0.
114+
NcaSignatureKeyGeneration_Since900NUP = 1, ///< 9.0.0+.
115115
NcaSignatureKeyGeneration_Current = NcaSignatureKeyGeneration_Since900NUP,
116116
NcaSignatureKeyGeneration_Max = (NcaSignatureKeyGeneration_Current + 1)
117117
} NcaSignatureKeyGeneration;

include/core/npdm.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
/// TODO: update on signature keygen changes.
4444
typedef enum {
4545
NpdmSignatureKeyGeneration_Since100NUP = 0, ///< 1.0.0 - 8.1.1.
46-
NpdmSignatureKeyGeneration_Since900NUP = 1, ///< 9.0.0 - 17.0.0.
46+
NpdmSignatureKeyGeneration_Since900NUP = 1, ///< 9.0.0+.
4747
NpdmSignatureKeyGeneration_Current = NpdmSignatureKeyGeneration_Since900NUP,
4848
NpdmSignatureKeyGeneration_Max = (NpdmSignatureKeyGeneration_Current + 1)
4949
} NpdmSignatureKeyGeneration;

include/core/rsa.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,17 @@ extern "C" {
3636
#define RSA2048_PUBKEY_SIZE RSA2048_BYTES
3737

3838
/// Verifies a RSA-2048-PSS with SHA-256 signature.
39+
/// Suitable for NCA and NPDM signatures.
3940
/// The provided signature and modulus must have sizes of at least RSA2048_SIG_SIZE and RSA2048_PUBKEY_SIZE, respectively.
4041
bool rsa2048VerifySha256BasedPssSignature(const void *data, size_t data_size, const void *signature, const void *modulus, const void *public_exponent, size_t public_exponent_size);
4142

43+
/// Verifies a RSA-2048-PKCS#1 v1.5 with SHA-256 signature.
44+
/// Suitable for ticket and certificate chain signatures.
45+
/// The provided signature and modulus must have sizes of at least RSA2048_SIG_SIZE and RSA2048_PUBKEY_SIZE, respectively.
46+
bool rsa2048VerifySha256BasedPkcs1v15Signature(const void *data, size_t data_size, const void *signature, const void *modulus, const void *public_exponent, size_t public_exponent_size);
47+
4248
/// Performs RSA-2048-OAEP decryption.
43-
/// Suitable to decrypt the titlekey block from tickets with personalized crypto.
49+
/// Suitable to decrypt the titlekey block from personalized tickets.
4450
/// The provided signature and modulus must have sizes of at least RSA2048_SIG_SIZE and RSA2048_PUBKEY_SIZE, respectively.
4551
/// 'label' and 'label_size' arguments are optional -- if not needed, these may be set to NULL and 0, respectively.
4652
bool rsa2048OaepDecrypt(void *dst, size_t dst_size, const void *signature, const void *modulus, const void *public_exponent, size_t public_exponent_size, const void *private_exponent, \

0 commit comments

Comments
 (0)