The words and goals of cryptography

8 min 5 sections 4 practice questions 8 sources citedISC2 objective 3.7

Cryptography scrambles information so that only the right people can read it, and so that changes and forgeries show. It works like a combination padlock: everyone can buy the same padlock, and only the combination is secret. No background is assumed. A security professional needs these words because every later choice of an encryption method, and every attack on one, is described with them.

By the end of this unit you will be able to:

  • Explain plaintext, ciphertext, cipher, key and cryptosystem in plain words
  • Calculate the size of a key space from the length of a key in bits
  • Explain Kerckhoffs's principle and why a secret algorithm is a weakness
  • Explain a brute force attack and choose the defence against it
  • Tell apart confidentiality, integrity, authentication and non-repudiation

Two products, one with a secret recipe

An illustrative example

A firm of accountants wants to encrypt the client files it sends to its two branch offices. Two suppliers answer.

The first sells a product built on its own encryption method. The method is confidential, the salesman says, and that is what makes it unbreakable. It uses a 256-bit key.

The second sells a product built on a method published by a standards body more than twenty years ago and studied by researchers ever since. It uses a 128-bit key. The office manager notes that 256 is bigger than 128 and that a secret sounds safer than something anyone can read.

Which product deserves more trust, and what is the one thing in an encryption product that has to stay secret?

Scrambling a message and getting it back

A combination padlock has two parts. The lock itself is a design that thousands of people own. The combination is a number that only the owner knows. splits its work the same way.

Plaintext
The plaintext is the information in readable form: a letter, a file, a card number.
Ciphertext
The ciphertext is the same information after scrambling. It looks like nonsense to anyone without the key.
Cipher or algorithm
A cipher, also called an algorithm, is the fixed method of scrambling and unscrambling. It is the design of the padlock.
Key
A key is a secret value fed into the with the message. A different key gives different . It is the combination. It is also called a cryptovariable.
Encrypt and decrypt
To encrypt is to turn into ciphertext. To decrypt is to turn ciphertext back into plaintext with the right key.
Cryptosystem
A cryptosystem is everything needed to do this in practice: the cipher, the keys, and the rules for creating, sharing and storing them.

Three related words name the field. Cryptography is the making of ciphers. Cryptanalysis is the breaking of them: recovering plaintext or a key without being given the key. Cryptology is the study of both.

The same idea with a child's code

A child writes HELLO as IFMMP by moving every letter one place along the alphabet. The method, moving along the alphabet, is the cipher. The number of places, one, is the key. HELLO is the plaintext and IFMMP is the ciphertext.

The key, and how many keys there are

A computer stores a key as a row of bits. A bit is one : a 0 or a 1. The key length is the number of bits in the key.

The key space is the set of every key the cipher could use. Each bit has two possible values, so a key of n bits has 2 multiplied by itself n times possible keys, written 2^n. Adding one bit doubles the key space.

Size of a key space

Number of possible keys = 2^n

n
The key length in bits.

A 3-bit key has 2 × 2 × 2 = 8 possible keys: 000, 001, 010, 011, 100, 101, 110 and 111.

Key length, key space and the time to try every key at one billion guesses a second
Key lengthPossible keysTime to try them all
3 bits8No time at all
40 bitsAbout 1.1 trillionAbout 18 minutes
56 bitsAbout 72 quadrillion (72 followed by 15 zeros)About 834 days
128 bitsAbout 3.4 followed by 38 zerosMore than a billion billion years
256 bitsAbout 1.2 followed by 77 zerosBeyond any useful figure

The work factor is the effort, in time and resources, that an attacker needs to defeat a protection. A cipher is strong enough when its is greater than the value of the secret, or longer than the secret needs to stay secret.

Common misconception

“A 128-bit key is about twice as strong as a 64-bit key.”

Each extra bit doubles the key space. A 128-bit key has 2^64 times as many possible keys as a 64-bit key, which is about 18 billion billion times as many.

Kerckhoffs's principle: only the key is secret

In 1883 Auguste Kerckhoffs set out six requirements for a military cipher. The second said that the system must not need to be secret, and must be able to fall into enemy hands without causing trouble.

