JeanLuc38
11th June, 2022, 01:12 PM
Hello,
I'm trying to understand how the checksum of EDC16C34 (PSA) is calculated.
I already found the 1024bits RSA key and managed to decrypt the signature.
The RSA modulus and public exponent (3) is located in the code zone (before 0x1c0000) and it is easy to find it in a full dump.
(find a 1024 bit big endian number that is not easy to factor and not prime, then check the sig with found canditates)
The 1024bits signature is located at 0x1FDF7C (in the MAP zone) and is readable via OBD.
All my dump collection of PSA EDC16C34 share the same RSA public key (modulus and exponent).
You can devryt the signature by doing the follwoing:
BigInteger n = new BigInteger(
"9f63259b570099e4435112058526405d"+
"edd701b8b51d42d80b46c71839171620"+
"fe91c5d46aaf2ccf8921b6eb56c62f46"+
"4f2930d1b0970bb77c686a30123400ef"+
"b406bff133151cc4100b4d715c038f0f"+
"50aa247e5b710e0a8893de467077d169"+
"db2c496d7205c3c44a6b3b1e37bfa03b"+
"35d9a44f1879f76523ffde1a0e501151",
16
);
BigInteger a = new BigInteger(
"7C0BAF52E70054CFECBC7E14F41C9E39"+
"D33E2501083F2455872B7B47A35D3D5D"+
"1538D15D2C50D0D6B8A88A852A5349EB"+
"A27585936055E0F8890B4B0C5C1823C2"+
"D844357A6AA4F050541BA790D0EC9AEB"+
"DE78DB8E2D5A76821B6A1E0D45167054"+
"E114E5B148CFCAD8E6BDAF5797CA0770"+
"6879D768FED02193F4DC53D7727D8685"
,16);
BigInteger sig = a.pow(3).mod(n);
System.out.println(sig.toString(16) + " " + sig.bitLength() + "bits");
Output:
1ffffffffffffffff00c371e42fdb4d3808b3f0559437cb20f 6000000003931330000000000000000000000000031343a313 03a34312030332d30382d3037e42d139c6adc1f855d87000ed 8052481c7b494d198fe81a92a2406ab30c3a3ae953d4a3d2a5 f621e207cb62f9d5fad5ef735b7fccce4594796f1b458ee560 c5a
An original signature looks like this:
0001ffffffffffffffff00feda839f0a536be7114da06cde4a c7f6000000003931310000000000000000000000000031343a 31393a34322031362d31312d3036dc6c083a64afccdfa711c8 984d1e5aabdda747ad6f6ad1d5cc3d5fc24044f97cb62bb5f3 5a0249d246b0ced88a9112971f3c4dccec07ce2d994550d938 cf9055
. . . . . . . . . . . . . . . . S k . . M . l . J . . . . . . 9 1 1 . . . . . . . . . . . . . 1 4 : 1 9 : 4 2 1 6 - 1 1 - 0 6 . l . : d . . . . . . . M . Z . . . G . o j . . . = _ . @ D . | . + . . Z . I . F . . . . . . . . < M . . . . - . E P . 8 . . U
A corrected one looks like this:
By winols: winols adds BPG-8101 inside its signature:
9f63259b570099e4435112058526405dedd701b8b51d42d80b 46c71839171620fe91c5d46aaf2ccf8921b6eb56c62f464f29 30d1b0970bb77c686a30123400efb406bff133151cc4100b4d 715c038f0f50aa247e5b4ea0e63e695862d738823786e4ba78 e88203b34fddbc7836aca5162cf87358cb74c65740c5ec0c46 1b1390
0001ffffffffffffffff00885ac5e6fee40cd7f7bbdaaeeb3c 57d14250472d3831303100000000000021c2b276bf784d885d cd17b73bd7e29302512be2e4f2e7831d8fff35951d06feffda 1f4748eb89bad75e5be9a504ab124766b97528da4394e66475 129f716c1c2ed391626cfa47175d5aad3c343cb9e1bef12f9c 85e810
. . . . . . . . . . . . Z . . . . . . . . . . . < W . B P G - 8 1 0 1 . . . . . . ! . . v . x M . ] . . . ; . . . . Q + . . . . . . . . 5 . . . . . . . G H . . . . ^ [ . . . . . G f . u ( . C . . d u . . q l . . . . b l . G . ] Z . < 4 < . . . . / . . . .
By MPPS:
00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 0000000000000000000001428a2f98d728ae220835a672cdd5 ee33c799c5a3418d6b167cc857b3692d5bcdcf4d06ca12be35 68e4ce
0001ffffffffffffffff00885ac5e6fee40cd7f7bbdaaeeb3c 57d1000000000000000000000000000000c0ffb7c19af461d9 ffdb87764502cc89dfadd61a37c3c1ae8350aacccad9a9d540 39d3a0b3756075ad784033a09aa7cdab281803bc6ba3f986b6 4f6cbad447204cdce6d2dda0bd1ea9ccf76787a04a779d3172 ed13b8
. . . . . . . . . . . . Z . . . . . . . . . . . < W . . . . . . . . . . . . . . . . . . . . . . a . . . . v E . . . . . . . 7 . . . . P . . . . . . @ 9 . . . u ` u . x @ 3 . . . . . ( . . . k . . . . O l . . G L . . . . . . . . . . g . . J w . 1 r . . .
We can remark that only the prefix 0001ffffffffffffffff00 followed by the 128 bits hash (MD5) is kept, the other byte are used to find a cubic root (mod n), this is a common RSA failure when the padding is not fully checked.
I manged to locate the MD5 code in the MPC code, here is the routine that initialise the MD5 initial state.
Then follow the MD5 round code.
https://content-eu.invisioncic.com/m304542/monthly_2022_06/large.mpc_md5.jpg.ad122beef4b8b383d90702c3a4fc5b98 .jpg
Now the problem is to find how the MD5 is calculated, i presume it is calculated on several areas and not on the full MAP zone.
I didn't manage to find addresses and length of this areas.
It is also difficult to set all the environement in the TRACE32 debbuger, to run the program and get addresses and length, it is difficult to find information on the boot sector.
So any suggestions or additionnal informations would be welcome :)
Thanks
I'm trying to understand how the checksum of EDC16C34 (PSA) is calculated.
I already found the 1024bits RSA key and managed to decrypt the signature.
The RSA modulus and public exponent (3) is located in the code zone (before 0x1c0000) and it is easy to find it in a full dump.
(find a 1024 bit big endian number that is not easy to factor and not prime, then check the sig with found canditates)
The 1024bits signature is located at 0x1FDF7C (in the MAP zone) and is readable via OBD.
All my dump collection of PSA EDC16C34 share the same RSA public key (modulus and exponent).
You can devryt the signature by doing the follwoing:
BigInteger n = new BigInteger(
"9f63259b570099e4435112058526405d"+
"edd701b8b51d42d80b46c71839171620"+
"fe91c5d46aaf2ccf8921b6eb56c62f46"+
"4f2930d1b0970bb77c686a30123400ef"+
"b406bff133151cc4100b4d715c038f0f"+
"50aa247e5b710e0a8893de467077d169"+
"db2c496d7205c3c44a6b3b1e37bfa03b"+
"35d9a44f1879f76523ffde1a0e501151",
16
);
BigInteger a = new BigInteger(
"7C0BAF52E70054CFECBC7E14F41C9E39"+
"D33E2501083F2455872B7B47A35D3D5D"+
"1538D15D2C50D0D6B8A88A852A5349EB"+
"A27585936055E0F8890B4B0C5C1823C2"+
"D844357A6AA4F050541BA790D0EC9AEB"+
"DE78DB8E2D5A76821B6A1E0D45167054"+
"E114E5B148CFCAD8E6BDAF5797CA0770"+
"6879D768FED02193F4DC53D7727D8685"
,16);
BigInteger sig = a.pow(3).mod(n);
System.out.println(sig.toString(16) + " " + sig.bitLength() + "bits");
Output:
1ffffffffffffffff00c371e42fdb4d3808b3f0559437cb20f 6000000003931330000000000000000000000000031343a313 03a34312030332d30382d3037e42d139c6adc1f855d87000ed 8052481c7b494d198fe81a92a2406ab30c3a3ae953d4a3d2a5 f621e207cb62f9d5fad5ef735b7fccce4594796f1b458ee560 c5a
An original signature looks like this:
0001ffffffffffffffff00feda839f0a536be7114da06cde4a c7f6000000003931310000000000000000000000000031343a 31393a34322031362d31312d3036dc6c083a64afccdfa711c8 984d1e5aabdda747ad6f6ad1d5cc3d5fc24044f97cb62bb5f3 5a0249d246b0ced88a9112971f3c4dccec07ce2d994550d938 cf9055
. . . . . . . . . . . . . . . . S k . . M . l . J . . . . . . 9 1 1 . . . . . . . . . . . . . 1 4 : 1 9 : 4 2 1 6 - 1 1 - 0 6 . l . : d . . . . . . . M . Z . . . G . o j . . . = _ . @ D . | . + . . Z . I . F . . . . . . . . < M . . . . - . E P . 8 . . U
A corrected one looks like this:
By winols: winols adds BPG-8101 inside its signature:
9f63259b570099e4435112058526405dedd701b8b51d42d80b 46c71839171620fe91c5d46aaf2ccf8921b6eb56c62f464f29 30d1b0970bb77c686a30123400efb406bff133151cc4100b4d 715c038f0f50aa247e5b4ea0e63e695862d738823786e4ba78 e88203b34fddbc7836aca5162cf87358cb74c65740c5ec0c46 1b1390
0001ffffffffffffffff00885ac5e6fee40cd7f7bbdaaeeb3c 57d14250472d3831303100000000000021c2b276bf784d885d cd17b73bd7e29302512be2e4f2e7831d8fff35951d06feffda 1f4748eb89bad75e5be9a504ab124766b97528da4394e66475 129f716c1c2ed391626cfa47175d5aad3c343cb9e1bef12f9c 85e810
. . . . . . . . . . . . Z . . . . . . . . . . . < W . B P G - 8 1 0 1 . . . . . . ! . . v . x M . ] . . . ; . . . . Q + . . . . . . . . 5 . . . . . . . G H . . . . ^ [ . . . . . G f . u ( . C . . d u . . q l . . . . b l . G . ] Z . < 4 < . . . . / . . . .
By MPPS:
00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 0000000000000000000001428a2f98d728ae220835a672cdd5 ee33c799c5a3418d6b167cc857b3692d5bcdcf4d06ca12be35 68e4ce
0001ffffffffffffffff00885ac5e6fee40cd7f7bbdaaeeb3c 57d1000000000000000000000000000000c0ffb7c19af461d9 ffdb87764502cc89dfadd61a37c3c1ae8350aacccad9a9d540 39d3a0b3756075ad784033a09aa7cdab281803bc6ba3f986b6 4f6cbad447204cdce6d2dda0bd1ea9ccf76787a04a779d3172 ed13b8
. . . . . . . . . . . . Z . . . . . . . . . . . < W . . . . . . . . . . . . . . . . . . . . . . a . . . . v E . . . . . . . 7 . . . . P . . . . . . @ 9 . . . u ` u . x @ 3 . . . . . ( . . . k . . . . O l . . G L . . . . . . . . . . g . . J w . 1 r . . .
We can remark that only the prefix 0001ffffffffffffffff00 followed by the 128 bits hash (MD5) is kept, the other byte are used to find a cubic root (mod n), this is a common RSA failure when the padding is not fully checked.
I manged to locate the MD5 code in the MPC code, here is the routine that initialise the MD5 initial state.
Then follow the MD5 round code.
https://content-eu.invisioncic.com/m304542/monthly_2022_06/large.mpc_md5.jpg.ad122beef4b8b383d90702c3a4fc5b98 .jpg
Now the problem is to find how the MD5 is calculated, i presume it is calculated on several areas and not on the full MAP zone.
I didn't manage to find addresses and length of this areas.
It is also difficult to set all the environement in the TRACE32 debbuger, to run the program and get addresses and length, it is difficult to find information on the boot sector.
So any suggestions or additionnal informations would be welcome :)
Thanks