Back to the topic

The mark scheme starts on a new page, so you can print pages one and two for a student and keep the last page yourself. Everything prints in black on white whichever theme you are using.

A Level · 1.3.1

Compression, Encryption and Hashing

Section A: 10 multiple choice questions, 10 marks. Section B: 5 written questions, 21 marks. Total 31 marks.

Name

Class

Date

Mark  / 31

Section A

Circle the letter of the correct answer. One mark each.

  1. 1When can run length encoding increase the size of a file?1
    1. AWhen the file is text
    2. BWhen there are very few runs of identical consecutive values
    3. CWhen the file is very large
    4. DIt never increases size
  2. 2What problem does asymmetric encryption solve?1
    1. AData compression
    2. BKey distribution, since the public key can be shared openly
    3. CSlow encryption of large files
    4. DPassword storage
  3. 3Why does HTTPS use both symmetric and asymmetric encryption?1
    1. AFor legal reasons
    2. BTo make the connection slower and safer
    3. CAsymmetric is used for images and symmetric for text
    4. DAsymmetric securely exchanges a session key, then fast symmetric encryption carries the data
  4. 4What is the avalanche effect?1
    1. AEncryption keys expire
    2. BCollisions increase with file size
    3. CA tiny change to the input produces a completely different hash
    4. DHash values gradually become longer
  5. 5Why are passwords stored as salted hashes?1
    1. AIt makes login faster
    2. BA stolen database does not reveal passwords, and identical passwords hash differently
    3. CIt compresses the database
    4. DIt encrypts the whole database
  6. 6A digital signature is created by:1
    1. ACompressing the message
    2. BEncrypting the message with the recipient's public key
    3. CHashing the recipient's public key
    4. DEncrypting a hash of the message with the sender's private key
  7. 7Which compression method replaces repeated sequences with index references?1
    1. ARun length encoding
    2. BLossy compression
    3. CDictionary encoding
    4. DHashing
  8. 8What is a hash collision?1
    1. ATwo different inputs producing the same hash value
    2. BA hash that cannot be computed
    3. CA hash longer than its input
    4. DTwo identical inputs
  9. 9Which key encrypts a message so that only the intended recipient can read it?1
    1. AThe recipient's private key
    2. BThe sender's private key
    3. CThe sender's public key
    4. DThe recipient's public key
  10. 10What is the main disadvantage of symmetric encryption?1
    1. AThe key must be transmitted securely to the recipient
    2. BIt cannot handle large files
    3. CIt requires a certificate authority
    4. DIt is very slow

Section B

Answer in the space provided. The number of marks tells you how many separate points to make.

  1. 1ExplainExplain how run length encoding compresses data and state one type of data for which it is unsuitable.4
  2. 2ExplainExplain the difference between symmetric and asymmetric encryption.4
  3. 3DescribeDescribe how a digital signature is created and used to verify a message.5
  4. 4ExplainExplain why passwords should be stored as salted hashes rather than as encrypted values.5
  5. 5ExplainExplain why lossless compression must be used for a program file.3

Mark scheme

Section A

1B2B3D4C5B6D7C8A9D10A

Section B

1 Explain how run length encoding compresses data and state one type of data for which it is unsuitable. 4

One mark for each of the following, to a maximum of 4.

  • Runs of identical consecutive values are replaced by the value and a count
  • Gives a valid example of the encoding
  • It is lossless, so the original is restored exactly
  • It is unsuitable for data with few runs, such as a photograph, where it may increase size

Model answer. Run length encoding works by scanning the data for runs of identical consecutive values and replacing each run with a single copy of the value together with a count of how many times it repeated, so a sequence of five As followed by three Bs is stored as 5A3B. It is lossless, because the count contains everything needed to reconstruct the original sequence exactly. It is unsuitable for data that contains few runs of identical adjacent values, such as a photograph, where neighbouring pixels almost always differ slightly. In that case almost every value would be stored with a count of one, so the encoded file would actually be larger than the original.

2 Explain the difference between symmetric and asymmetric encryption. 4

