R&D: TripleCrypt "Blender" cipher - glenw921/TripleCrypt GitHub Wiki
Create a JavaScript function library, to be named TCBlender.js, with these utilities:
- Cipher()
- OVERVIEW: This function applies multiple sequences of scrambling, substitution, and compression, to combat deciphering techniques such as frequency analysis.
- INPUT: Plain Text to be ciphered.
- OUTPUT: Ciphered Text and Cipher Key (a code that captures the sequence of cipher actions taken such that the actions can be reversed in order).
- Substitution:
- Create a substitution dictionary and RANDOMLY (a character can be assigned itself) assign a substitution character for each plain text character.
- Common English letter combinations should be replaced with a single character. ("th", "ea", "ie", etc.)
- Hi frequency characters should have multiple substitutions to reduce their frequency.
- Low frequency characters will be hidden by a matching number of randomly placed chaff characters which have no meaning.
- Ideally, there should be only a small difference between the counts of the most common and least common characters.
- Characters which appear only once could be assigned a unique combination of the more common characters. This kind of substitution would need to be perform last when ciphering and first when deciphering during each Substitution related action.
- Scrambling:
- (a) Divide working text into an even number of segments consisting of X characters. Randomly select and merge the segments together so that their characters interleave. (Perhaps use a special chaff character if the working text cannot be evenly divided. Such a characters cannot be pre-existing in the working text nor used for any other operation, since all instances will need to be deleted when reversing this scramble.)
- (b) Divide the working text into smallish segments of random length y, reverse the character sequence within each segment.
- (c) For some random number of times, randomly do (a) or (b).
- Compression: Run the text through a compression algorithm. This removes redundant data and patterns that attackers might try to exploit.
- Hashing: Randomly choose a segment of the working text and derive a non-reproducible hash from it. Insert this hash into the working text at a random location. Be sure to run at least one Scramble after doing this. (Will need to record location and length of hash to remove it.)
- Withholding: Randomly choose a small section of the working text and remove it. Store it in the Cipher Key. Do this only after every other kind of cipher action has been done at least once. Withhold no more than 50 characters or 5% of the current working text, whichever is less.
- ACTION SEQUENCE: Conduct the various cipher actions a random number of times and in a random sequence, but do each some minimum number of times. Record the sequence of operations so that it can all be reversed by Decipher().
- ERROR HANDLING: Fails noisily so that encryption is halted. It is essential, above all else, that a user's data be recoverable if encrypted.
- Decipher()
- INPUT: Cipher Text to be deciphered and Cipher Key (see Cipher() OUTPUT).
- OUTPUT: Plain Text.
- This function will perform reverse order cipher actions, as recorded in the Cipher Key, on Cipher Text such that Plain Text is eventually produced.
- ERROR HANDLING: Any failure should be accompanied be useful information and instructions to that user is maximally empowered to decrypt their data.
NOTE: The purpose of this cipher system is to enhance the strength of more standard encryption methods by obfuscating their outputs. It should be applied before/between/after performing other encryptions so that attackers will have difficulty determining if their attack has been successful.