Password-based Key Derivation PKCS #5 v1.5


DeriveKeyM.cs is a simply C# utility which derives key byte material using a PKCS #5 v1.5 algorithm by consecutive hashing of salt data and password data. The utility accepts 4 parameters: a password string, a hex-encoded salt string, a hash iteration count, and the number of passes for the algorithm:
  DeriveKeyM.exe  [password]  [hex-encoded salt]  [hash-iteration count]  [algorithm passes]
DeriveKeyM uses the MD5 algorithm for hashing (generating 16 bytes per algorithm pass). The byte sequence produced by DeriveKeyM.exe is the same as that produced by, for example, the Java 2 PBEWithMD5AndDES algorithm. Note that Openssl.exe enc ... derives the same key and IV material, but with an iteration count of unity.

Sample output:

C:\DeriveKeyM>DeriveKeyM test 3065AD204B46DD02 1 3

Contatenated pswd || salt
746573743065AD204B46DD02

Computing hash 1 times over 3 algorithm iterations

D_1
5DC4CC9BCEFC482B7208C7A077519EB1

D_2
EE5C334761228D9F712387F331F73B9F

D_3
EDE37C9B8333573CFE4ABCAEBE6F05F2

Contatenated key data:
5DC4CC9BCEFC482B7208C7A077519EB1EE5C334761228D9F712387F331F73B9FEDE37C9B8333573CFE4ABCAEBE6F05F2


See also: