CSCI 3341 Notes: Symmetric vs Asymmetric Cryptography (09/16/2025)

Symmetric vs Asymmetric Cryptography

  • Hashing is strictly NOT encryption/decryption because:

    • (a) Encryption/Decryption requires keys.

    • (b) Hashing is a one-way data transformation, while encryption/decryption involve two-way data transformation.

  • Examples of operations:

    • Encrypt data (key1) -> ciphertext

    • Decrypt ciphertext (key2) -> data

    • Decrypt key2 (Encrypt key1 (data)) -> data

  • If key1 and key2 are the same, the cryptography is:

    • Symmetric Cryptography (or Symmetric Encryption/Decryption)

    • Also known as Shared Key Encryption/Decryption because the encryptor and the decryptor must pre-share the key.

    • Note: A prerequisite of using a symmetric cryptographical algorithm is that the key must be pre-shared.

  • If key1 and key2 are inverse keys, it is called Asymmetric Cryptography (aka Public Key Crypto).

    • Usually one of the two keys is the private key and the other is the public key.

    • Assumptions:

    • (i) The public key is considered publicly available.

    • (ii) The private key is only known by the owner of the keypair.

  • Mary’s keypair scenario:

    • (a) Decrypt Mary’s public key (Encrypt Mary’s private key (data)) -> data

    • Example use: digital signature generation and verification

    • (b) Decrypt Mary’s private key (Encrypt Mary’s public key (data)) -> data

    • Example use: confidentiality (not typical for public-key decryption of data, but shown as a paired concept)

  • A scenario: A wants to send a confidential message to B using public key cryptography.

    • Q1: What does confidentiality mean in this context?

    • The message sent by A is only accessible by B.

    • Q2: What does public key crypto mean?

    • A has A’s public key and A’s private key; B has B’s public key and B’s private key.

    • Q3: How would the protocol be designed?

    • A will use B’s public key to encrypt the message, and B can decrypt the received ciphertext using B’s private key.

    • NOTE: Use the receiver’s public key for encryption if you want confidentiality.


Public Key Cryptography: Assumptions and Protocol

  • Pre-requisites:

    • (a) A must have B’s public key;

    • (b) Both must agree to use the same public key cryptographical algorithm (e.g., RSA).

  • The protocol (Author A -> Receiver B):

    1. Create data

    2. Encrypt data using B’s public key → ciphertext

    3. Send ciphertext to B. A→B: ciphertext

    • To the left of the colon is the header, and to the right is the payload of the message.

    1. Receive the message → the message header + the payload

    2. Decrypt payload using B’s private key → data2

    • NOTE: The result of the decryption may or may not be the same as the original data.

    • That is, encryption/decryption does not guarantee data integrity.

  • Typical message header fields (example):

    • Source = "A"; Destination = "B"; Time of Creation = 02-06-2024, 12:26pm

    • ProtocolID = "SMTP"; MessageID = 3; Size of body = 2MB

    • The encryption algorithm = "RSA" …

  • Message body (payload): ciphertext

  • EX1: Combine hashing with the above protocol to provide both confidentiality and data integrity of the transmitted message.

  • Pre-requisites for EX1:

    • (a) A must have B’s public key;

    • (b) Both must agree to use the same public key cryptographical algorithm (e.g., RSA);

    • (c) A and B must agree to use the same hashing algorithm (e.g., MD5).

  • EX1 protocol steps:

    1. Create data

    2. Hash (data) to produce hash_value

    3. Encrypt data using B’s public key → ciphertext

    4. Send ciphertext + hashvalue to B. A→B: ciphertext + hashvalue

    5. Receive the message → the message header + the payload

    6. Extract from the payload the ciphertext to produce dataEncrypted

    7. Extract from the payload the hash to produce hash1

    8. Decrypt dataEncrypted using B’s private key → data2


