Class ECChecks


  • public class ECChecks
    extends Object
    Elliptic curve checks.
    Version:
    2017-04-13
    Author:
    Vladimir Dzhuvinov
    • Method Detail

      • isPointOnCurve

        public static boolean isPointOnCurve​(ECPublicKey publicKey,
                                             ECPrivateKey privateKey)
        Checks if the specified (ephemeral) public key is on the curve of the private key. Intended to prevent an "Invalid Curve Attack", independent from any JCA provider checks (the SUN provider in Java 1.8.0_51+ and BouncyCastle have them, other / older provider do not).

        See https://www.cs.bris.ac.uk/Research/CryptographySecurity/RWC/2017/nguyen.quan.pdf

        Parameters:
        publicKey - The public EC key. Must not be null.
        privateKey - The private EC key. Must not be null.
        Returns:
        true if public key passed the curve check.
      • isPointOnCurve

        public static boolean isPointOnCurve​(ECPublicKey publicKey,
                                             ECParameterSpec ecParameterSpec)
        Checks if the specified (ephemeral) public key is on the given curve. Intended to prevent an "Invalid Curve Attack", independent from any JCA provider checks (the SUN provider in Java 1.8.0_51+ and BouncyCastle have them, other / older provider do not).

        See https://www.cs.bris.ac.uk/Research/CryptographySecurity/RWC/2017/nguyen.quan.pdf

        Parameters:
        publicKey - The public EC key. Must not be null.
        ecParameterSpec - The EC spec. Must not be null.
        Returns:
        true if public key passed the curve check.
      • isPointOnCurve

        public static boolean isPointOnCurve​(BigInteger x,
                                             BigInteger y,
                                             ECParameterSpec ecParameterSpec)
        Checks if the specified (ephemeral) public key is on the given curve. Intended to prevent an "Invalid Curve Attack", independent from any JCA provider checks (the SUN provider in Java 1.8.0_51+ and BouncyCastle have them, other / older provider do not).

        See https://www.cs.bris.ac.uk/Research/CryptographySecurity/RWC/2017/nguyen.quan.pdf

        Parameters:
        x - The public EC x coordinate. Must not be null.
        y - The public EC y coordinate. Must not be null.
        ecParameterSpec - The EC spec. Must not be null.
        Returns:
        true if public key passed the curve check.