stef / pbp

salty privacy
Other
53 stars 5 forks source link

File format description for pk encrypted files is wrong #12

Closed TLINDEN closed 10 years ago

TLINDEN commented 10 years ago

This one took me a couple of hours to figure out. If we ever met, I'll take a beer :)

The recipient list which is generated by pbp is described as:

nonce | cipher

where cipher is the pk-encrypted symkey. In reality pbp does this:

nonce | L | cipher

where L is the len of the cipher (1 byte). I didn't have that value in pcp.

So, for now I added it, but I'd suggest leaving it out. Since everything in there is static, the size of the cipher is well known (it's 72 bytes, 24 nonce, 16 nacl pad, 32 symkey). And all my functions work with nonce|cipher whereever symmetric encryption is concerned, therefore I have to dissect the recipient list in order to get the correct input for my decryption functions.

best regards, Tom

PS: pk-crypto is now compatible (if the patches of issue#10 are applied), see my last post on CP.

stef commented 10 years ago

do you mean this part (src):

        outfd.write(struct.pack(">L", len(peerkeys)))
        for rnonce, ct in peerkeys:
            outfd.write(rnonce)
            outfd.write(struct.pack("B", len(ct)))
            outfd.write(ct)

the length here is necessary to know how many recipients are in the recipient part. I believe this is also described as such in doc/fileformats.txt#L21

stef commented 10 years ago

oooh, i get it. the middle thing.

outfd.write(struct.pack("B", len(ct)))

this really hit a cognitive blindspot. thanks!

stef commented 10 years ago

fixed. thx again! see: https://github.com/stef/pbp/commit/7d7b7c9ecb7604ad22938f5b68a624093a417bfa