Protocol with Integrity Check (EX1 continued) and Hashing Details

  • After decryption, perform: extHash(data2)<br>ightarrowexthash2ext{Hash}(data2) <br>ightarrow ext{hash2}

  • If exthash2=exthash1ext{hash2} = ext{hash1}, then data2data2 is correct; else abort.

  • Message header (modified):

    • Encryption algorithm = "RSA"; Hashing algorithm = "MD5"; Size of hash = 16 bytes

  • Message body (payload) contains: ciphertext + hash_value

  • EX2: Modify the above protocol so that, instead of public key encryption, A and B use symmetric encryption/decryption to provide confidentiality.

  • Q: How would we refine the above protocol to provide not only creator origin integrity but also sender origin integrity?

    • Hint: Use an anti-replay mechanism (timestamping, sequence numbers, etc.).

  • Anti-replay via timestamping:

    • The sender inserts the current timestamp into the outgoing message.

    • The receiver must examine the timestamp as early as possible; if the timestamp is too old, the message could be a replay and should be aborted.

  • EX3: Add timestamp into the above protocol to provide anti-replay.

    • Alternatively, sequencing numbers have been used (e.g., TCP).

    • The receiver maintains a window of sequence numbers (lowerBound – upperBound):

    • If the received sequence number is a duplicate, drop it.

    • If the sequence number falls outside the window, drop it.

  • Share and discuss EX2/EX3 as described above.


The CIA Triad and Security Protocols

  • The CIA Triad consists of:

    • Confidentiality (data and origin)

    • Integrity (data + origin)

    • Availability (e.g., anti-replay)

    • Anti-replay mechanisms (timestamps, sequence numbers)

  • Definition: When a protocol is called a 'security protocol', it must provide at least the above four security services.

    • Examples: IPsec, VPN, HTTPS (HTTP over SSL)

  • MACs (Message Authentication Codes):

    • Based on symmetric cryptography and a keyed hashing algorithm.

  • Pre-requisites for MACs:

    • (i) Both sides have set up a pre-shared key (psk);

    • (ii) Both sides must use the same MAC algorithm (e.g., HMAC).

  • Scenario: A has a file f and wants to share it with teammates R (represented in the protocol).

    • Goal: Provide both data integrity and origin integrity.

  • MAC-based protocol (Author A → Retriever R):

    1. Create data

    2. MAC(psk, data) → macCode

    3. Save data and macCode to the file f

    4. Retrieve the file → file header + file body

    5. Extract Author’s name from the file header → "A"

    6. Extract the shared key with this author → psk

    7. Extract data2 from the file body

    8. Extract macCode2 from the file body

    9. MAC(psk, data2) → macCode3

    10. If macCode3 = macCode2, then:

      • (i) data2 is the same as the original data (data integrity)

      • (ii) data2 and macCode2 were produced by A (Author Origin Integrity)

  • Note: This protocol provides NO sender origin integrity. Else, abort. // Don’t trust the received data.


File Header and File Body: Practical Structure

  • File f contains both the file header and the file body.

  • File header (meta-data) contains:

    • Author = "A" // origin information

    • Time of Creation = 02-06-2024, 12:26pm

    • File type = "TEXT"

    • Size of body = 2MB

    • MAC algorithm = "HMAC"

    • Size of the MAC = 20 bytes

  • File body contains: data + macCode


Summary of Key Concepts (Glueing ideas together)

  • Hashing vs encryption: Hashing is one-way; encryption is reversible with the proper key.

  • Symmetric vs asymmetric: Symmetric uses a pre-shared key; asymmetric uses a key pair (public/private).

  • Digital signatures (implicit in some examples) involve using a private key to sign data and a public key to verify.

  • Integrity vs origin integrity: MACs can verify data integrity and that the data comes from a party who shares the key, but not non-repudiation (sender origin integrity).

  • Anti-replay and freshness: Timestamps and sequence numbers help prevent replay attacks and ensure message freshness.

  • Real-world parallels: VPNs, IPsec, and HTTPS rely on these basic primitives to provide confidentiality, integrity, and availability.

  • Formulas and key relationships:

    • Hash: exthash=H(extdata)ext{hash} = H( ext{data})

    • MAC: extMAC=extHMACK(extdata)ext{MAC} = ext{HMAC}_{K}( ext{data})

    • RSA encryption/decryption (conceptual): extciphertext=extRSA<em>e(extdata)ext{ciphertext} = ext{RSA}<em>{e}( ext{data} ), extdata=extRSA</em>d(extciphertext)ext{data} = ext{RSA}</em>{d}( ext{ciphertext} )

    • MD5 output size: extSize(extMD5)=16extbytes ext(128bits)ext{Size}( ext{MD5}) = 16 ext{ bytes} \ ext{(128 bits)}

    • Hash length example in headers: 16 bytes

  • Terminal notes: The protocol designs in the slides emphasize the separation of confidentiality (encryption) and integrity (hashing or MAC), and the careful handling of keys and freshness to achieve secure communications.