One mark for each of the following, to a maximum of 4.

  • Symmetric uses the same key to encrypt and decrypt
  • Asymmetric uses a public key to encrypt and a matching private key to decrypt
  • Symmetric is faster but the key must be distributed securely
  • Asymmetric solves key distribution because the public key can be shared openly, but it is slower

Model answer. Symmetric encryption uses a single shared key for both encryption and decryption, so both parties must possess the same secret. Asymmetric encryption uses a mathematically related pair of keys: a public key that may be distributed openly and a private key that is never shared, where data encrypted with the public key can only be decrypted with the private one. The practical difference is a trade off between speed and key distribution. Symmetric encryption is considerably faster and therefore suited to encrypting large volumes of data, but it requires the key itself to be transmitted to the recipient by some secure means, and if that transmission is intercepted the encryption is worthless. Asymmetric encryption removes that problem entirely, since the public key can be published without compromising anything, but it is significantly slower, which is why real systems use asymmetric encryption to exchange a symmetric session key and then use that faster symmetric key for the actual data.

3 Describe how a digital signature is created and used to verify a message. 5

One mark for each of the following, to a maximum of 5.

  • A hash of the message is calculated
  • The hash is encrypted with the sender's private key to form the signature
  • The recipient decrypts the signature using the sender's public key
  • The recipient independently hashes the received message
  • If the two hashes match, the message is unaltered and came from the private key holder

Model answer. To create a digital signature, the sender first passes the message through a hash function to produce a fixed size digest. That digest is then encrypted using the sender's private key, and the result is attached to the message as the signature. To verify it, the recipient decrypts the signature using the sender's public key, which recovers the original hash value, and separately calculates the hash of the message they actually received using the same hash function. If the two hashes are identical then two things are proven at once: the message has not been altered in transit, since any change would produce a completely different hash because of the avalanche effect, and it genuinely came from the holder of the private key, since no one else could have produced a signature that decrypts correctly with that public key.

4 Explain why passwords should be stored as salted hashes rather than as encrypted values. 5

One mark for each of the following, to a maximum of 5.

  • Hashing is a one way function that cannot be reversed
  • Encryption is reversible, so an attacker who obtains the key recovers every password
  • Login works by hashing the entered password and comparing the hashes
  • A salt is a random value added before hashing
  • The salt ensures identical passwords hash differently and defeats precomputed rainbow tables

Model answer. Hashing is a one way function: it is computationally infeasible to recover the original input from the hash, so an attacker who steals the database obtains only hashes and not the passwords themselves. Encryption, by contrast, is reversible by design, which means the system must hold a decryption key somewhere, and an attacker who obtains both the database and that key recovers every password in plain text at once. Authentication does not require the original password to be recoverable: when a user logs in, the system hashes what they typed and compares the result with the stored hash, and a match proves they supplied the right password. Salting adds a random value, unique to each user, to the password before it is hashed, and that salt is stored alongside the hash. This matters because without it two users who chose the same password would produce identical hashes, which is visible information, and an attacker could use a precomputed rainbow table mapping common passwords to their hashes to crack thousands of accounts instantly. With a unique salt per user, every hash is different even for identical passwords, precomputed tables are useless, and the attacker must mount a separate brute force attack against each account individually.

5 Explain why lossless compression must be used for a program file. 3

One mark for each of the following, to a maximum of 3.

  • Every byte of a program file is a meaningful instruction or data value
  • Lossy compression permanently discards data
  • Removing any part would corrupt the program so it would not run correctly

Model answer. A program file consists entirely of machine instructions and the data they operate on, and every single byte is significant, since there is no redundant detail that a human observer would fail to notice. Lossy compression achieves its size reduction precisely by permanently discarding information judged to be imperceptible, which is a reasonable trade for an image or a piece of audio but is meaningless for executable code. Discarding any portion of a program would corrupt the instruction stream, so the program would either fail to start, crash during execution or, worse, run while behaving incorrectly. Lossless compression must therefore be used, since it reduces the file size by encoding the same information more efficiently and restores it byte for byte on decompression.