Notes (MS Word) - SWC

advertisement
When we send messages from person to person, or computer to computer, we often don't want anyone
else seeing their contents. So, we would like to transform the information of a message in such a way
that a person seeing just the transformed information (and not knowing what transformation was used)
will find it prohibitively difficult to determine what the message originally said. Of course, the
information does need to be preserved so that the intended recipient can perform the reverse
transformation and see the original message.
Terminology:
Cryptography: The field of study and practical effort regarding secret messages.
Encrypt: To transform data into a new form, preserving all the information but making it more difficult
for someone looking at the data to figure out what it means. Data that has been put into this form is
called 'encrypted', and the process of transforming the data is called 'encryption'. Sometimes, the entire
field may also referred to as 'encryption'.
Decrypt: To transform encrypted data into its original form, restoring the intended message. The
restored message is called 'decrypted', and the process of transforming the encrypted data back is called
'decryption'.
Cipher: Any encryption scheme that works by changing the actual data of the original message, so that a
similar amount of information is sent but it looks nothing like the original message (at least until it has
been decrypted).
Steganography: Encryption schemes that work by putting the original message (unchanged) into a much
larger quantity of arbitrary data, so that a much larger amount of information is sent and it is not
obvious which parts are meaningful. The information is essentially 'hidden in plain sight'.
Of course, ciphers and steganography can be used together. However, ciphers are better suited to large
amounts of information because they have little to no extra data overhead, whereas steganography is
better suited to small amounts of information because it adds a lot of extra data.
Encryption algorithm: An algorithm that encrypts information. Often it is assumed that an encryption
algorithm also comes with its corresponding decryption algorithm.
Key: Some encryption algorithms make use of a 'key', which is a (usually small) string of data used to
determine how the original information will be encrypted and decrypted. The idea is that decrypting the
message with the wrong key will just give meaningless data, so even if an eavesdropper has the right
algorithm on hand, they also need to know the right key in order to figure out what the message says.
Symmetric key encryption: Encryption schemes where both the sender and the intended recipient use
the same key (the one for encryption, the other for decryption).
Public key encryption: Encryption schemes where the sender keeps a 'private key' and tells everyone a
corresponding 'public key', where the private key and public key are chosen such that information
encrypted with either one can be decrypted with the other, but it is difficult for someone with only one
key to guess the other one.
Block chaining: Encryption techniques where earlier parts of the message (whether the original or
encrypted versions, or both) are used to help determine how later parts of the message will be
encrypted. This tends to make it harder for an eavesdropper to figure out what any one part of the
message is supposed to say.
For the pseudocode algorithms presented today, we will assume that only english capital letters A - Z are
encrypted and decrypted, with punctuation, numerals, etc being entirely incidental to the algorithms.
However, most of the techniques presented today also work more generally, after being tweaked the
right way (you can find examples in my C code).
We will also assume that the letters A - Z are equivalent to integer values 0 - 25.
Rotation Cipher:
Rotate letter, given letter original_letter and integer value distance:
{
Return (((original_letter+distance) mod 26)+26) mod 26.
}
Rotation cipher encrypt, given string original_string and integer value
distance:
{
Set encrypted_string to "" (an empty string).
Set length to the length of original_string.
Set next_index to 1.
While next_index<=length:
{
Set next_oletter to original_string[next_index].
Set next_eletter to the value returned by rotate letter, given
next_oletter and distance.
Append next_eletter to encrypted_string.
Add 1 to next_index.
}
Return encrypted_string.
}
Rotation cipher decrypt, given string original_string and integer value
distance:
{
Return the value returned by rotation cipher encrypt, given
original_string and 0-distance.
}
Rotation cipher with "TINKER TAILOR SOLDIER HACKER" and 0 gives:
"TINKER TAILOR SOLDIER HACKER"
Rotation cipher with "TINKER TAILOR SOLDIER HACKER" and 11 gives:
"ETYVPC ELTWZC DZWOTPC SLNVPC"
Block Chaining:
As mentioned in the first TXT file, block chaining is when an algorithm uses earlier parts of the message
(whether the original or encrypted versions, or both) to help determine how later parts of the message
will be encrypted. Here's an encryption algorithm that uses block chaining:
Rotate letter, given letter original_letter and integer value distance:
{
Return (((original_letter+distance) mod 26)+26) mod 26.
}
BC cipher encrypt, given string original_string and integer value key:
{
Set encrypted_string to "" (an empty string).
Set length to the length of original_string.
Set next_index to 1.
Set chain_value to key.
While next_index<=length:
{
Set next_oletter to original_string[next_index].
Set next_eletter to the value returned by rotate letter, given
next_oletter and chain_value.
Set chain_value to (((chain_value+next_oletter)*key)+next_eletter) mod
676.
Append next_eletter to encrypted_string.
Add 1 to next_index.
}
Return encrypted_string.
}
BC cipher decrypt, given string encrypted_string and integer value key:
{
Set decrypted_string to "" (an empty string).
Set length to the length of encrypted_string.
Set next_index to 1.
Set chain_value to key.
While next_index<=length:
{
Set next_eletter to encrypted_string[next_index].
Set next_dletter to the value returned by rotate letter, given
next_eletter and 0-chain_value.
Set chain_value to (((chain_value+next_dletter)*key)+next_eletter) mod
676.
Append next_dletter to decrypted_string.
Add 1 to next_index.
}
Return decrypted_string.
}
BC cipher with "TINKER TAILOR SOLDIER HACKER" and 0 gives:
"TBOYCT MMUFTK CQBEMQH OOQAEV"
BC cipher with "TINKER TAILOR SOLDIER HACKER" and 69105 gives:
"QGBIOP PWQFEJ AOJLMGF XGQEWZ"
Download