35
Cryptography Basic Principles 1. Encryption In a simplest form, encryption is to convert the data in some unreadable form. This helps in protecting the privacy while sending the data from sender to receiver. On the receiver side, the data can be decrypted and can be brought back to its original form. The reverse of encryption is called as decryption. The concept of encryption and decryption requires some extra information for encrypting and decrypting the data. This information is known as key. There may be cases when same key can be used for both encryption and decryption while in certain cases, encryption and decryption may require different keys.

Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Cryptography Basic Principles

1. Encryption

• In a simplest form, encryption is to convert the data in some unreadable form. This helps in protecting the privacy while sending the data from sender to receiver. On the receiver side, the data can be decrypted and can be brought back to its original form.

• The reverse of encryption is called as decryption. The concept of encryption and decryption requires some extra information for encrypting and decrypting the data. This information is known as key.

• There may be cases when same key can be used for both encryption and decryption while in certain cases, encryption and decryption may require different keys.

Page 2: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

2. Authentication

• This is another important principle of cryptography. In a layman’s term, authentication ensures that the message was originated from the originator claimed in the message.

• Now, one may think how to make it possible? Suppose, Alice sends a message to Bob and now Bob wants proof that the message has been indeed sent by Alice.

• This can be made possible if Alice performs some action on message that Bob knows only Alice can do. Well, this forms the basic fundamental of Authentication.

Page 3: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

3. Integrity

• Now, one problem that a communication system can face is the loss of integrity of messages being sent from sender to receiver.

• This means that Cryptography should ensure that the messages that are received by the receiver are not altered anywhere on the communication path.

• This can be achieved by using the concept of cryptographic hash.

Page 4: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

4. Non Repudiation

• What happens if Alice sends a message to Bob but denies that she has actually sent the message?

• Cases like these may happen and cryptography should prevent the originator or sender to act this way.

• One popular way to achieve this is through the use of digital signatures.

Page 5: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Three types of cryptography techniques

• Secret key Cryptography (Symmetric), Public key cryptography (Asymmetric), Hash Functions

• Secret Key Cryptography uses just a single key. The sender applies a key to encrypt a message while the receiver applies the same key to decrypt the message. Since only single key is used so we say that this is a symmetric encryption

• Problem with this technique is the distribution of key.

Page 6: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Public Key Cryptography

• Uses two key crypto system in which a secure communication can take place between receiver and sender over insecure communication channel. Since a pair of keys is applied here so this technique is also known as asymmetric encryption.

• In this method, each party has a private key and a public key. The private is secret and is not revealed while the public key is shared with all those whom you want to communicate with. If Alice wants to send a message to bob, then Alice will encrypt it with Bob’s public key and Bob can decrypt the message with its private key.

Page 7: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Hash Functions• Not an key. Rather it uses a fixed length hash

value that is computed on the basis of the plain text message. Hash functions are used to check the integrity of the message to ensure that the message has not be altered, compromised or affected by virus.

Page 8: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Types of Encryption

Page 9: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Encryption and Decryption• Encryption is the process of transforming information so it is unintelligible

to anyone but the intended recipient. Decryption is the process of transforming encrypted information so that it is intelligible again.

• A cryptographic algorithm, also called a cipher, is a mathematical function used for encryption or decryption. In most cases, two related functions are employed, one for encryption and the other for decryption.

• With most modern cryptography, the ability to keep encrypted information secret is based not on the cryptographic algorithm, which is widely known, but on a number called a key that must be used with the algorithm to produce an encrypted result or to decrypt previously encrypted information.

• Decryption with the correct key is simple. Decryption without the correct key is very difficult, and in some cases impossible for all practical purposes.

Page 10: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Symmetric-Key EncryptionWith symmetric-key encryption, the encryption key can be calculated from the decryption key and vice versa. With most symmetric algorithms, the same key is used for both encryption and decryption

Page 11: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

symmetric-key encryption • Efficient: users do not experience any significant time delay as a result of

