Minerva: The curse of ECDSA nonces Jan Jancar , Vladimir Sedlacek, - - PowerPoint PPT Presentation

minerva
SMART_READER_LITE
LIVE PREVIEW

Minerva: The curse of ECDSA nonces Jan Jancar , Vladimir Sedlacek, - - PowerPoint PPT Presentation

Minerva: The curse of ECDSA nonces Jan Jancar , Vladimir Sedlacek, Petr Svenda, Marek Sys Minerva: The curse of ECDSA nonces Jan Jancar , Vladimir Sedlacek, Petr Svenda, Marek Sys Systematic analysis of lattice attacks on noisy leakage of


slide-1
SLIDE 1

Minerva:

The curse of ECDSA nonces

Jan Jancar, Vladimir Sedlacek, Petr Svenda, Marek Sys

slide-2
SLIDE 2

Minerva:

The curse of ECDSA nonces

Jan Jancar, Vladimir Sedlacek, Petr Svenda, Marek Sys

slide-3
SLIDE 3
slide-4
SLIDE 4

Systematic analysis of lattice attacks on noisy leakage of bit-length of ECDSA nonces

slide-5
SLIDE 5

Discovery

EC Tester

  • Tool for testing black-box ECC implementations

JavaCards

Software libraries (15 supported)

  • Idea: Independently verify implementations are well-behaved and do not

contain bugs

  • 12 test suites
  • crocs-muni/ECTester

Jan Jancar Minerva: The curse of ECDSA nonces 2 / 17

slide-6
SLIDE 6

Discovery

ECDSA

P Q −(P + Q) (P + Q) x y

y2 ≡ x3 + ax + b

  • ver Fp

G ∈ E(Fp), |G| = n (prime) Sign(message m, private key x)

1 k $

← Zn (nonce)

2 r ≡ ([k]G)x mod n 3 s ≡ k−1(H(m) + rx) mod n 4 Output (r, s) as ASN.1 DER SEQUENCE

Jan Jancar Minerva: The curse of ECDSA nonces 3 / 17

slide-7
SLIDE 7

Discovery

ECDSA tests

  • ASN.1 parsing

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-8
SLIDE 8

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-9
SLIDE 9

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-10
SLIDE 10

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-11
SLIDE 11

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-12
SLIDE 12

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-13
SLIDE 13

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-14
SLIDE 14

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-15
SLIDE 15

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-16
SLIDE 16

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-17
SLIDE 17

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-18
SLIDE 18

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Let’s test timing as well!

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-19
SLIDE 19

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Timing

  • Jan Jancar

Minerva: The curse of ECDSA nonces 4 / 17

slide-20
SLIDE 20

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Timing

  • Minerva

1 5

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-21
SLIDE 21

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Timing

  • Minerva

1 5 TPM-FAIL 2

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-22
SLIDE 22

Discovery

ECDSA tests

  • ASN.1 parsing
  • Signature malleability
  • Test-vectors

~

  • Nonce randomness

Timing

  • Minerva

1 5 TPM-FAIL 2 Déjà Vu 1 ...

Jan Jancar Minerva: The curse of ECDSA nonces 4 / 17

slide-23
SLIDE 23

Discovery

Tested

Type Name Version/Model Scalar multiplier Leakage Library OpenSSL 1.1.1d Montgomery ladder no BouncyCasle 1.58 Comb method no SunEC JDK 7 - JDK 12 Window-NAF no Lopez-Dahab ladder yes* WolfSSL 4.0.0 Sliding window yes BoringSSL 974f4dddf Window method no libtomcrypt v1.18.2 Sliding window no libgcrypt 1.8.4 Double-and-add yes* Botan 2.11.0 Window method no Microsoft CNG 10.0.17134.0 Window method no mbedTLS 2.16.0 Comb method no MatrixSSL 4.2.1 Sliding window yes Intel PP Crypto 2020 Window-NAF no Crypto++ 8.2 unknown yes Card Athena IDProtect 010b.0352.0005 unknown yes* NXP JCOP3 J2A081, J2D081, J3H145 unknown no Infineon JTOP 52GLA080AL, SLE78 unknown no G+D SmartCafe v6, v7 unknown no Jan Jancar Minerva: The curse of ECDSA nonces 5 / 17

