Updated on 2026-08-14
This commit is contained in:
parent
df94a313e8
commit
bc544de0c0
2 changed files with 87 additions and 14 deletions
|
|
@ -66,5 +66,73 @@
|
|||
{"block":11491,"count":1,"digest":"4078"},
|
||||
{"block":0,"count":0,"digest":"75C3"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"fw":"1.28r",
|
||||
"challenge":"00000000000000000000000000000001",
|
||||
"sha-256":[
|
||||
{"block":0,"count":1,"digest":"A52D552A4CCA2979122300C7C8686031FBB216C187971C739305D493284DD262"},
|
||||
{"block":1,"count":1,"digest":"AF8D5DDC8FD0BA9B58707BC66940A50298AAB6FFE74D243874BAA25CCD53C7C3"},
|
||||
{"block":2,"count":1,"digest":"03612CB50531C2A2B7825B6A72C14528522A926A781391E8FE17027943543387"},
|
||||
{"block":3,"count":1,"digest":"88A984179C97654B7833824DF43A13133BC6E627C17C9A65BEEDFB671CD78D2A"},
|
||||
{"block":4,"count":1,"digest":"A3DB1DD3F876ED972287FEC903C2112F6B99A09BCF686E2B65A6E19EA9CD9ECB"},
|
||||
{"block":5,"count":1,"digest":"CA7685FCD6BE9D8310BBD58AA7DED1390925BADA47B6611DB010625CA6BA7542"},
|
||||
{"block":6,"count":1,"digest":"192E10BF1D4AA426676918AAC7312FF4914A4781A2E6372986356AC26917078B"},
|
||||
{"block":7,"count":1,"digest":"00B657206A8120DE159F3C16B4F036B7D2D292603067FCB6B33E3753421D9D15"},
|
||||
{"block":8,"count":1,"digest":"2F875EE18AD37A3A4666810E7E0942F7370CAD365C510B7952280EC43BE12ADE"},
|
||||
{"block":9,"count":1,"digest":"1CFAF013B43CAF9F6627DAC871335B09279375A9DE8644AEB2FBBA105C73C05A"},
|
||||
{"block":10,"count":1,"digest":"AD33E62400EFE078EB9256C3A6F9B9299A4B56F4A7E63E78C9BC34F7DCA2FE10"},
|
||||
{"block":11497,"count":1,"digest":"FBB56C858CF485012A08343B73C46CDA7423500D52FBE5E4F28326F2515C7150"},
|
||||
{"block":0,"count":0,"digest":"7582258B2AF9FDCD83BCDEA05FA0310216F7CFF4FB27C699461397EF4D189567"}
|
||||
],
|
||||
"crc-16":[
|
||||
{"block":0,"count":1,"digest":"B42D"},
|
||||
{"block":1,"count":1,"digest":"7A5C"},
|
||||
{"block":2,"count":1,"digest":"D1EF"},
|
||||
{"block":3,"count":1,"digest":"BB3B"},
|
||||
{"block":4,"count":1,"digest":"AE9E"},
|
||||
{"block":5,"count":1,"digest":"F021"},
|
||||
{"block":6,"count":1,"digest":"D2EB"},
|
||||
{"block":7,"count":1,"digest":"DFFD"},
|
||||
{"block":8,"count":1,"digest":"63F3"},
|
||||
{"block":9,"count":1,"digest":"96FD"},
|
||||
{"block":10,"count":1,"digest":"C886"},
|
||||
{"block":11497,"count":1,"digest":"E4B0"},
|
||||
{"block":0,"count":0,"digest":"0143"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"fw":"1.28d SDK",
|
||||
"challenge":"00000000000000000000000000000001",
|
||||
"sha-256":[
|
||||
{"block":0,"count":1,"digest":"2F9DB9B70A20E28A97A6A58919E71ABF757BA73E693D9DC9CEEE1B0BCA8DAB8E"},
|
||||
{"block":1,"count":1,"digest":"6B6F75ECF7E9CB76E570C290E7BEEAEF44E4B24C46BA4AA115D5BBAE3209869F"},
|
||||
{"block":2,"count":1,"digest":"4D584DDC73B940C7E508456BF0C52BC6BE018CD448A5886B54BEBF1D26D31AD5"},
|
||||
{"block":3,"count":1,"digest":"A9D5929A34793F5BCC623234AE34DEE246A95ED34D75D51508B9DC2694F28CD6"},
|
||||
{"block":4,"count":1,"digest":"094D5F3E03262B6D07E58F795E17FFF2D83D39ABCF86B3B04A856A37BB076AD0"},
|
||||
{"block":5,"count":1,"digest":"40F5586223406B2BD790629AB5D8D1AB97B6EA9151B69BF4D55C4A1EF5E2A1BB"},
|
||||
{"block":6,"count":1,"digest":"B56C71A3E6DFE98B1666825825844372EEE5811EEA743A40760FA7AE2D66CADD"},
|
||||
{"block":7,"count":1,"digest":"4331EB4B7415883536DDBA03D75F0408BE1F23F3DEE4459227755C12CBF98A8D"},
|
||||
{"block":8,"count":1,"digest":"7383EDD57D266591760CD74E50073D28973CB2DAFD1410E45030B33588768DEE"},
|
||||
{"block":9,"count":1,"digest":"893F5CF5E368E82CABE7F48D5DAA54AFAFA740B28496F303E845E680B7C1436C"},
|
||||
{"block":10,"count":1,"digest":"8DEEB29CD6C764FB7AB53A056BC3C860DBD8E121AB7C1E6E4DF3C273A503C405"},
|
||||
{"block":11497,"count":1,"digest":"6F6166E13672B12BD947CDFEC3158064A14C5A259AD0B3550738E30E90BC20C5"},
|
||||
{"block":0,"count":0,"digest":"E475661F4D0948ACBDF104EAD718260A73FB99448691F0EB68AED85D189B6F3C"}
|
||||
],
|
||||
"crc-16":[
|
||||
{"block":0,"count":1,"digest":"3506"},
|
||||
{"block":1,"count":1,"digest":"FB77"},
|
||||
{"block":2,"count":1,"digest":"50C4"},
|
||||
{"block":3,"count":1,"digest":"3A10"},
|
||||
{"block":4,"count":1,"digest":"2FB5"},
|
||||
{"block":5,"count":1,"digest":"710A"},
|
||||
{"block":6,"count":1,"digest":"53C0"},
|
||||
{"block":7,"count":1,"digest":"5ED6"},
|
||||
{"block":8,"count":1,"digest":"E2D8"},
|
||||
{"block":9,"count":1,"digest":"17D6"},
|
||||
{"block":10,"count":1,"digest":"49AD"},
|
||||
{"block":11497,"count":1,"digest":"659B"},
|
||||
{"block":0,"count":0,"digest":"1893"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -41,22 +41,27 @@ public class FW {
|
|||
|
||||
public static VerifyCodeRecord selectRandomVerifyCodeBlock(String firmwareVersion) throws IOException {
|
||||
|
||||
for(int i=0; i<jaFirmwares.size(); i++) {
|
||||
JsonObject jsVersion = jaFirmwares.get(i).getAsJsonObject();
|
||||
if( jsVersion.get("fw").getAsString().equals(firmwareVersion) )
|
||||
{
|
||||
VerifyCodeRecord result=new VerifyCodeRecord();
|
||||
result.hashAlg = "sha-256";
|
||||
JsonArray jsHashes = jsVersion.get(result.hashAlg).getAsJsonArray();
|
||||
result.challenge = Util.hexToBytes(jsVersion.get("challenge").getAsString());
|
||||
int caseIndex= Util.byteArrayToInt(Util.generateRandomBytes(4))%jsHashes.size();
|
||||
JsonObject jsRecord = jsHashes.get(caseIndex).getAsJsonObject();
|
||||
result.blockIndex = jsRecord.get("block").getAsInt();
|
||||
result.blockCount = jsRecord.get("count").getAsInt();
|
||||
result.digest = Util.hexToBytes(jsRecord.get("digest").getAsString());
|
||||
return result;
|
||||
try {
|
||||
for (int i = 0; i < jaFirmwares.size(); i++) {
|
||||
JsonObject jsVersion = jaFirmwares.get(i).getAsJsonObject();
|
||||
if (jsVersion.get("fw").getAsString().equals(firmwareVersion)) {
|
||||
VerifyCodeRecord result = new VerifyCodeRecord();
|
||||
result.hashAlg = "sha-256";
|
||||
JsonArray jsHashes = jsVersion.get(result.hashAlg).getAsJsonArray();
|
||||
result.challenge = Util.hexToBytes(jsVersion.get("challenge").getAsString());
|
||||
int caseIndex = (Util.byteArrayToInt(Util.generateRandomBytes(4)) & 0xFFFFFF) % jsHashes.size();
|
||||
JsonObject jsRecord = jsHashes.get(caseIndex).getAsJsonObject();
|
||||
result.blockIndex = jsRecord.get("block").getAsInt();
|
||||
result.blockCount = jsRecord.get("count").getAsInt();
|
||||
result.digest = Util.hexToBytes(jsRecord.get("digest").getAsString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue