From 5a46f2f1b3b4a3d81c08b2b3d42c74714288ca53 Mon Sep 17 00:00:00 2001 From: Sorvigolova Date: Mon, 6 Apr 2015 14:04:40 +0300 Subject: [PATCH] Updated to v.0.2.14 - Added PS3 Linux support. - Fixed ECDSA checking. --- src/README | 3 +++ src/sce.cpp | 25 +++++++++++++++++++++---- src/types.h | 12 ++++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/README b/src/README index 5f2673e..8088d76 100644 --- a/src/README +++ b/src/README @@ -85,6 +85,9 @@ OPTIONS Possible Values Explanation -j, --np-add-sig TRUE/FALSE(default) Whether to add a NP sig. or not. ==> History <== +Version 0.2.14 +- Added PS3 Linux support. +- Fixed ECDSA checking. Version 0.2.13 - Unlocked decryption for self files with network license type. - Fixed one minor bug with capability flags. diff --git a/src/sce.cpp b/src/sce.cpp index 359b497..8bfd6fa 100644 --- a/src/sce.cpp +++ b/src/sce.cpp @@ -119,6 +119,9 @@ void _print_sce_signature(FILE *fp, signature_t *sig) void _print_sce_signature_status(FILE *fp, sce_buffer_ctxt_t *ctxt, u8 *keyset) { u8 hash[0x14]; + u8 Q[0x28]; + u8 M[0x14]; + u8 zero_buf[0x14]; keyset_t *ks; //Check if a keyset is provided. @@ -134,11 +137,25 @@ void _print_sce_signature_status(FILE *fp, sce_buffer_ctxt_t *ctxt, u8 *keyset) } //Generate header hash. sha1(ctxt->scebuffer, _ES64(ctxt->metah->sig_input_length), hash); - - //Validate the signature. + _hexdump(fp, " E", 0, hash, 0x14, FALSE); + ecdsa_set_curve(ks->ctype); ecdsa_set_pub(ks->pub); - fprintf(fp, "[*] Signature status: %s\n", (ecdsa_verify(hash, ctxt->sig->r, ctxt->sig->s) == TRUE ? "OK" : "FAIL")); + + #ifdef CONFIG_PRIVATE_BUILD + //validate private key and calculate M + ec_priv_to_pub(ks->priv, Q); + get_m(ctxt->sig->r, ctxt->sig->s, hash, ks->priv, M); + if (memcmp(ks->pub, Q, sizeof(Q)) == 0) + _hexdump (fp, " M", 0, M, 0x14, FALSE); + #endif + + //Validate the signature. + memset(zero_buf, 0, sizeof(zero_buf)); + if ((memcmp(ctxt->sig->r, zero_buf, sizeof(zero_buf)) == 0) || (memcmp(ctxt->sig->s, zero_buf, sizeof(zero_buf)) == 0)) + fprintf(fp, "[*] Signature status: FAIL\n"); + else + fprintf(fp, "[*] Signature status: %s\n", (ecdsa_verify(hash, ctxt->sig->r, ctxt->sig->s) == TRUE ? "OK" : "FAIL")); } static sce_buffer_ctxt_t *_sce_create_ctxt() @@ -1025,4 +1042,4 @@ opt_header_t *sce_get_opt_header(sce_buffer_ctxt_t *ctxt, u32 type) } return NULL; -} +} \ No newline at end of file diff --git a/src/types.h b/src/types.h index 4d323c0..41a7add 100644 --- a/src/types.h +++ b/src/types.h @@ -38,6 +38,10 @@ typedef unsigned long long int u64; #define _ES16(val) \ ((u16)(((((u16)val) & 0xff00) >> 8) | \ ((((u16)val) & 0x00ff) << 8))) + +#ifdef __BIG_ENDIAN__ + #define _ES16(val) val +#endif //Endian swap for u32. #define _ES32(val) \ @@ -45,6 +49,10 @@ typedef unsigned long long int u64; ((((u32)val) & 0x00ff0000) >> 8 ) | \ ((((u32)val) & 0x0000ff00) << 8 ) | \ ((((u32)val) & 0x000000ff) << 24))) + +#ifdef __BIG_ENDIAN__ + #define _ES32(val) val +#endif //Endian swap for u64. #define _ES64(val) \ @@ -57,6 +65,10 @@ typedef unsigned long long int u64; ((((u64)val) & 0x000000000000ff00ull) << 40) | \ ((((u64)val) & 0x00000000000000ffull) << 56))) +#ifdef __BIG_ENDIAN__ + #define _ES64(val) val +#endif + #ifdef __cplusplus } #endif