slide-24
SLIDE 24

Discovery

Leak

Jan Jancar Minerva: The curse of ECDSA nonces 6 / 17

slide-25
SLIDE 25

Discovery

Leak

[k]G

Jan Jancar Minerva: The curse of ECDSA nonces 6 / 17

slide-26
SLIDE 26

Discovery

Leak

[k]G

248 249 250 251 252 253 254 255 256

nonce bit-length

148500 149000 149500 150000 150500 151000 151500 152000

signature time ( s)

20 40 60 80 Jan Jancar Minerva: The curse of ECDSA nonces 6 / 17

slide-27
SLIDE 27

Discovery

Leak

L = base + iter_time · B + N B ∼ Geom(p = 1/2, (256, 255, . . . , 0)) N ∼ Norm(0, sdev2)

3570000 3600000 3630000 3660000 3690000 3720000 3750000 3780000 3810000 time (ns) 200 400 600 800 1000 1200 1400 count all 256b 255b 254b 253b 252b 251b 250b 249b

base iter_time sdev // secp256r1 curve

Jan Jancar Minerva: The curse of ECDSA nonces 6 / 17

slide-28
SLIDE 28

Exploitation

Hidden Number Problem

  • Average 1 LZB per signature
  • There is noise

Jan Jancar Minerva: The curse of ECDSA nonces 7 / 17

slide-29
SLIDE 29

Exploitation

Hidden Number Problem

  • Average 1 LZB per signature
  • There is noise

[1]

Jan Jancar Minerva: The curse of ECDSA nonces 7 / 17

slide-30
SLIDE 30

Exploitation

Hidden Number Problem

  • Average 1 LZB per signature
  • There is noise

Hidden Number Problem (HNP) [1]

Given an oracle computing: Ob,t() = MSBl(at + b mod n) with t u.i.d. in Z∗

n, find a.

Jan Jancar Minerva: The curse of ECDSA nonces 7 / 17

slide-31
SLIDE 31

Exploitation

Hidden Number Problem

  • Average 1 LZB per signature
  • There is noise

Hidden Number Problem (HNP) [1]

Given an oracle computing: Or,s() = MSBl(k mod n)

Jan Jancar Minerva: The curse of ECDSA nonces 7 / 17

slide-32
SLIDE 32

Exploitation

Hidden Number Problem

  • Average 1 LZB per signature
  • There is noise

Hidden Number Problem (HNP) [1]

Given an oracle computing: Or,s() = MSBl(xs−1r + H(m)s−1 mod n) find x.

Jan Jancar Minerva: The curse of ECDSA nonces 7 / 17

slide-33
SLIDE 33

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-34
SLIDE 34

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest
  • Assume some bounds li: |ki| = |xti − ui| = |xs−1

i

ri + H(mi)s−1

i

| < n/2li

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-35
SLIDE 35

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest
  • Assume some bounds li: |ki| = |xti − ui| = |xs−1

i

ri + H(mi)s−1

i

| < n/2li

  • Construct a lattice with basis B and reduce it:

B =

       

2l1n . . . 2l2n . . . . . . . . . . . . 2ldn 2l1t1 2l2t2 2l3t3 . . . 2ldtd 1

       

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-36
SLIDE 36

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest
  • Assume some bounds li: |ki| = |xti − ui| = |xs−1

i

ri + H(mi)s−1

i

| < n/2li

  • Construct a lattice with basis B and reduce it:

B =

       

2l1n . . . 2l2n . . . . . . . . . . . . 2ldn 2l1t1 2l2t2 2l3t3 . . . 2ldtd 1

       

  • Construct a target u = (2l1u1, . . . , 2ldud, 0)

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-37
SLIDE 37

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest
  • Assume some bounds li: |ki| = |xti − ui| = |xs−1

i

ri + H(mi)s−1

i

| < n/2li

  • Construct a lattice with basis B and reduce it:

B =

       

2l1n . . . 2l2n . . . . . . . . . . . . 2ldn 2l1t1 2l2t2 2l3t3 . . . 2ldtd 1

       

  • Construct a target u = (2l1u1, . . . , 2ldud, 0)
  • Solve CVP(B, u). The closest lattice point is often: v = (2l1t1x, . . . , 2ldtdx, x)

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-38
SLIDE 38

