Minor documentation error

I was able to build a fully functional decryption program in C# using your architecture document, which is quite good.

I did discover a minor error in the following pseudocode taken verbatim from the architecture document:

cleartextChunks[] := split(cleartext, 32KiB)
for (int i = 0; i < length(cleartextChunks); i++) {
chunkNonce := createRandomBytes(16)
ciphertextPayload := aesCtr(cleartextChunks[i], contentKey, chunkNonce)
mac := hmacSha256(headerNonce . bigEndian(i) . chunkNonce . ciphertextPayload, macMasterKey)
ciphertextChunks[i] := chunkNonce . ciphertextPayload . mac
}
ciphertextFileContent := join(ciphertextChunks[])

The variable “i” must be a long, not int, as the mac requires an 8-byte big-endian block number, not a 4-byte one.

Aside from that, well done; describing the file system and encryption adequately in such a brief document is impressive. Having gone through all this I’m quite confident of the security and reliability of the software.

2 Likes

The pseudocode isn‘t meant to represent any specific architecture, therefore int isn‘t necessarily 32bit as in most modern cpu architectures. Anyhow you’re right, we could improve the code by explicitly saying what the bytesequence should look like, e.g. encodeAs64BitBigEndian(i).

Do you plan to publish your program? I think, many users would love to hear more about it.

1 Like

I’d like to make it available although there are a few obstacles:

  1. There is no UI front-end. It is simply meant to provide a simple virtual directory traverser and file decryptor. This would be packaged as a class library with maybe a command line driver to show functionality. Maybe this is not an issue given the scope of what was intended.

  2. Right now it has a dependence on 4 libraries: Newtonsoft JSON, an Scrypt library, an AES Keywrap library, and an AES SIV library. For the last 3, I am having trouble finding pure code I might use to replace the library and most of these would be too much work to do from scratch.

  3. Finally as a personal matter I have no one to review the code which I’d prefer to be done before widely available. I did not refer at all to the Java code because I have no experience with it, and thus my code is not factored in any way that’s similar to the official code.

If I can overcome some or all of these maybe then :). Ideas welcome.

(Pardon the interruption)

New here, I signed up minutes ago and just started perusing. I’m encouraged to see a number of things and I’m guessing it won’t be a negative to send a note:

Highly encouraging are:

  • dev involvement and encouragement
  • non-dev technical knowledge
  • friendliness
  • attention to detail

Okay I’ve gushed enough, cheers