Kerckhoffs's principle is the modern form of that rule: a cryptosystem should stay secure when everything about it is public except the key.

The reasoning is practical. A cipher design is copied into every product that uses it, so it leaks: staff leave, devices are taken apart. A leaked key is replaced in minutes. A leaked secret design cannot be replaced at all. A published cipher has also been attacked by researchers for years, and its weaknesses, if any, are known.

Relying on a hidden design is called security through obscurity. The ciphers in current standards, such as the Advanced Standard (AES), are fully published.

Common misconception

“An encryption method that nobody outside the supplier has seen is harder to break.”

Nobody outside the supplier has tested it either. Its strength is unknown, and its secrecy will not last. Trust a published, widely studied cipher and protect the key.

Brute force: trying every key

A thief who cannot pick a three-digit combination lock can still open it by trying 000, 001, 002 and so on. At most 1,000 tries are needed.

A brute force attack does the same to a cipher or a password: it tries every possible key, or every possible password, until one works. It needs no cleverness and it always succeeds in the end. The only question is how long it takes. On average the right key turns up after half the key space has been tried.

The Data Encryption Standard (DES), an older cipher, used a 56-bit key. The standard was withdrawn in 2005. By 2006 a purpose-built machine could search the whole DES key space in under nine days on average. AES uses keys of 128, 192 or 256 bits, which puts a brute force search out of reach.

  • Against a cipher, the defence is a longer key. Every added bit doubles the attacker's work.
  • Against a sign-in page, the defence is to slow the guessing: lock the account or add a delay after a number of failed attempts.
  • Against both, replace keys and passwords before an attacker has had time to finish.

Brute force is not a dictionary attack, which tries only likely passwords such as common words. It is also not a shortcut found by . A cipher is called broken when any attack on it needs less work than brute force.

Four things cryptography can promise

Hiding a message is only one of the jobs. Cryptography is used for four goals, and each needs its own tool.

The four goals of cryptography
GoalWhat it promisesEveryday comparisonTool
ConfidentialityOnly the intended people can read itA sealed envelopeEncryption
IntegrityAny change to it will be noticedA tamper-evident seal on a jarA or a
AuthenticationIt really comes from the person or system namedA recognised signature on a chequeA message authentication code, a or a
Non-repudiationThe sender cannot later deny having sent itA signature made in front of a witnessA digital signature

Non-repudiation means there is evidence, good enough to show a third party, that one named party created the message. It needs a key that only that party holds.

Cryptography does not provide . Encrypted data whose key has been lost is gone for good.

Common misconception

“An encrypted message cannot be altered on the way.”

Encryption hides the content. An attacker can still change or swap the ciphertext. Detecting a change is the job of an integrity check, which is a separate tool.

Worked example: How much harder is 128 bits than 56 bits?

An attacker has a machine that tries one billion keys a second. A file is encrypted once with a 56-bit key and once with a 128-bit key.

  1. 56-bit key space: 2^56 = 72,057,594,037,927,936 keys, about 72 quadrillion.
  2. Time to try them all: 72 quadrillion divided by one billion a second is about 72 million seconds, which is about 834 days.
  3. On average the key is found halfway through, after about 417 days. Ten such machines would take about six weeks.
  4. 128-bit key space: 2^128 keys, about 3.4 followed by 38 zeros.
  5. The 128-bit key is 128 − 56 = 72 bits longer, so its key space is 2^72 times larger. 2^72 is about 4.7 followed by 21 zeros.
  6. Time to try them all on the same machine: 834 days multiplied by 2^72, which is far more than a billion billion years.

The 56-bit key falls to a patient attacker with ordinary money. The 128-bit key does not fall to brute force at all, so an attacker has to look for another way in.

A question, worked through

A security manager at a firm of accountants is comparing two products for encrypting client files sent between offices. Product one uses the supplier's own confidential algorithm with a 256-bit key. Product two uses a published standard algorithm with a 128-bit key. The managing partner prefers product one because its key is longer and its method is secret.