Exploitation

Basic attack [2]

  • Collect N signatures, take d of the fastest
  • Assume some bounds li: |ki| = |xti − ui| = |xs−1

i

ri + H(mi)s−1

i

| < n/2li

  • Construct a lattice with basis B and reduce it:

B =

       

2l1n . . . 2l2n . . . . . . . . . . . . 2ldn 2l1t1 2l2t2 2l3t3 . . . 2ldtd 1

       

  • Construct a target u = (2l1u1, . . . , 2ldud, 0)
  • Solve CVP(B, u). The closest lattice point is often: v = (2l1t1x, . . . , 2ldtdx, x)
  • Because ∀i: (xti − ui) mod n is small

Jan Jancar Minerva: The curse of ECDSA nonces 8 / 17

slide-39
SLIDE 39

Analysis

  • Can we improve the attack?
  • How to choose li, d and minimize N?
  • 4 datasets of signatures, varying noise, secp256r1 curve
  • Run attack 5 times,

for each N from 500 to 10 000 (steps 100) and

d from 50 to 140 (steps 2)

  • Solve via SVP (search reduced basis vectors),

after BKZ reduction with β ∈ {15, 20, . . . , 55}

Dataset base (µs) iter_time (µs) sdev (µs) sim ○ 1 sw ○ 453.4 12.7 17.2 tpm ○ 27047.3 236.1 211.3 card ○ 43578.4 371.5 451.3

Jan Jancar Minerva: The curse of ECDSA nonces 9 / 17

slide-40
SLIDE 40

Analysis

Bounds li

  • How to assign bound li for the i-th fastest signature?

Constant (li = c for c ∈ {1, 2, 3, 4}) based on d

Jan Jancar Minerva: The curse of ECDSA nonces 10 / 17

slide-41
SLIDE 41

Analysis

Bounds li

10 20 30 40 50 60 70 80 90 100 index 2 2 4 6 8 10 bound sim (sample) sim - geom geom

  • How to assign bound li for the i-th fastest signature?

Constant (li = c for c ∈ {1, 2, 3, 4}) based on d

Geometric based on N ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 10 / 17

slide-42
SLIDE 42

Analysis

Bounds li

500 2000 4000 6000 8000 10000 60 80 100 120 140 Dimension of matrix (D)

card

500 2000 4000 6000 8000 10000 60 80 100 120 140

sim

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140 Dimension of matrix (D)

sw

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140

tpm

1 2 3 4 5

constant c = 3 ○ ○ ○ ○

500 2000 4000 6000 8000 10000 60 80 100 120 140 Dimension of matrix (D)

card

500 2000 4000 6000 8000 10000 60 80 100 120 140

sim

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140 Dimension of matrix (D)

sw

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140

tpm

1 2 3 4 5

geometric ○ ○ ○ ○

  • How to assign bound li for the i-th fastest signature?

Constant (li = c for c ∈ {1, 2, 3, 4}) based on d

Geometric based on N ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 10 / 17

slide-43
SLIDE 43

Analysis

Bounds li

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Success probability card const3 card geom sim const3 sim geom sw const3 sw geom tpm const3 tpm geom

  • How to assign bound li for the i-th fastest signature?

Constant (li = c for c ∈ {1, 2, 3, 4}) based on d

Geometric based on N ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 10 / 17

slide-44
SLIDE 44

Analysis

CVP vs SVP

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Success probability card np card svp sim np sim svp sw np sw svp tpm np tpm svp

  • Solve the HNP via the natural CVP(B, u) or transform into SVP(C)?
  • CVP solved via Babai’s Nearest Plane algorithm after reduction
  • SVP solved via search of the reduced basis vectors

C =

  • B

u n

  • Jan Jancar

Minerva: The curse of ECDSA nonces 11 / 17

slide-45
SLIDE 45

Analysis

Recentering

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Success probability card no recentering card recentering sim no recentering sim recentering sw no recentering sw recentering tpm no recentering tpm recentering

  • Nonces are non-negative, we bound the absolute value
  • Gain 1 bit by recentering! [5] [3]

|ki − n/2li+1| < n/2li+1

Jan Jancar Minerva: The curse of ECDSA nonces 12 / 17

