Test suites

*NOTE: The wrong, composite, invalid,twist, cofactor, edge-cases and degenerate test suites caused temporary/permanent DoS of some cards. These test suites prompt you for confirmation before running, be cautious.

Default

Tests support for ECC and the presence of default curves on the target. These might not be present or the target might not even support ECC. Tests keypair allocation, generation, ECDH and ECDSA. ECDH is first tested with two valid generated keypairs, then with a compressed public key to test support for compressed points.

This test suite is run if no argument is provided to -t / --test.

Test-Vectors

Tests ECDH using known test vectors provided by NIST/SECG/Brainpool:

SECG - GEC2

NIST - ECCDH

Brainpool - RFC6931

Brainpool - RFC7027

Compression

Tests support for compression of public points in ECDH as specified in ANSI X9.62. The standard specifies two forms of point compression, fully compressed point contains the x coordinate and one bit of the y coordinate, from which the whole point can be reconstructed, hybrid form of a compressed point contains both the x and y coordinates but also one bit of the y coordinate.

Tests ECDH with points in compressed and hybrid form. Also tests target response to a hybrid point with wrong y coordinate and to the point at infinity(as public key in ECDH). Tests ECDH with invalid compressed point, where x does not lie on the curve.

Miscellaneous

Some miscellaneous tests, tries ECDH and ECDSA over super-singular curves, anomalous curves and Barreto-Naehrig curves with small embedding degree and CM discriminant. Also tests ECDH over MNT curves, M curves and Curve25519 transformed into short Weierstrass form.

Signature

Tests ECDSA verification, with well-formed but invalid and malformed signatures.

Wrong

Tests on a category of wrong curves. These curves are not really curves as they have:

This test suite also does some additional tests with corrupting the parameters:

Composite

Tests using curves that don’t have a prime order/nearly prime order. These tests should generally fail, a success here implies the target will use a non-secure curve if such curve is set by the applet. Operations over such curves are susceptible to small-subgroup attacks.

Invalid

Tests using known named curves from several categories(SECG/NIST/Brainpool) against pre-generated invalid public keys. ECDH should definitely fail, a success here implies the target is susceptible to invalid curve attacks.

See Practical Invalid Curve Attacks on TLS-ECDH for more information.

Twist

Tests using known named curves froms several categories(SECG/NIST) against pre-generated points on twists of said curves. ECDH should fail, a success here implies the target is not twist secure, if a curve with an unsecure twist is used, the target might compute on the twist, if a point on the twist is supplied.

See SafeCurves on twist security for more information.

Degenerate

Tests using known named curves froms several categories(SECG/NIST) against pre-generated points on the degenerate line Y: x = 0. ECDH should fail, a success here might mean the target does not check that the point lies on the correct curve and uses a curve model vulnerable to such degenerate points.

See Degenerate Curve Attacks - Extending Invalid Curve Attacks to Edwards Curves and Other Models for more information.

Cofactor

Tests whether the target correctly rejects points that lie on the curve but not on the subgroup generated by the specified generator during ECDH. Does this with curves where the cofactor subgroup has small order, then with curves that have order equal to the product of two large primes, sets the generator with order of one prime and tries points on the subgroup of the other prime order.

Edge-Cases

Tests various inputs to ECDH which may cause an implementation to achieve a certain edge-case state during ECDH. Some of the data is from the google/Wycheproof project. Tests include CVE-2017-10176 and CVE-2017-8932 and an OpenSSL modular reduction bug presented in Practical realisation and elimination of an ECC-related software bug attack. Various custom edge private key values are also tested.

CVE-2017-10176 was in implementation issue in the SunEC Java library (and NSS (CVE-2017-7781), thus also anything that used it) that caused the implementation to reach the point at infinity during ECDH computation. See blog for more info.

CVE-2017-8932 was an implementation issue in the Go standard library, in particular its scalar multiplication algorithm on the P-256 curve which leaked information about the private key.

Custom edge-case private key values over SECG curves are tested: