Because of this, Cryptographic Primitive are designed to do one very specific task in a highly reliable fashion.
Commonly used Cryptographic Primitives#
- Cryptographically secure pseudorandom number generator
- Cryptographic Hash Function or one-way compression function -- compute a reduced Hash value for a message (eg. SHA-1)
- Digital Signatures - confirm the author of a Message
- Symmetric Key Cryptography - compute a Ciphertext decodable with the same key used to encode (e.g. DES)
- Asymmetric Key Cryptography - compute a Ciphertext decodable with a different key used to encode (e.g. RSA)
Beginning with the same seed will always lead to the same stream of numbers, but what's important is that the stream of numbers descended from the seed do not exhibit any pattern. In the Linux kernel, /dev/random and /dev/urandom, operate in this fashion: they gather entropy from multiple sources, process it to remove biases, create a seed, and can then provide the random numbers used to generate an RSA key for example.Cryptographic Hash Function is meant to take an input (Message) of arbitrary size and produce a usually a fixed size output (Message-Digest). If we can find any two messages that create the same Message-Digest, that's a Cryptographic Collision and makes the Hash Function unsuitable for cryptography. Note the emphasis on "find"; if we have an infinite world of messages and a fixed size output, there are bound to be collisions, but if we can find any two messages that collide without a monumental investment of computational resources, that's a deal-breaker. Worse still would be if we could take a specific message and could then find another message that results in a collision.
As well, the Cryptographic Hash Function should be One-Way Hash Function: given a Message-Digest, it should be computationally infeasible to determine what the message is. Respectively, these requirements are called Collision Resistance Second Preimage Resistance, and Preimage Resistance. If we meet these requirements, our Message-Digest acts as a kind of fingerprint for a message. No two people (in theory) have the same fingerprints, and you can't take a fingerprint and turn it back into a person.Hashes sound great, but what good is sending a Message-Digest with a message if someone can tamper with your message and then tamper with the Message-Digest too? (Integrity)
We need to mix hashing in with the ciphers we have. For Symmetric Key ciphers, we have Message Authentication Codes (MACs). Message Authentication Codes come in different forms, but an HMAC is based on hashing. An HMAC takes the key K and the message M and blends them together using a Cryptographic Hash Function H with the formula H(K + H(K + M)) where "+" is concatenation.
Why this formula specifically? That's beyond this article, but it has to do with protecting the integrity of the HMAC itself. The Message Authentication Code is sent along with an encrypted message. Eve could blindly manipulate the message, but as soon as Bob independently calculates the Message Authentication Code and compares it to the Message Authentication Code he received, he'll realize the message has been tampered with.
More Information#There might be more information for this subject on one of the following:
- Block Cipher
- Cipher Block Chaining
- Cipher Suite
- Computational Hardness Assumption
- Cryptographically Weak
- Encryption Scheme
- Information-theoretic Secure
- Initialization Vector
- Key size
- Mask Generation Function
- Pseudorandom function
- Side-channel attacks
- Signature Primitive
- Verification Primitive