Hey! I'm David, a security engineer at the Blockchain team of Facebook, previously a security consultant for the Cryptography Services of NCC Group. I'm also the author of the Real World Cryptography book. This is my blog about cryptography and security and other related topics that I find interesting.
If you missed the previous blogpost on OTS, go check it out first. This is about a construction a bit more useful, that allows to sign more than one signature with the same small public-key/private-key. The final goal of this series is to see how hash-based signature schemes are built. But they are not the only applications of one-time signatures (OTS) and few-times signatures (FTS).
For completeness here's a quote of some paper about other researched applications:
One-time signatures have found applications in constructions of ordinary signature schemes [Mer87, Mer89], forward-secure signature schemes [AR00], on-line/off-line signature schemes [EGM96], and stream/multicast authentication [Roh99], among others
[...]
BiBa broadcast authentication scheme of[Per01]
But let's not waste time on these, today's topic is HORS!
The first construction, based on one-way functions, starts very similarly to OTS: generate a list of integers that will be your private key, then hash each of these integers and you will obtain your public key.
But this time to sign, you will also need a selection function \(S\) that will give you a list of index according to your message \(m\). For the moment we will make abstraction of it.
In the following example, I chose the parameters \(t = 5\) and \(k = 2\). That means that I can sign messages \(m \) whose decimal value (if interpreted as an integer) is smaller than \( \binom{t}{k} = 10 \). It also tells me that the length of my private key (and thus public key) will be of \( 5 \) while my signatures will be of length \( 2 \) (the selection function S will output 2 indexes).
Using a good selection function S (a bijective function), it is impossible to sign two messages with the same elements from the private key. But still, after two signatures it should be pretty easy to forge new ones.
The second construction is what we call the HORS signature scheme. It is based on "subset-resilitient" functions instead of one-way functions. The selection function \(S\) is also replaced by another function \(H\) that makes it infeasible to find two messages \(m_1\) and \(m_2\) such that \(H(m_2) \subseteq H(m_1)\).
More than that, if we want the scheme to be a few-times signature scheme, if the signer provides \(r\) signatures it should be infeasible to find a message \(m'\) such that \(H(m') \subseteq H(m_1) \cup \dots \cup H(m_r) \). This is actually the definition of "subset-resilient". Our selection function \(H\) is r-subset-resilient if any attacker cannot find (even with small probability), and in polynomial time, a set of \(r+1\) messages that would confirm the previous formula. From the paper this is the exact definition (but it basically mean what I just said)
so imagine the same previous scheme:
But here the selection function is not a bijection anymore, so it's hard to reverse. So knowing the signatures of a previous set of message, it's hard to know what messages would use such indexes.
This is done in theory by using a random oracle, in practice by using a hash function. This is why our scheme is called HORS for Hash to Obtain Random Subset.
If you're really curious, here's our new selection function:
On October 18th 1979, Leslie Lamport published his concept of One Time Signatures.
Most signature schemes rely in part on one-way functions, typically hash functions, for their security proofs. The beauty of Lamport scheme was that this signature was only relying on the security of these one-way functions.
here you have a very simple scheme, where \(x\) and \(y\) are both integers, and to sign a single bit:
if it's \(0\), publish \(x\)
if it's \(1\), publish \(y\)
Pretty simple right? Don't use it to sign twice obviously.
Now what happens if you want to sign multiple bits? What you could do is hash the message you want to sign (so that it has a predictible output length), for example with SHA-256.
Now you need 256 private key pairs:
and if you want to sign \(100110_2 \dots\),
you would publish \((y_0,x_1,x_2,y_3,y_4,x_5,\dots)\)
Winternitz OTS (WOTS)
A few months after Lamport's publication, Robert Winternitz of the Stanford Mathematics Department proposed to publish \(h^w(x)\) instead of publishing \(h(x)\|h(y)\).
For example you could choose \(w=16\) and publish \(h^{16}(x)\) as your public key, and \(x\) would still be your secret key. Now imagine you want to sign the binary \(1001_2\) (\(9_{10}\)), just publish \(h^9(x)\).
Another problem now is that a malicious person could see this signature and hash it to retrieve \(h^{10}(x)\) for example and thus forge a valid signature for \(1010_2\) (\(10_{10}\)).
This can be circumvented by adding a short Checksum after the message (which you would have to sign as well).
Variant of Winternitz OTS
A long long time after, in 2011, Buchmann et al published an update on Winternitz OTS and introduced a new variant using families of functions parameterized by a key. Think of a MAC.
Now your private key is a list of keys that will be use in the MAC, and the message will dictates how many times we iterate the MAC. It's a particular iteration because the previous output is replacing the key, and we always use the same public input. Let's see an example:
We have a message \(M = 1011_2 (= 11_{10})\) and let's say our variant of W-OTS works for messages in base 3 (in reality it can work for any base \(w\)). So we'll say \(M = (M_0, M_1, M_2) = (1, 0, 2)\) represents \(102_3\).
To sign this we will publish \((f_{sk_1}(x), sk_2, f^2_{sk_3}(x) = f_{f_{sk_3}(x)}(x))\)
Note that I don't talk about it here, but there is still a checksum applied to our message and that has to be signed. This is why it doesn't matter if the signature of \(M_2 = 2\) is already known in the public key.
Intuition tells me that a public key with another iteration would provide better security
Why? For the 1 bit example: The checksum would be 0. Hence, to sign that message one needs to know a preimage of a public key element. That has to be exponentially hard in the security parameter for the scheme to be secure. Requiring an attacker to be able to invert the hash function on two values or twice on the same value only adds a factor 2 to the attack complexity. That's not making the scheme significantly more secure. In terms of bit security you might gain 1 bit (At the cost of ~doubling the runtime).
Winternitz OTS+ (WOTS+)
There's not much to say about the W-OTS+ scheme. Two years after the variant, Hulsing alone published an upgrade that shorten the signatures size and increase the security of the previous scheme. It uses a chaining function in addition to the family of keyed functions. This time the key is always the same and it's the input that is fed the previous output. Also a random value (or mask) is XORed before the one-way function is applied.
Some precisions from Hulsing about shortening the signatures size:
WOTS+ reduces the signature size because you can use a hash function with shorter outputs than in the other WOTS variants at the same level of security or longer hash chains. Put differently, using the same hash function with the same output length and the same Winternitz parameter w for all variants of WOTS, WOTS+ achieves higher security than the other schemes. This is important for example if you want to use a 128 bit hash function (remember that the original WOTS requires the hash function to be collision resistant, but our 2011 proposal as well as WOTS+ only require a PRF / a second-preimage resistant hash function, respectively). In this case the original WOTS only achieves 64 bits of security which is considered insecure. Our 2011 proposal and WOTS+ achieve 128 - f(m,w) bits of security. Now the difference between WOTS-2011 and WOTS+ is that f(m,w) for WOTS-2011 is linear in w and for WOTS+ it is logarithmic in w.
Other OTS
Here ends today's blogpost! There are many more one-time signature schemes, if you are interested here's a list, some of them are even more than one-time signatures because they can be used a few times. So we can call them few-times signatures schemes (FTS):
So far their applications seems to be reduce to be the basis of Hash-based signatures that are the current advised signature scheme for post quantum usage. See PQCrypto initial recommendations that was released a few months ago.
The Merkle signature scheme is a digital signature scheme based on hash trees (also called Merkle trees) and one-time signatures such as the Lamport signature scheme. It was developed by Ralph Merkle in the late 1970s and is an alternative to traditional digital signatures such as the Digital Signature Algorithm or RSA.
Reading the SPHINCS whitepaper (a hash-based signature), we can understand a bit more why hash-based signatures were considered by PQCrypto to replace our current quantum weak signatures.
– RSA and ECC are perceived today as being small and fast, but they are broken in polynomial time by Shor’s algorithm. The polynomial is so small that scaling up to secure parameters seems impossible.
– Lattice-based signature schemes are reasonably fast and provide reasonably small signatures and keys for proposed parameters. However, their quanti- tative security levels are highly unclear. It is unsurprising for a lattice-based scheme to promise “100-bit” security for a parameter set in 2012 and to correct this promise to only “75-80 bits” in 2013. Fur- thermore, both of these promises are only against pre-quantum attacks, and it seems likely that the same parameters will be breakable in practice by quantum computers.
– Multivariate-quadratic signature schemes have extremely short signatures, are reasonably fast, and in some cases have public keys short enough for typical applications. However, the long-term security of these schemes is even less clear than the security of lattice-based schemes.
– Code-based signature schemes provide short signatures, and in some cases have been studied enough to support quantitative security conjectures. How- ever, the schemes that have attracted the most security analysis have keys of many megabytes, and would need even larger keys to be secure against quantum computers.
it's a two-track event. There are some talks about everything. From Indistinghuishability Obfuscation to Multi Parti Computation. Seems like a good place to be! I'm waiting for videos/slides/reports about the event. Will edit this post accordingly.
I'm looking at Indistinghuishability Obfuscation (iO). Which seems to be coming from Fully Homomorphic Encryption (FHE), Functional Encryption (FE) and Multilinear Maps (MM).
Watching Sanjam Garg introduction to this iO, I noticed one interesting slide that puts things into context:
2 parties key exchange in 1976 (DH)
3 parties in 2000 (Joux)
X parties in 2013 (GGH)
Video here:
EDIT:
Apparently, @Leptan is telling me that all multiparty key exchange using multilinear maps are broken as of today. Cf Cryptanalysis of GGH Map
Sometimes I read something interesting, and so I take a screenshot of it. And I know some people glance at this blog hoping to read a short piece that will provide some good knowledge. So here you go.
Taken from a Dan Bernstein's blogpost:
some history on curves
some constant-time shenanigans
The following is taken from the wikipedia's page on cryptanalysis
It is possible to repeatedly fold a standard letter-sized sheet of paper at the midway point about six to seven times. In 2012, some MIT students were able to fold an 1.2 kilometer long toilet paper 13 times. And every time the paper was folded, the number of layers on top of each other doubled. Therefore, the MIT students ended up with 2^13 = 8192 layers of paper on top of each other. And poor Eve's job was to manually count all layers one by one.
Please refer to this Wiki before asking questions that might have been asked before (use your common sense).
Cryptography is also usually more interesting than decrypting your random ciphertext, so consider that when posting, read what we are sharing first to see if it's really pertinent.
How to learn about Cryptography?
The first thing you should do, is to sign-up for Dan Boneh's course Crypto I on Coursera.
You do not have to finish it. Watching a few videos will already give you an idea of what is crypto and how easy/hard it is for you. If you can finish the course, and enjoy it at the same time, then you're in for a lot of fun.
Don't try signing-up for Crypto II though.
Alright, that was interesting, MOAR
There are many ways to learn more about crypto. Here's a non-exhaustive list:
But my favorite way: read whitepapers. Look at the ePrint archives and check what papers interest you. Often papers will come with an introduction section that explains the basics.
What about studying cryptography in a real school?
First, it's important to cultivate your new passion. Don't let your course get in the way of reading or building and doing side projects involving crypto.
Second, You need either a bachelor in mathematics or computer science. Depending on which part you find the more interesting in crypto. Usually Math => Theorical Cryptography, CS => Applied Cryptography.
Now either you don't have a master, and you could choose to do a cryptography master. There are a few: Rennes, Bordeaux, Limoges in France.Stanford, etc...
Or you can do a Computer Science or Number Theory oriented master and pick a crypto subject for a phd. Note that a phd will often lead you into theorical research in university, although some phd can be done within a company and might involve applied crypto. But companies around the world might find that relatively relevant (in France a phd will get you to some places).
It's important to know what you want to do, theorical or applied or in the middle? Usually finding an internship in a applied crypto company helps to get out of academia for a while. A good way to see what please you the most. And good news, in cryptography internships are pretty easy to find (at least at the moment).
Alright I'm studying crypto now, how to get more involved?
Cryptography is a big world, many things are happening and it's sometimes hard to follow everything. Especially some mediums give you a high noise-to-quality ratio. So here they are:
Now is your time to find an internship or a job? Apply everywhere, in the world. But where? Where other cryptographers are working, or have worked. You can find that on their published papers (usually written in the header), on Twitter, on Linkedin, etc...
Another good way is to check for "who's hiring" posts on hackernews or reddit
First of all, we stress that SVP and its variants should all be considered easy when the lattice dimension is less than 70. Indeed, we will see in Section 4 that exhaustive search techniques can solve SVP within an hour up to dimension 60. But because such techniques have exponential running time, even a 100-dimensional lattice is out of reach. When the lattice dimension is beyond 100, only approximation algorithms like LLL, DEEP and BKZ can be run.
I can't remember from what article I got that from. Must have been something Phong Nguyen wrote.
It states that a lattice of dimension 60 could be easily solved, in an hour, by an exhaustive search (or similar techniques (enumeration?)). Something to dig into.
So I'm now completely out of the loop, because I've been traveling a bunch. If you have any interesting crypto paper/blog post that was released in these last couple of months please post it here :)
Also I obtained my master. If you speak french or are just curious, you can check that here:
After defending my master thesis in Labri's amphitheatrum I thought I would never have to go back there again. Little did I know, ECC 2015 took place in the exact same room. I was back in school.
Talks
It was a first for me, but for many people it was only one more ECC. Most people knew each other, a few were wandering alone, mostly students. The atmosphere was serious although relaxed. People were mostly in their late 30s and 40s, a good part was french, others came from all over the world, a good minority were government people. Rumor has it that NSA was somewhere hidden.
Nothing really groundbreaking was introduced, as everybody knows ECC is more about politics than math these days. The content was so rare that a few talks were not even talking about ECC. Like that talk about Logjam (was a good talk though) or a few about lattices.
We got warmed up by a one hour cocktail party organized by Microsoft, by 6pm most people were "canard" as the belgium crypto people were saying. We left Bordeaux's Magnificient sun and sat back into the hot room with our wine glasses. Then every 5 minutes a random person would show up on stage and present something, sometimes serious, sometimes ridiculous, sometimes funny.
Panel
The panel was introduced by Benjamin Smith and was composed of 7 figures. Dan Bernstein that needs no introduction, Bos from NXP, Flori from the french government agency ANSSI, Hamburg from Cryptography Research (who was surprised that his company let him assist to the panel), Lochter from BSI (German government) and Moody from NIST.
It was short and about standardization, here are the notes I took then. Please don't quote anything from here, it's inexact and redacted after the fact.
Presenter: you have very different people in front of you, you have exactly 7 white people in front of you, hopefuly it will be different next year.
The consensus is that standardisation in ECC is not working at all. Maybe it should be more like the AES one. Also, people are disapointed that not enough academics were involved... general sadness.
Lochter: it's not good to change too much, things are working for now and Post-Quantum will replace ECC. We should start standardizing PQ. Because everything is slow, mathematics takes years to get standardized, then implemented, etc... maybe the problem is not in standardization but keeping software up-to-date.
Hamburg: PQ is the end of every DLP-based cryptosystem.
Bos: I agree we shouldn't do this (ECC2015) too often. Also we should have a framework where we can plugin different parameters and it would work with any kind of curves.
Someone: why build new standards if the old/current one is working fine. This is distracting implementers. How many crypto standards do we already have? (someone else: a lot)
Bos: Peter's talk was good (about formal verification, other panelists echoed that after). It would be nice for implementers to have tools to test. Even a database with a huge amount of test vectors would be nice
Flori: people don't trust NIST curves anymore, surely for good reasons, so if we do new curves we should make them trustable. Did anyone here tried generating nist, dan, brainpool etc...? (3 people raised their hands).
Bernstein: you're writing a paper? Why don't you put the Sage script online? Like that people won't make mistakes or won't run into a typo in your paper, etc...
Lochter: people have to implement around patents all the time (ranting).
Presenter: NSA said, if you haven't moved to ECC yet, since there will be PQ, don't get into too much trouble trying to move to ECC. Isn't that weird?
Bernstein: we've known for years that PQ computers are coming. There is no doubt. When? It is not clear. NSA's message is nice. Details are weird though.
We've talked to people at the NSA about that. Really weird. Everybody we've talked to has said "we didn't see that in advance" (the announcement). So who's behind that? No one knows. (someone in the audience says that maybe the NSA's website got hacked)
Flori: I agree it's hard to understand what the NSA is saying. So if someone in the audience wants to make some clarification... (waiting for some hidden NSA agent to speak. No one speaks. People laugh).
Hamburg: usually they say they do not deny, or they say they do not confirm. This time they said both (the NSA about Quantum computers).
Lochter: 30 years is the lifetime of secret data, could be 60 years if you double it (grace period?). We take the NSA's announcement seriously, satelites have stuff so we can upgrade them with curves (?)
Presenter: maybe they (the NSA) are scared of all the curve standardization happening and that we might find a curve by accident that they can't break. (audience laughing)
Bos: we have to follow standards when we implement in smartcards...
Lochter: we can't blame the standard. Look at Openssl, they did this mess themselves.
Moody: standards give a false sense a security but we are better with them than without (lochter looks at him weirdly, Moody seems embarassed that he doesn't have anything else to say about it).
Bernstein: we can blame it on the standard!
Lochter: blame the process instead. Implementers should get involved in the standardization process.
Bernstein: I'll give you an example of implementers participating in standardization, Rivest sent a huge comment to the NIST ("implementers have enough rope to hang themselve"). It was one scientific involved in the standardization.
Presenter: we got 55 minutes of the panel done before the first disagreement happened. Good. (everybody laughs)
Bos: we don't want every app dev to be able to write crypto. It is not ideal. We can't blame the standards. We need cryptographers to implement crypto.
A team of researchers ran an attack for nine months, and from 4.8 billion of ephemeral handshakes with different TLS servers they recovered hundreds of private keys.
The theory of the attack is actually pretty old, Lenstra's famous memo on the CRT optimization was written in 1996. Basicaly, when using the CRT optimization to compute a RSA signature, if a fault happens, a simple computation will allow the private key to be recovered. This kind of attacks are usually thought and fought in the realm of smartcards and other embedded devices, where faults can be induced with lasers and other magical weapons.
The research is novel in a way because they made use of Accidental Faults Attack, which is one of the rare kind of remote side-channel attacks.
This is interesting, the oldest passive form of Accidental Fault Attack I can think of is Bit Squatting that might go back to 2011 at that defcon talk.
But first, what is vulnerable?
Any library that uses the CRT optimization for RSA might be vulnerable. A cheap countermeasure would be to verify the signature after computing it, which is what most libraries do. The paper has a nice list of who is doing that.
Implementation
Verification
cryptlib 3.4.2
disabled by default
GnuPG 1.4.1.8
yes
GNUTLS
see libgcrypt and Nettle
Go 1.4.1
no
libgcrypt 1.6.2
no
Nettle 3.0.0
no
NSS
yes
ocaml-nocrypto 0.5.1
no
OpenJDK 8
yes
OpenSSL 1.0.1l
yes
OpenSwan 2.6.44
no
PolarSSL 1.3.9
no
But is it about what library you are using? Your server still has to be defective to produce a fault. The paper also have a nice table displaying what vendors, in their experiments, where most prone to have this vulnerability.
Vendor
Keys
PKI
Rate
Citrix
2
yes
medium
Hillstone Networks
237
no
low
Alteon/Nortel
2
no
high
Viprinet
1
no
always
QNO
3
no
medium
ZyXEL
26
no
low
BEJY
1
yes
low
Fortinet
2
no
very low
If you're using one of these you might want to check with your vendor if a firmware update or other solutions were talked about after the discovery of this attack. You might also want to revoke your keys.
Since the tests were done on a broad scale and not on particular machines, it is obvious that more are vulnerable to this attack. Also only instances connected to internet that offered TLS on port 443 were tested. The vulnerability could potentially exist in any stack using this CRT optimization with RSA.
The first thing you should do is asses where in your stack the RSA algorithm is used to sign. Does it use CRT? If so, does it verifies the signature? Note that the blinding techniques we talked about in one of our cryptography bulletin (may first of this year) will not help.
What can cause your server to produce such erroneous signatures
They list 5 reasons in the paper:
old or vulnerable libraries that have broken operations on integer. For example CVE-2014-3570 the square operations of OpenSSL was not working properly for some inputs
race conditions, when applications are multithreaded
errors in the CPU cache, other caches or the main memory.
Note that at the end of the paper, they investigate if a special hardware might be the cause and end up with the conclusion that several devices leaking the private keys were using Cavium hardware, and in some cases their "custom" version of OpenSSL.
I'm curious. How does that work?
RSA-CRT
Remember, RSA signature is basically \(y = x^d \pmod{n}\) with \(x\) the message, \(d\) the private key and \(n\) the public modulus. Also you might want to use a padding system but we won't cover that here. And then you can verify a signature by doing \(y^e \pmod{n}\) and verify if it is equal to \(x\) (with \(e\) the public exponent).
CRT is short for Chinese Remainder Theorem (I should have said that earlier). It's an optimization that allows to compute the signatures in \(\mathbb{Z}_p\) and \(\mathbb{Z}_q\) and then combine it into \(\mathbb{Z}_n\) (remember \(n = pq\)). It's way faster like that.
and then combine these two values to get the signature:
$$ y = y_p q (q^{-1} \pmod{p}) + y_q p (p^{-1} \pmod{q}) \pmod{n} $$
And you can verify yourself, this value will be equals to \(y_p \pmod{p}\) and \(y_q \pmod{q}\).
The vulnerability
Let's say that an error occurs in only one of these two elements. For example, \(y_p\) is not correctly computed. We'll call it \(\widetilde{y_p}\) instead. It is then is combined with a correct \(y_q\) to produce a wrong signature that we'll call \(\widetilde{y}\) .
Let's notice that if we raise that to the power \(e\) and remove \(x\) from it we get:
$$
\begin{cases}
\widetilde{y}^e - x = \widetilde{y}^e_p - x = a \pmod{p}\\
\widetilde{y}^e - x = y_q^e - x = 0 \pmod{q}
\end{cases}
$$
This is it. We now know that \(q \mid \widetilde{y}^e - x\) while it also divides \(n\). Whereas \(p\) doesn't divide \(\widetilde{y}^e - x\) anymore. We just have to compute the Greatest Common Divisor of \(n\) and \(\widetilde{y}^e - x\) to recover \(q\).
The attack
The attack could potentially work on anything that display a RSA signature. But the paper focuses itself on TLS.
A normal TLS handshake is a two round trip protocol that looks like this:
The client (the first person who speaks) first sends a helloClient packet. A thing filled with bytes saying things like "this is a handshake", "this is TLS version 1.0", "I can use this algorithm for the handshake", "I can use this algorithm for encrypting our communications", etc...
Here's what it looks like in Wireshark:
The server (the second person who speaks) replies with 3 messages: a similar ServerHello, a message with his certificate (and that's how we authenticate the server) and a ServerHelloDone message only consisting of a few bytes saying "I'm done here!".
A second round trip is then done where the client encrypts a key with the server's public key and they later use it to compute the TLS shared key. We won't cover them.
Another kind of handshake can be performed if both the client and the server accepts ephemeral key exchange algorithms (Diffie-Hellman or Elliptic Curve Diffie-Hellman). This is to provide Perfect Forward Secrecy: if the conversations are recorded by a third party, and the private key of the server is later recovered, nothing will be compromised. Instead of using the server's public key to compute the shared key, the server will generate a ephemeral public key and use it to perform an ephemeral handshake. Usualy just for this session or for a limited number.
An extra packet called ServerKeyExchange is sent. It contains the server's ephemeral public key.
Interestingly the signature is not computed over the algorithm used for the ephemeral key exchange, that led to a long series of attack which recently ended with FREAK and Logjam.
By checking if the signature is correctly performed this is how they checked for the potential vulnerability.
I'm a researcher, what's in it for me?
Well what are you waiting for? Go read the paper!
But here are a list of what I found interesting:
instead of DDoSing one target, they broadcasted their attack.
We implemented a crawler which performs TLS handshakes and looks for miscomputed RSA signatures. We ran this crawler for several months.
The intention behind this configuration is to spread the load as widely as possible. We did not want to target particular servers because that might have been viewed as a denial-of-service attack by individual server operators. We assumed that if a vulnerable implementation is out in the wild and it is somewhat widespread, this experimental setup still ensures the collection of a fair number of handshake samples to show its existence.
We believe this approach—probing many installations across the Internet, as opposed to stressing a few in a lab—is a novel way to discover side-channel vulnerabilities which has not been attempted before.
Some TLS servers need a valid Server Name Indication to complete a handshake, so connecting on port 443 of random IPs should not be very efficient. But they found that it was actually not a problem and most key found like that were from weird certificates that wouldn't even be trusted by your browser.
To avoid too many DNS resolutions they bypassed the TTL values and cached everything (they used PowerDNS for that)
They guess what devices were used to perform the TLS handshakes from what was written in the x509 certificates in the subject distinguished name field or Common Name field
They used SSL_set_msg_callback() (see doc) to avoid modifying OpenSSL.