1 /*---------------------------------------------------------------------------*
2   Project:  TwlSDK - tools - makerom.TWL
3   File:     format_rom_certificate.h
4 
5   Copyright 2007-2008 Nintendo. All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Date:: 2008-09-18#$
14   $Rev: 8573 $
15   $Author: okubata_ryoma $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef	FORMAT_ROM_CERTIFICATE_H_
19 #define	FORMAT_ROM_CERTIFICATE_H_
20 
21 /*===========================================================================*
22  *  ROM CERTIFICATE FORMAT
23  *===========================================================================*/
24 
25 #define TWL_ROM_CERT_MAGIC_NUMBER			0x54524543		// "CERT" string
26 #define RSA_KEY_LENGTH						( 1024 / 8 )	// RSA public key length
27 #define ROM_CERT_SIGN_OFFSET				256				// Signature offset in ROM header certificate
28 #define ROM_HEADER_SIGN_TARGET_SIZE			0xe00			// Targeted size of the ROM header signature
29 
30 // ROM certificate header
31 typedef struct RomCertificateHeader {
32 	u32		magicNumber;
33 	u32		version;
34 	u32		serialNo;
35 	u32		gameCode;
36 }RomCertificateHeader;
37 
38 // ROM certificate
39 typedef struct RomCertificate {
40 	RomCertificateHeader	header;
41 	u8						reserved[ ROM_CERT_SIGN_OFFSET - sizeof(RomCertificateHeader) - RSA_KEY_LENGTH ];
42 	u8						pubKeyMod[ RSA_KEY_LENGTH ];
43 	u8						sign[ RSA_KEY_LENGTH ];
44 }RomCertificate;
45 
46 #endif //FORMAT_ROM_CERTIFICATE_H_
47