Symmetric Encryption: Caesar Cipher
Symmetric encryption algorithms use the same key to encrypt and decrpyt a message
Julius Caesar used an alphabet shifted by three letters to encrypt military messages (substituting for example A for the letter D), hence ciphers of this type are often referred to as Caesar ciphers or Caesar code
Source: https://commons.wikimedia.org/wiki/File:CipherDisk2000.jpg (Public Domain)
Symmetric Encryption: ROT13
ROT13 is a type of Caesar cipher with using a latin alphabet shifted by 13
Because the latin alphabet has 26 letter a ROT13 function is its own inverse
PHP has the function str_rot13()
implementing the algorithm
… or you use the shell command tr
:
Symmetric Encryption: Security
- Key and Message must have the same length
- the key must be random
- the key must never be used more than once
Symmetric Encryption: Insecurity
- During World War Two the Germans used a machine to eliminate human error when generating random keys …
… only the British at Bletchley Park were able to not only decrypt the messages, but also identify the exact model of the machine used - During the Cold War the Soviet Union used One-Time Pads…
…more than once — and the practice of the NSA to archive all intercepted encrpyted communication (especially messages that they could not decipher) paid off - In the 1980s the Fleet Broadcast System of the US Navy used the same key on every station…
…this helped with easier key distribution, but the entire system was breached when the Soviet Union got hold of the keys of the Alameda Naval Air station through bribery
One central problem of symmetric key encryption is the Key Distribution Problem:
- it is necessary to have the same key on the side of the sender and the recipient
- getting the key to the other side securely is crucial …
- …and also often the point of failure
Public/Private-Key Encryption
The answer to the key distribution problem was published fairly recently in the 1970s…
… although it is now known that intelligence agencies seem to have had this knowledge earlier.
Public/Private-Key Encryption is also called Asymmetric Encryption, because a pair of keys is used where one key cannot be easily derived from the other
What's next? - Encrypt a symmetric password asymmetrically
Process
- Generate a long symmetric password and a random seed
- Encrypt data with symmetric password and seed
- Encrypt symmetric password and seed with public key
- Store encrypted data and encrypted password/seed
Benefits
- Every blob of data is encrypted with a one-time password
- Big data can be encrypted with a symmetric key faster than asymmetrically
- Data can only be decrypted by possessing private key
- Symmetric password may be re-encrypted with a different public key, effectively granting access for a different entity.
What's next? - Stateless authentication without username/password
Process
- Client sends fingerprint and signed random string with every request
- 1st Level of security: Server searches for public key in it's database by fingerprint and returns only data having a connection with the fingerprint
- 2nd Level of security: Server validates signature and denies invalid signatures
Benefits
- Only data available for fingerprint may be sent back to client
- Even if a valid fingerprint is guessed, data is still encrypted
- No username/password required, No bearer token or oauth ...
- TLS network level encryption is not required, MITM proxies still won't see data
Drawbacks
- Private Key must be present on client machine to decrypt data
- Mitigation: Create key per machine and grant access, use Hardware Token implementation ...