Menu

#21 mcrypt key modes

v1.0_(example)
open
nobody
keymode (1)
1
2014-01-27
2014-01-27
Per Tunedal
No

I've spent some time reading different manpages and examples in vain; I cannot
figure out how the key modes function in mcrypt.

I would like to know what input mcrypt expects and what's done to the
key internally before encryption.

  1. What´s the default input format? Binary? Hex? String?
  2. Is the key hashed (SHA-1? as told in an old manpage),
    padded/truncated to fit the algoritm?

I'm encrypting with a password (string). If I stick to the default key
mode, should the key passed to mcrypt be in binary form? Should it be
truncated to the appropriate length?

I've tested to hash the key to HEX, trunkate it and binarise it with
pack (as in the example in the php manpage). As an alternative I've tested
to hash it directly to binary form and not truncate. Both ways work as a
charm, but are not compatible: the same password cannot decrypt both
variants.

Ideally I would like to use some keywrapping eg PBKDF2. What key mode
would be appropriate? How to proceed?

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.