the encryption and decryption. It also provides a degree of authentication, since information encrypted with one symmetric key cannot be decrypted with any other symmetric key. Thus, as long as the key is kept secret by the two parties, each party can be sure that it is communicating with the other as long as the decrypted messages continue to make sense.

• Effective only if the symmetric key is kept secret by the two parties involved. If anyone else discovers the key, it affects both confidentiality and authentication. A person with an unauthorized symmetric key not only can decrypt messages sent with that key, but can encrypt new messages and send them as if they came from one of the two parties who were originally using the key.

• Symmetric-key encryption plays an important role in the SSL protocol, which is widely used for authentication, tamper detection, and encryption over TCP/IP networks.

Page 12: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Public-Key Encryption• The most commonly used implementations of public-key encryption are

based on algorithms patented by RSA Data Security. Therefore, this section describes the RSA approach to public-key encryption.

• Public-key encryption (also called asymmetric encryption) involves a pair of keys - a public key and a private key - associated with an entity that needs to authenticate its identity electronically or to sign or encrypt data.

• Each public key is published, and the corresponding private key is kept secret Data encrypted with your public key can be decrypted only with your private key.

Page 13: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• You can freely distribute a public key, and only you will be able to read data encrypted using this key. To send encrypted data to someone, you encrypt the data with that person's public key, and the person receiving the encrypted data decrypts it with the corresponding private key.

• Compared with symmetric-key encryption, public-key encryption requires more computation and is therefore not always appropriate for large amounts of data. However, it's possible to use public-key encryption to send a symmetric key, which can then be used to encrypt additional data. This is the approach used by the SSL protocol.

Page 14: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Public Key and Private Keys

• The Public and Private key pair comprise of two uniquely related cryptographic keys (basically long random numbers). The Public Key is - Public. It is made available to everyone via a publicly accessible repository or directory.

• On the other hand, the Private Key must remain confidential to its respective owner.

• Because the key pair is mathematically related, whatever is encrypted with a Public Key may only be decrypted by its corresponding Private Key and vice versa.

Page 15: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• For example, if Bob wants to send sensitive data to Alice, and wants to be sure that only Alice may be able to read it, he will encrypt the data with Alice's Public Key. Only Alice has access to her corresponding Private Key and as a result is the only person with the capability of decrypting the encrypted data back into its original form.

• As only Alice has access to her Private Key, only Alice can decrypt the encrypted data. Even if someone else gains access to the encrypted data, it will remain confidential as they should not have access to Alice's Private Key.

• Public Key Cryptography can achieve Confidentiality. Another important aspect of Public Key Cryptography is its ability to create a Digital Signature.

Page 16: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Data encrypted with your private key can be decrypted only with your public key. This would not be a desirable way to encrypt sensitive data, however, because it means that anyone with your public key, which is by definition published, could decrypt the data.

• Nevertheless, private-key encryption is useful, because it means you can use your private key to sign data with your digital signature-an important requirement for electronic commerce and other commercial applications of cryptography.

• Client software such as Firefox can then use your public key to confirm that the message was signed with your private key and that it hasn't been tampered with since being signed

Page 17: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Digital Signatures• Digital Signatures apply the same functionality to an e-mail message or data file

that a handwritten signature does for a paper-based document. The Digital Signature vouches for the origin and integrity of a message, document or other data file.

• How do we create a Digital Signature?

Page 18: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

1. Alice clicks 'sign' in her email application or selects which file is to be signed.

2. Alice's computer calculates the 'hash' (the message is applied to a publicly known mathematical hashing function that coverts the message into a long number referred to as the hash).

3. The hash is encrypted with Alice's Private Key (in this case it is known as the Signing Key) to create the Digital Signature.

4. The original message and its Digital Signature are transmitted to Bob.

Page 19: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

5. Bob receives the signed message. It is identified as being signed, so his email application knows which actions need to be performed to verify it.

6. Bob's computer decrypts the Digital Signature using Alice's Public Key.

7. Bob's computer also calculates the hash of the original message (remember - the mathematical function used by Alice to do this is publicly known).

