Version 8
17th August 2023
Cryptography can help to keep your private correspondence private – from state surveillance, commercial harvesting of personal details, fraudsters seeking potential victims or just plain nosy parkers. It does this by encrypting readable plaintext, that you wish to keep secret, into ciphertext gibberish that only the recipients you choose can decrypt and understand.
It is not new – during Julius Cæsar’s military campaign in ancient Gaul, he used a simple cipher to keep his plans secret. But it has grown in importance since Cæsar’s time, due to modern means of communication and increasing security threats. Mathematical methods and powerful computers have come to the aid of both code-makers and code-breakers. Once the preserve of governments and the military, it is now available to businesses and the public.
This paper sets out the basic principles of modern Public Key Cryptography, with a brief account of how it got here and suggestions of where it may be going. The companion paper Pros and Cons of Cryptography summarises the benefits, drawbacks and costs; Implementing Cryptography deals with practical details of choice of software and management of cryptographic keys; and there is a Glossary.
A typical cryptographic system includes:
Historically, cryptographic systems would decrypt a message by using the same key that had been used for encrypting it, which is known as a symmetric key. Up until the 1970s, symmetric key cryptography was the only kind available. It is fast and secure, and may be used on its own or as a component of larger systems.
Present-day symmetric key cryptography uses modern digital methods such as AES. They provide algorithms that can:
where the same key, K, is used for both functions.
Symmetric key cryptography could provide a lightweight cryptosystem to a small group of users. The keys used by group members would be organised so that:
Communication within the group would be secure against outsiders, but not against insiders unless all members take care of their keys and observe the rules. Another shortcoming is that the scheme does not provide digital signatures or signature verification. The risks can be avoided by using public key cryptography.
The need for privacy of communication, and later for authentication of messages and of correspondents, expanded beyond the traditional fields of commercial, intelligence and diplomatic communications. It was boosted by the two World Wars and later the Cold War against the Soviet Union, that demanded speedy decoding of enemy signals traffic and security of allied communications. Mathematicians, scientists and engineers made good progress in a series of incremental developments that culminated in the Public Key Cryptosystem.
Polish mathematicians had cracked the workings of the German electro-mechanical Enigma machine in the 1930s. From 1940 onwards, Turing, Welchman and others at the Government Code & Cipher School (now the Government Communications Headquarters, GCHQ) took up the work. Early code-breaking machines such as the Bombe were superseded by the Colossus, a true electronic computer.
It is not a full Public Key Cryptosystem, but it solves the key distribution problem. It is used as a component, for example in symmetric key cryptography and in the Signal, ElGamal and Elliptic-curve protocols. Merkle‡ tried a different approach to a Public Key Cryptosystem but it was not viable on then-current hardware.
The calculation uses integer (whole number) values in modular arithmetic, where numbers are constrained to be within a range from zero up to a limit called the modulus. If the result of a computation would fall outside this range, it is brought back within range by subtracting the modulus from it (or, if negative, adding the modulus to it) a sufficient number of times.
A value called the base that, like the modulus, has been agreed between the parties beforehand, is raised to a power. Each party does this independently, choosing their own value for the power – say, a for one user and b for the other – and keeping it secret. The user-selected value continues to influence the calculation through the remaining steps, but combined with other data so that it cannot be unscrambled by an interloper or by the other party.
The parties swap numbers, so that each party now holds a number, the base raised to the power of the other party’s secret parameter, but from which they cannot retrieve that secret. They also still know their own secret. They raise the number they received from the other party to their own secret power, the result is the secret key. This is usually a very big number.
Both parties, by doing the mirror image of one another’s calculation, achieve the identical result. This is because raising the base to the power a then raising the result to the power b gives the original base, raised to the power ab; the other party, by doing the exponentiations in the reverse order, raises the original base to power ba; but the two are exactly the same. No secret information had to be transmitted over a communications link.
RSA also solved the long-standing problem of authentication. An electronic business or financial transaction needs to be backed by evidence of the grantor’s consent, just like the signature on a written agreement. Now the author of an electronic document can make a digital signature, unique to themself, that the world can see is theirs but that an impostor (even the recipient) cannot forge.
Creating and verifying such digital signatures depends on the capability of decrypting plaintext. This is explained further in criterion (4) of the Criteria for a Public Key Cryptosystem section.
A digital signature authenticates the document’s content as well as its author’s identity, showing up any deviation of the content delivered from that which the sender sent. Signature of the document can be almost instantaneous, avoiding banking delays and circulation of papers by post or in person.
A digital signature guards against a document signatory later attempting to repudiate their signature and say “I never signed that!” The proof is in the signature, signed with their key that no-one else has access to.
A Public Key Cryptosystem also simplifies key management. The user themself creates and controls their own keys and has an incentive to do it conscientiously.
The diagram below illustrates a single user’s Public Key Cryptosystem:
Each user’s device is connected to the network, via which they can communicate with one another. Each contains:
‘A function satisfying (1) – (3) of the above criteria is a “trap-door one-way function;” if it also satisfies (4) it is a “trap-door one-way permutation.” … These functions are called “one-way” because they are easy to compute in one direction but (apparently) very difficult to compute in the other direction. They are called “trap-door” functions since the inverse functions are in fact easy to compute once certain private “trap-door” information is known. A trap-door one-way function which also satisfies (4) must be a permutation: every message is the ciphertext for some other message and every ciphertext is itself a permissible message. (The mapping is “one-to-one” and “onto”). Property (4) is needed only to implement “signatures”.’ (See Rivest, Shamir and Adleman op. cit.)
We want to generate keys such that:
Keys are large numbers – usually a few hundred digits each. The keys are generated by software called a ‘pseudo-random bit generator’, which produces a stream of numbers that look random but are, in fact, deterministic; so a cunning attacker might be able to detect a pattern in the sequence and so short-circuit the trial and error process. To prevent this, it is a good idea to inject some external randomness into the process. Suggestions include timings of a noisy diode, radioactive decay or keyboard and mouse events.
Users should:
Asymmetric key methods provide algorithms that can:
As well as encrypting an electronic document to ensure its privacy, the sender can add a digital signature to authenticate it – just as a handwritten signature authenticates a hard copy document. For this purpose, public and private keys are used differently from the encryption case. In a communication from Alice to Bob:
A fake message will not pass this test. The attacker would need Alice’s private key, which they do not have, to create a convincing false signature.
Rivest, Shamir & Adleman (op. cit.) envisaged that the sender would decrypt the whole of the message and use that as the signature. In this case there would be no need to send the original text as well, as the recipient could obtain it simply by re-encrypting the signature. An alternative method is to compute a hash of the document, decrypt just the hash and send that along with the document, which must now be sent in full as the recipient cannot derive it from the hash. After decrypting the document as received, the recipient computes a hash of its content, re-encrypts the hash of the sent content given in the signature, and checks that the two hashes match.
To support digital signatures and verification, the general methods must provide the algorithms:
where K is the sender’s private decryption key and K′ is the sender’s public encryption key.
The author of a confidential message signs it digitally in their own name, to identify themself as the originator. This runs the risk of Surreptitious Forwarding. If the recipient of the message sends it on to someone else, no cryptographic record is made in the message to show that this forwarding has taken place. If the onward recipient is a person not entitled to see the message, this could be a serious breach of security for which the original author may be blamed – as theirs is the only signature that appears in the message.
Public Key Cryptography is used for secure web-sites (where you see a padlock icon in your browser’s address bar), for code signing and for secure messages. The public, as well as state institutions, have been able to use it since Phil Zimmermann published the PGP (Pretty Good Privacy) program in the 1990s. After a run-in with the US Department of Justice, it became generally available.
Secure web-sites caught on rapidly, driven by e‑commerce companies’ need for secure transactions over the world-wide web. Most e-businesses now use them.
Complaints include:
A revival of consumer demand came from the world of social media. Users wanted secure communication, to keep their activities secret from snoopers or from the police or security services; they wanted it on mobile devices; and they wanted to use it as an appliance, not needing a high degree of IT skills.
To meet this demand, new cryptographic applications (see Appendix III of the Implementing Cryptography paper) were developed to make secure communication easier to use and more modern in style by combining:
Some of these applications provide robust cryptography suitable for serious business and professional users, for whom high security is a priority; others are aimed at the recreational market and provide popular add-ons but less emphasis on security.
Each application comes as part of a proprietary platform; to use it, you sign up for an account, which lets you communicate with other users of that platform. You can extend your circle of contacts by opening accounts on several platforms. This is less open than e‑mail, which let you communicate freely with anyone else, anywhere on the internet, using any e‑mail software.
Other possible drawbacks are that instant messaging lacks the quoting and threading features of e‑mail and could make document control more difficult.
Many users now own more than one device – for example desktop computer, laptop computer, tablet computer or mobile phone. They may use them in different places and at different times – for instance send an enquiry from a desktop computer at work, receive a reply by mobile phone on the train and send a follow-up query from a laptop at home. They want this conversation to be as seamless as if they were conducting it from a single device in a single place.
To do this, each device’s key store must have a copy of your own Private and Public keys and your correspondents’ Public keys. In early Public Key Cryptography, you had to propagate them manually from device to device but this was tricky. The new applications synchronise keys between devices automatically.
Forward Secrecy can protect you against leakage of commercially sensitive, compromising or embarrassing information, that you probably did not know – or had forgotten – was on your computer. The biggest risk is often from working copies of data, that computers make without your knowing as it passes through the system; tracking down and purging all such copies is next to impossible.
The cryptography software does not attempt to purge this data; instead, it keeps each item of data encrypted with its own one-off or short-term key. Once the key has expired, no-one can ever decrypt the data again.
In an online conversation with forward secrecy, the software generates a key for each successive message. Even if an attacker cracks the key for one message, previous messages remain secure.
Forward secrecy is not a water-tight guarantee of security. If the sender’s device has been infected with malicious software that can spy on the information before it has been encrypted, or the recipient’s device with software that can stash away a copy of the information after it has been decrypted, the attacker can still obtain a copy of it; and there is no way to stop the recipient taking a photograph of their screen while the information is on display.
To support these features, applications need extensions to the basic cryptography described in the Anatomy of the Public Key Cryptosystem section. You still have a key, providing decryption and encryption algorithms, but it is created automatically by the software when you sign up to the platform:
In addition, the user interface has been modernised by a method of creating and managing keys behind the scenes, more in keeping with the social media model (see Implementing Cryptography section TOFU).
Cryptography has always been at risk of keys being cracked, so making the current cryptographic protocols useless. This is a particular concern now because of the development of powerful Quantum Computers.
There is also active research into new communication techniques, that exploit the quantum characteristics of novel materials and so provide security that would be very hard for an attacker to defeat.
Richard Stonehouse
Private and public key work together according to the rules:
The private and public keys of the sender and the recipient are used as shown in the table below. Decryption, including the special case of decrypting plaintext, can only be done by the owner of the relevant private (decryption) key. Anyone can encrypt plaintext by using the relevant public (encryption) key; these keys are distributed generally. Decrypted plaintext can be re-encrypted using the public key counterpart of the private key that was used for decrypting it.
Encryption/Decryption | Signing/Verification |
---|---|
Sender Side | |
Message is written by sender and encrypted by sender using copy of recipient’s public key. | Plaintext signature is created by sender and decrypted by sender using sender’s own private key. |
Recipient Side | |
Message is decrypted by recipient using recipient’s own private key. | Plaintext signature is re-encrypted by recipient using copy of sender’s public key. |