Hi,
today I'm publishing the improved Version of my
former Idea on how to using an Linear Congruential Generator for cryptographic Purposes
Here the basic Principle again:
The main Functions of
my new Encryption Algorithm (SEA1m5 ) consisting in the following parts
1) A modified use of a regular Linear Congruential Generator (mLCG) feeding now with one Seed and 3 every-time changing Values for the Constants (A, C, M) for every single Encryption, instead of normally using one Seed and three fixed Constants. Long-term Test of the modified LCG (mLCG) showing a very resonable discrete Uniform Distribution of random Numbers.
Similar to:
* http://en.wikipedia.org/wiki/Linear_congruential_generator
2) A simple Hash-Function using MD5-Checksums which are re-hashed over several Rounds as a Key stretching Function.
Similar to:
* http://en.wikipedia.org/wiki/Key_strengthening
3) A Password-Based Random Initialisation Vector Function (PRND_IV) used to create the 4 IV (X, A, C, M) for the modified LCG (mLCG), which are in fact nearly similar to "Numbers used once". This function (PRND_IV) will generate the 4 IV (X, A, C, M) out of a random ASCII-String and the Password. Both represented by re-hashed MD5-Checksum‘s (MD5CHF) which are XOR enciphered, than split up in Numbers of certain length to initialise the Values X, A, C and M for the modified LCG (mLCG).
4) The random String, from which the 4 IV (X, A, C, M) are derived, will be XOR encrypted with the salted Password and placed in Front of every encrypted Message. This way we can secretly submit all 4 IV (X, A, C, M) for the modified LCG (mLCG) and the Message can be deciphered, if the receiver has Knowledge of the Password.
Now just a short Description of the enciphering and deciphering Steps:
'# Encipher Steps (short Description)'
(** Please find the corresponding Number in the JavaScript-Listing.)
(** e1)
//
Generate a random ASCII-String, build it‘s MD5-Checksum and pick some Values of it as Password-Salt
(** e2)
//
Generate a random ASCII-String as the Basis for the Password-Based Random Initialisation Vector Function. (PRND_IV)
(** e3)
//
Derive the 4 IV (Values X, A, C, M) from this random ASCII-String using the Password-Based Random Initialisation Vector Function (PRND_IV). This will put the modified LCG (mLCG) into it‘s internal State for creating the Key-Stream.
(** e4)
//
XOR Encipher the HEX-String of Random-IV with the MD5-based Chained Hash (MD5CHF) of the salted Password. The Result will be the Secret-IV.
(** e5)
//
Prepare the Message-Header containing a Marker for the used Version of the Encryption Algorithm, the Value for the MD5-Based Chained Hash Rounds, the HEX-Value of the Password-Salt and finally the HEX-Value of the Secret-IV.
(** e6)
//
Perform the XOR-Encryption of the Data-Stream with the Key-Stream using the formerly under (** e3) created 4 IV (Values X, A, C, M) with the modified LCG (mLCG) until the End of the Data-Stream has been reached.
(** e7)
//
In this JavaScript-Implementation, as we Encipher just a Text, the Message-Header will be placed in Front of the enciphered Message. When using the Encryption Algorithm on binary Data or a Communication-Stream the Message-Header of course needs to be written or send before the actual enciphered Data.
###
'# Decipher Steps (short Description)'
(** Please find the corresponding Number in the JavaScript-Listing.)
(** d1)
//
Check if the enciphered Message has the proper Version, extract the Value for the MD5-Based Chained Hash Rounds and the HEX-Value of the Password-Salt.
(** d2)
//
XOR Decipher the HEX-String of the Secret-IV from the Beginning of the enciphered Message, using the MD5-based Chained Hash (MD5CHF) of the salted Password. The Result will be the Random-IV from which the 4 IV (Values X, A, C, M) will be derived.
(** d3)
//
Now re-generate the 4 IV (Values for X, A, C, M) out of the Random-IV using a Password-Based Random Initialisation Vector Function (PRND_IV). This will put the modified LCG (mLCG) into it‘s internal State for creating the Key-Stream for Deciphering the Data-Stream.
(** d4)
//
Perform the XOR-Decryption of the Cipher-Stream with the Key-Stream using the formerly under (** d3) re-created 4 IV (Values X, A, C, M) with the modified LCG (mLCG) until the End of the Cipher-Stream has been reached and regain the Data-Stream.
A full functional Example of the Encryption Algorithm (SEA1m5) including Source-Code in JavaScript is available here
JavaScript Example
Cheers,
Karl-Uwe
//######################################################################
//
// Copyright (c) 2011, Karl-Uwe Frank
//
// This Software and it‘s Encryption Algorithm (SEA1m5) is released
// under the Non-Profit Open Software License 3.0 (NPOSL-3.0)
// http://www.opensource.org/licenses/NOSL3.0
//
// This Code and the Encryption Algorithm (SEA1m5) can be used freely
// for all personal, academic or non-commercial purposes.
//
// For commercial purposes please contact karl.frank [a T] freecx.co.uk
//
//######################################################################