8. Bob's computer compares the hashes it has computed from the received message with the now decrypted hash received with Alice's message.

Page 20: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• If the message has remained integral during its transit (i.e. it has not been tampered with), when compared the two hashes will be identical.

• However, if the two hashes differ when compared then the integrity of the original message has been compromised. If the original message is tampered with it will result in Bob's computer calculating a different hash value.

• If a different hash value is created, then the original message will have been altered. As a result the verification of the Digital Signature will fail and Bob will be informed.

Page 21: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Trent, who wants to impersonate Alice, cannot generate the same signature as Alice because she does not have Alice's Private Key (needed to sign the message digest). If instead, Trent decides to alter the content of the message while in transit, the tampered message will create a different message digest to the original message, and Bob's computer will be able to detect that. Additionally, Alice cannot deny sending the message as it has been signed using her Private Key, thus ensuring non-repudiation.

Page 22: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Due to the recent Global adoption of Digital Signature law, Alice may now sign a transaction, message or piece of digital data, and so long as it is verified successfully it is a legally permissible means of proof that Alice has made the transaction or written the message.

Public Keys being available to everyone, the next question is how do we go about making them available to everyone in a safe, secure and scalable way? Generally speaking we use small data files known as Digital Certificate.

Page 23: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Digital Certificate• A Digital Certificate is a digital file used to cryptographically

bind an entity's Public Key to specific attributes relating to its identity. The entity may be a person, organization, web entity or software application. Like a driving license or passport binds a photograph to personal information about its holder, a Digital Certificate binds a Public Key to information about its owner.

• In other words, Alice's Digital Certificate attests to the fact that her Public Key belongs to her, and only her. As well as the Public Key, a Digital Certificate also contains personal or corporate information used to identify the Certificate holder, and as Certificates are finite, a Certificate expiry date.

Page 24: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Digital Certificates and Certification Authorities

Digital Certificates are issued by Certification Authorities (CA). Like a central trusted body is used to issue driving licenses or passports, a CA fulfils the role of the Trusted Third Party by accepting Certificate applications from entities, authenticating applications, issuing Certificates and maintaining status information about the Certificates issued.

The Trusted Third Party CAs will verify the identity of the Certificate applicant before attesting to their identity by Digitally Signing the applicant's Certificate. Because the Digital Certificate itself is now a signed data file, its authenticity can be ascertained by verifying its Digital Signature. Therefore, in the same way we verify the Digital Signature of a signed message, we can verify the authenticity of a Digital Certificate by verifying its signature.

Page 25: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Because CAs are trusted, their own Public Keys used to verify the signatures of issued Digital Certificates are publicized through many mediums widely.

Page 26: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Digital Signatures• Encryption and decryption address the problem of eavesdropping.

But encryption and decryption, by themselves, do not address the other two problems: tampering and impersonation.

• Tamper detection and related authentication techniques rely on a mathematical function called a one-way hash (also called a message digest). A one-way hash is a number of fixed length with the following characteristics:– The value of the hash is unique for the hashed data. Any change in the data,

even deleting or altering a single character, results in a different value.

– The content of the hashed data cannot, for all practical purposes, be deduced from the hash-which is why it is called "one-way”

Page 27: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• Key pair is generated for digital signing which consists of a private signing key and a public verification key.

• The public key is widely distributed, while the private key is known only to its proprietor.

• The keys are related mathematically, but the parameters are chosen so that calculating the private key from the public key is either impossible or prohibitively expensive.

• The encrypted hash, along with other information, such as the hashing

algorithm, is known as a digital signature.

Page 28: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• The original data and the digital signature, which is basically a one-way hash (of the original data) that has been encrypted with the signer's private key.

• To validate the integrity of the data, the receiving software first uses the signer's public key to decrypt the hash. It then uses the same hashing algorithm that generated the original hash to generate a new one-way hash of the same data.

• Finally, the receiving software compares the new hash against the original hash. If the two hashes match, the data has not changed since it was signed.

