ec_wii: Amend function casing
This commit is contained in:
1 parent
650071c3e4
commit
926c9f995a
4 files changed
+33
-39
No files matched your search
+21
-23
@@ -36,7 +36,18 @@ static u8 default_NG_sig[] = {
|
||||
0xB8, 0xA8, 0x90, 0x1F, 0xA8, 0x2A, 0x0E, 0x4E, 0x76, 0xEF, 0x44, 0x72, 0x99, 0xF8,
|
||||
};
|
||||
|
||||
// get_ng_cert
|
||||
static void MakeBlankSigECCert(u8* cert_out, const char* signer, const char* name,
|
||||
const u8* private_key, u32 key_id)
|
||||
{
|
||||
memset(cert_out, 0, 0x180);
|
||||
*(u32*)cert_out = Common::swap32(0x10002);
|
||||
|
||||
strncpy((char*)cert_out + 0x80, signer, 0x40);
|
||||
*(u32*)(cert_out + 0xc0) = Common::swap32(2);
|
||||
strncpy((char*)cert_out + 0xc4, name, 0x40);
|
||||
*(u32*)(cert_out + 0x104) = Common::swap32(key_id);
|
||||
ec_priv_to_pub(private_key, cert_out + 0x108);
|
||||
}
|
||||
|
||||
// ng_cert_out is a pointer to a 0x180 byte buffer that will contain the device-unique certificate
|
||||
// NG_id is the device-unique id to use
|
||||
@@ -45,7 +56,7 @@ static u8 default_NG_sig[] = {
|
||||
// NG_sig is the device-unique signature blob (from issuer) to use
|
||||
// if NG_priv iis nullptr or NG_sig is nullptr or NG_id is 0 or NG_key_id is 0, default values
|
||||
// will be used for all of them
|
||||
void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, const u8* NG_sig)
|
||||
void MakeNGCert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, const u8* NG_sig)
|
||||
{
|
||||
char name[64];
|
||||
if ((NG_id == 0) || (NG_key_id == 0) || (NG_priv == nullptr) || (NG_sig == nullptr))
|
||||
@@ -57,7 +68,7 @@ void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, c
|
||||
}
|
||||
|
||||
sprintf(name, "NG%08x", NG_id);
|
||||
make_blanksig_ec_cert(ng_cert_out, "Root-CA00000001-MS00000002", name, NG_priv, NG_key_id);
|
||||
MakeBlankSigECCert(ng_cert_out, "Root-CA00000001-MS00000002", name, NG_priv, NG_key_id);
|
||||
memcpy(ng_cert_out + 4, NG_sig, 60);
|
||||
}
|
||||
|
||||
@@ -72,8 +83,8 @@ void get_ng_cert(u8* ng_cert_out, u32 NG_id, u32 NG_key_id, const u8* NG_priv, c
|
||||
// NG_priv is the device-unique private key to use
|
||||
// NG_id is the device-unique id to use
|
||||
// if NG_priv is nullptr or NG_id is 0, it will use builtin defaults
|
||||
void get_ap_sig_and_cert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u32 data_size,
|
||||
const u8* NG_priv, u32 NG_id)
|
||||
void MakeAPSigAndCert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u32 data_size,
|
||||
const u8* NG_priv, u32 NG_id)
|
||||
{
|
||||
u8 hash[20];
|
||||
u8 ap_priv[30];
|
||||
@@ -96,7 +107,7 @@ void get_ap_sig_and_cert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u
|
||||
|
||||
sprintf(signer, "Root-CA00000001-MS00000002-NG%08x", NG_id);
|
||||
sprintf(name, "AP%08x%08x", (u32)(title_id >> 32), (u32)(title_id & 0xffffffff));
|
||||
make_blanksig_ec_cert(ap_cert_out, signer, name, ap_priv, 0);
|
||||
MakeBlankSigECCert(ap_cert_out, signer, name, ap_priv, 0);
|
||||
|
||||
mbedtls_sha1(ap_cert_out + 0x80, 0x100, hash);
|
||||
generate_ecdsa(ap_cert_out + 4, ap_cert_out + 34, NG_priv, hash);
|
||||
@@ -105,19 +116,6 @@ void get_ap_sig_and_cert(u8* sig_out, u8* ap_cert_out, u64 title_id, u8* data, u
|
||||
generate_ecdsa(sig_out, sig_out + 30, ap_priv, hash);
|
||||
}
|
||||
|
||||
void make_blanksig_ec_cert(u8* cert_out, const char* signer, const char* name,
|
||||
const u8* private_key, u32 key_id)
|
||||
{
|
||||
memset(cert_out, 0, 0x180);
|
||||
*(u32*)cert_out = Common::swap32(0x10002);
|
||||
|
||||
strncpy((char*)cert_out + 0x80, signer, 0x40);
|
||||
*(u32*)(cert_out + 0xc0) = Common::swap32(2);
|
||||
strncpy((char*)cert_out + 0xc4, name, 0x40);
|
||||
*(u32*)(cert_out + 0x104) = Common::swap32(key_id);
|
||||
ec_priv_to_pub(private_key, cert_out + 0x108);
|
||||
}
|
||||
|
||||
EcWii::EcWii()
|
||||
{
|
||||
bool init = true;
|
||||
@@ -160,22 +158,22 @@ EcWii::~EcWii()
|
||||
{
|
||||
}
|
||||
|
||||
u32 EcWii::getNgId() const
|
||||
u32 EcWii::GetNGID() const
|
||||
{
|
||||
return Common::swap32(BootMiiKeysBin.ng_id);
|
||||
}
|
||||
|
||||
u32 EcWii::getNgKeyId() const
|
||||
u32 EcWii::GetNGKeyID() const
|
||||
{
|
||||
return Common::swap32(BootMiiKeysBin.ng_key_id);
|
||||
}
|
||||
|
||||
const u8* EcWii::getNgPriv() const
|
||||
const u8* EcWii::GetNGPriv() const
|
||||
{
|
||||
return BootMiiKeysBin.ng_priv;
|
||||
}
|
||||
|
||||
const u8* EcWii::getNgSig() const
|
||||
const u8* EcWii::GetNGSig() const
|
||||
{
|
||||
return BootMiiKeysBin.ng_sig;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user