C01 Secret Key Encryption
C01 Secret Key Encryption
Introduction
• Encryption is the process of encoding a message in such a way that
only authorized parties can read the content of the original message
• History of encryption dates back to 1900 BC
• Two types of encryption
• secret-key encryption : same key for encryption and decryption
• pubic-key encryption : different keys for encryption and decryption
• Result
Authenticated Encryption
• To protect the integrity, the sender needs to generate a Message
Authentication Code (MAC) from the ciphertext using a secret shared
by the sender and the receiver.
• The MAC and the ciphertext will be sent to the receiver, who will
compute a MAC from the received ciphertext.
• If the MAC is the same as the one received, the ciphertext is not
modified.
• Two operations are needed to achieve integrity of ciphertext: one for
encrypting data and other for generating MAC.
• Authenticated encryption combines these two separate operations
into one encryption mode. E.g GCM, CCM, OCB
The GCM Mode
Programming using the GCM Mode
The unique part of the above code is the tag
generation and verification.
In Line 3 , we use the digest() to get the
authentication tag, which is generated from
the ciphertext.
Programming using the GCM Mode