What is the BEST advice for the security manager to give?

  1. Buy product two, because its method has been tested in public and its safety rests on the key alone
  2. Buy product one, because an attacker who cannot study the method has no way to begin an attack
  3. Buy product one, because a 256-bit key gives a far larger key space than a 128-bit key does
  4. Buy product two, because a shorter key is quicker to create and simpler to share between offices
Decide on your answer, then open the reasoning
  1. The question asks which product to trust, so it is asking what makes a cipher trustworthy.
  2. Rule out d. It picks the right product for a wrong reason: a 128-bit key is no easier to share than a 256-bit key, and ease of sharing is not what makes a cipher safe.
  3. Rule out c. Key length measures strength only when brute force is the best attack. Nobody outside the supplier has checked whether the secret method has a shortcut.
  4. Between a and b: b depends on the method staying secret. Products are taken apart and staff move on, so it will not. Kerckhoffs's principle says the design should be safe when public.
  5. Option a is the answer. A 128-bit key in a published, studied cipher is already beyond brute force.

Answer: A. Buy product two, because its method has been tested in public and its safety rests on the key alone

Choosing between good answers

One option depends on keeping an algorithm or a design secret
prefer the option that uses a published, tested algorithm and protects the key.
A question asks what makes a brute force attack harder
choose the longer key for a cipher, and lockout or delay for a sign-in page. A more complicated method is not the answer.
A question says a sender must not be able to deny sending a message
the goal is non-repudiation and the tool is a digital signature. Encryption alone does not give it.
A question asks whether a cipher is strong enough
compare the work factor with how long the data must stay secret and what it is worth.

Check your understanding

4 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.

These questions are drafts that no named reviewer has approved yet.

Question 1 of 4

A firm's contract system must hold evidence, good enough to show a court, that a named client approved each contract, so that the client cannot later deny it. Which goal of cryptography is this?

What to remember

  • A cipher is the published method and a key is the secret value. Plaintext goes in and ciphertext comes out.
  • A key of n bits has 2^n possible keys. Each extra bit doubles the key space.
  • Kerckhoffs's principle: a cryptosystem should be secure when everything except the key is public.
  • Brute force tries every key. It always works in the end, so the defence is a key long enough to make the work factor hopeless.
  • Cryptography serves confidentiality, integrity, authentication and non-repudiation. It does not provide availability.

Say it from memory

  1. What is a brute force attack, what decides how long it takes, and what defends against it?

    It tries every possible key or password until one works. The time depends on the size of the key space, which is 2^n for a key of n bits, and on the attacker's speed. On average half the keys are tried. The defences are a longer key for a cipher, and lockout or delay after failed attempts for a sign-in page.

    Read this part again

  2. How do a cipher and a key differ, and what do cryptography, cryptanalysis and cryptology each mean?

    A cipher, or algorithm, is the fixed method of scrambling and unscrambling. A key, or cryptovariable, is the secret value fed into it, and a different key gives different ciphertext. Cryptography is the making of ciphers, cryptanalysis the breaking of them, and cryptology the study of both.

    Read this part again

  3. How many keys does an n-bit key space hold, and what is the work factor?

    A key of n bits gives 2^n possible keys, so adding one bit doubles the key space. The work factor is the effort, in time and resources, an attacker needs to defeat a protection. A cipher is strong enough when its work factor is greater than the value of the secret, or longer than it must stay secret.

    Read this part again

  4. State Kerckhoffs's principle, and say why a hidden design is weaker than a published one.

    A cryptosystem should stay secure when everything about it is public except the key. A leaked key is replaced in minutes; a leaked secret design cannot be replaced at all. A published cipher has been attacked by researchers for years. Relying on a hidden design is security through obscurity.

    Read this part again

  5. Name the four goals of cryptography and the tool for each, and say which goal it does not provide.

    Confidentiality: encryption. Integrity: a hash or a message authentication code. Authentication: a message authentication code, a digital signature or a certificate. Non-repudiation: a digital signature. Cryptography does not provide availability; encrypted data whose key is lost is gone for good.

    Read this part again

Sources