latticeBitParser: add support for loading Lattice (Nexus) encrypted bitstreams,

by adding key and preamble of encrypted bitstreams to if statements.
This commit is contained in:
Giovanni Bruni 2024-02-13 09:20:35 +01:00
parent 4c4b132c2c
commit 0f9422f09a
1 changed files with 4 additions and 2 deletions

View File

@ -68,7 +68,8 @@ int LatticeBitParser::parseHeader()
printError("Preamble key not found");
return EXIT_FAILURE;
}
if ((uint8_t)_raw_data[pos-1] != 0xbd && (uint8_t)_raw_data[pos-1] != 0xbf) {
//0xbe is the key for encrypted bitstreams in Nexus fpgas
if ((uint8_t)_raw_data[pos-1] != 0xbd && (uint8_t)_raw_data[pos-1] != 0xbf && (uint8_t)_raw_data[pos-1] != 0xbe) {
printError("Wrong preamble key");
return EXIT_FAILURE;
}
@ -98,7 +99,8 @@ int LatticeBitParser::parse()
/* check preamble */
uint32_t preamble = (*(uint32_t *)&_raw_data[_endHeader+1]);
if ((preamble != 0xb3bdffff) && (preamble != 0xb3bfffff)) {
//0xb3beffff is the preamble for encrypted bitstreams in Nexus fpgas
if ((preamble != 0xb3bdffff) && (preamble != 0xb3bfffff) && (preamble != 0xb3beffff)) {
printError("Error: missing preamble\n");
return EXIT_FAILURE;
}