slide-46
SLIDE 46

Analysis

Random subsets

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Success probability card 1 card 1.5 sim 1 sim 1.5 sw 1 sw 1.5 tpm 1 tpm 1.5

  • Avoid errors by using a random subset of signatures! [2]
  • Sample d random signatures out of the 1.5d fastest signatures, repeat 100 times
  • Time consuming

Jan Jancar Minerva: The curse of ECDSA nonces 13 / 17

slide-47
SLIDE 47

Analysis

Nonce differences

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Successes card no differences card differences sim no differences sim differences sw no differences sw differences tpm no differences tpm differences

  • Instead of bounding |ki|, we can bound |ki − kj|! [5] [6]
  • Strive for li = lj, information is lost otherwise
  • Errors might cancel out
  • Cannot use recentering, difference might be negative

|ki − kj| < n/2min(li,lj)

Jan Jancar Minerva: The curse of ECDSA nonces 14 / 17

slide-48
SLIDE 48

Analysis

u-bitflips

  • Lattice reduction is the costly part of the attack
  • In solving via CVP, the u values are not part of the lattice
  • Reduce the lattice once, then try Babai’s Nearest Plane with many u
  • ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 15 / 17

slide-49
SLIDE 49

Analysis

u-bitflips

500 2000 4000 6000 8000 10000 60 80 100 120 140 Dimension of matrix (D)

card

500 2000 4000 6000 8000 10000 60 80 100 120 140

sim

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140 Dimension of matrix (D)

sw

500 2000 4000 6000 8000 10000 Number of signatures (N) 60 80 100 120 140

tpm

0.0 0.5 1.0 1.5 2.0 2.5 3.0

○ ○ ○ ○ errors fixed for success

  • Lattice reduction is the costly part of the attack
  • In solving via CVP, the u values are not part of the lattice
  • Reduce the lattice once, then try Babai’s Nearest Plane with many u
  • ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 15 / 17

slide-50
SLIDE 50

Analysis

u-bitflips

1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 Number of signatures (N) 0.0 0.2 0.4 0.6 0.8 1.0 Success probability card 0 card 3 sim 0 sim 3 sw 0 sw 3 tpm 0 tpm 3

  • Lattice reduction is the costly part of the attack
  • In solving via CVP, the u values are not part of the lattice
  • Reduce the lattice once, then try Babai’s Nearest Plane with many u
  • ( new)

Jan Jancar Minerva: The curse of ECDSA nonces 15 / 17

slide-51
SLIDE 51

Conclusions

  • Geometric assignment of bounds

lowers min(N) for attack success

  • SVP solving of HNP outperforms CVP

solving via Nearest Plane algorithm

  • Recentering improves the attack’s

success rate

  • Correcting errors via u-bitflips is

promising, but pays the cost of using Nearest Plane algorithm

  • Demonstrated an attack on data from

the TPM-FAIL paper [3], with only 900 signatures, instead of 40 000

slide-52
SLIDE 52

Thanks!

jan@neuromancer.sk The paper: minerva.crocs.fi.muni.cz Icons from & Font Awesome Photos from

slide-53
SLIDE 53

References

1

  • Dan Boneh, Ramarathnam Venkatesan; Hardness of Computing the Most Significant Bits
  • f Secret Keys in Diffie-Hellman and Related Schemes

2

  • Billy Bob Brumley, Nicola Tuveri; Remote Timing Attacks are Still Practical

3

  • Daniel Moghimi, Berk Sunar, Thomas Eisenbarth, Nadia Heninger; TPM-FAIL: TPM meets

Timing and Lattice Attacks 4

  • Sohaib ul Hassan, Iaroslav Gridin, Ignacio M. Delgado-Lozano, Cesar Pereida García,

Jesús-Javier Chi-Domínguez, Alejandro Cabrera Aldaya, Billy Bob Brumley; Déjà Vu: Side-Channel Analysis of Mozilla’s NSS 5

  • Joachim Breitner, Nadia Heninger; Biased Nonce Sense: Lattice Attacks against Weak

ECDSA Signatures in Cryptocurrencies 6

  • Jean-Charles Faugere, Christopher Goyet, Guénaël Renault; Attacking (EC)DSA given
  • nly an implicit hint