• If they don't match, the data may have been tampered with since it was signed, or the signature may have been created with a private key that doesn't correspond to the public key presented by the signer.

Page 29: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• If the two hashes match, the recipient can be certain that the public key used to decrypt the digital signature corresponds to the private key used to create the digital signature. Confirming the identity of the signer, however, also requires some way of confirming that the public key really belongs to a particular person or other entity. The significance of a digital signature is comparable to the significance of a handwritten signature. Once you have signed some data, it is difficult to deny doing so later-assuming that the private key has not been compromised or out of the owner's control.

• This quality of digital signatures provides a high degree of nonrepudiation - that is, digital signatures make it difficult for the signer to deny having signed the data. In some situations, a digital signature may be as legally binding as a handwritten signature.

Page 30: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Sender knows who is the receiver

• This public key is available in directories and from certificate authorities, so when the SENDER wants to encrypt a message by public key cryptography he can easily use the recipient's public key (and modulus) to do it.

• Each site's public key and modulus are almost certainly different.

• To illustrate the point for an intending recipient, let us make a simple example with the large prime numbers replaced with very small ones.

Say the two secretly held prime numbers are:

p = 5 , q = 11

Page 31: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Then the modulus of the arithmetic that will be used is given by their product:

m = 5 x 11 = 55 (the modulus of the arithmetic to use)The encryption key can be found as follows: First, using the two prime numbers, calculate the function:

f(n) = (p-1) x (q-1)∵ p = 5 and q = 11 ∴ f(n) = (5-1) x (11-1)∴ f(n) = 40then,Select ANY number that is relatively prime to f(n) and less than it.

(Two numbers are said to be relatively prime when they share no common factors other than one. This term is also referred to as mutually prime, or coprime ).

The possible choices become:3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, and 39.

Say we select the public encrypt key = 7The receiving site's PUBLIC key can then be safely given to the world as :

(7, 55) as (encryption exponent, modulus)

Page 32: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

private decrypt key(y) = (public encrypt key(x))-1 Mod f(n)

Modular multiplicative inverse function:

y*x mod f(n) =1

∵ public encrypt key = 7 , and f(n) = 40

∴ (private decrypt key x 7) Mod 40 = 1

∴ private decrypt key = 23

The Site B PRIVATE key pair is then:

(23,55) as (decryption exponent, modulus)

Page 33: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Public key Encryption Example • Encryption with B's Public Key

• Assume that the public key pair belong to a Site B and Assume a plain language character represented by the number '2' is to be encrypted by Site A and sent to the recipient Site B: Site A uses Site B's public key pair to do so.

• Assume plaintext=2

• cyphertext = plaintext public encrypt key Mod n

• ∵ public encrypt key =7, and modulus = 55

• ∴ cyphertext = 27 Mod 55 = 128 Mod 55

• ∴ cyphertext = 18

Page 34: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

• With the very small numbers used in the example the cracking of the code would be relatively simple. But for very large values of primes p and q, and without knowing the private key value, the burden becomes very difficult. In some cases the task would involve an unreasonable time even for a very large number of computers.

• Public key encryption does not disguise the relative frequency of the characters used. This is considered a failing in such systems since it improves the chances of cracking the code.

• So, the plaintext characters are arranged into groups before encryption to hide their natural frequencies of use; the groups are very large, the limit being that the size of a number encrypted must be smaller than the modulus in use.

Page 35: Cryptography Basic Principles - KSUksuweb.kennesaw.edu/~she4/2017Fall/cs4322/Slides/13...2. Authentication •This is another important principle of cryptography. In a layman’s term,

Decryption with B's Private Key• Decryption for the received cyphertext = 18

with cyphertext=18 from previous section

• Plaintext = cyphertext private decrypt key Mod n

∵ private decrypt key =23, and modulus = 55

∴ Plaintext = 1823 Mod 55 = 74347713614021927913318776832 Mod 55

∴ Plaintext = 2 (You can confirm this with the Windows scientific

calculator) which is the required result.