libyal / libbde

Library and tools to access the BitLocker Drive Encryption (BDE) encrypted volumes
GNU Lesser General Public License v3.0
214 stars 52 forks source link

recovery key generation method #67

Open nblog opened 10 months ago

nblog commented 10 months ago

In the "Recovery Key" section,there is no mention of how to generate it, so I'll add the method for that,It comes from one of the tools I analyzed.

std::srand(static_cast<std::uint32_t>(std::time(0)));

std::array<uint8_t, 16> tmpvalue = { 0 };

for (size_t i = 0; i < 16; i++)
{
    tmpvalue[i] = uint8_t(int(double(std::rand()) * 0.000030517578125 * 255.0 + 0.0));
}

std::array<std::string, 8> blocks;

for (size_t i = 0; i < 8; i++)
{
    char szBuffer[20] = { 0 };
    sprintf(szBuffer, "%06d", ((uint16_t*)(tmpvalue.data()))[i] * 11);
    blocks[i] = szBuffer;
}

return blocks[0] 
    + "-" + blocks[1]
    + "-" + blocks[2]
    + "-" + blocks[3]
    + "-" + blocks[4]
    + "-" + blocks[5]
    + "-" + blocks[6]
    + "-" + blocks[7];

@joachimmetz ,i hope this helps.

joachimmetz commented 10 months ago

I'll have a look when time permits, the goal of this project has mostly been to read BitLocker volumes