paragonie / pco_prototype

PCO - PHP Crypto Objects
Do What The F*ck You Want To Public License
12 stars 1 forks source link

Message Format #1

Closed paragonie-scott closed 9 years ago

paragonie-scott commented 9 years ago

We should encode some "basic" information in a header: Library, version, etc.

For example, the message format might seem like this (assume hex):

AAAAAAAA AAAAAAAA BBBBBBBB BBBBBBBB 
BBBBBBBB BBBBBBBB CCCCCCCC CCCCCCCC
CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC
CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC
CCCCCCCC CCCCCCCC CCCCCCCC CCCCCCCC
DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD
DDDDDDDD DDDDDDDD DDDDDDDD DDDDDDDD

Proposed Header Format

We should reserve 8 bytes (64 bits)

ircmaxell commented 9 years ago

Well, I would suggest having the version dictate the rest of the layout. There may be algorithms that need more than 2 components prior to the MAC.

paragonie-scott commented 9 years ago

Right, that makes sense. The idea I wanted to establish was whether or not the first 8 bytes should be reserved for the header. (Is 8 bytes enough?)

paragonie-scott commented 9 years ago

Actually, if we just make the first 4 bytes the header then let each driver prepend its own "driver-specific" header after that, we can eschew the 3-7 detail.

ircmaxell commented 9 years ago

8 bytes is plenty. If more is needed the version can identify that and parse it explicitly (like an extension)

ircmaxell commented 9 years ago

Yeah, in that case, I'd do 4 bytes: VVDC

where C is a checksum (computed as V ^ V ^ D) to validate that the ciphertext is infact a valid ciphertext.

paragonie-scott commented 9 years ago

Alright, I'll put a formal definition in the docs directory. :+1: