java.lang.Object
net.i2p.crypto.ECConstants

final class ECConstantsextends Object
Constants for elliptic curves, from NIST FIPS 186-4 (2013) / ANSI X9.62.
  • Field Details

    • DEBUG

      private static final boolean DEBUG
      True to log the parameter verification.
      See Also:
    • BC_AVAILABLE

      private static final boolean BC_AVAILABLE
      True when Bouncy Castle is present.
    • PARM_P256

      private static final ECConstants.ECParms PARM_P256
      The parameters of the P-256 curve.
    • PARM_P384

      private static final ECConstants.ECParms PARM_P384
      The parameters of the P-384 curve.
    • PARM_P521

      private static final ECConstants.ECParms PARM_P521
      The parameters of the P-521 curve.
    • P256_SPEC

      public static final ECParameterSpec P256_SPEC
      P256_SPEC.
    • P384_SPEC

      public static final ECParameterSpec P384_SPEC
      P384_SPEC.
    • P521_SPEC

      public static final ECParameterSpec P521_SPEC
      P521_SPEC.
  • Constructor Details

    • ECConstants

      ECConstants()
      Constructor. The curve, domain and provider lookups below all run in the static initializer, so an instance holds nothing.
  • Method Details

    • log

      private static void log(String s)
      Logs a debug message.
      Parameters:
      s - the message to log
    • log

      private static void log(String s, Throwable t)
      Logs a debug message with a cause.
      Parameters:
      s - the message to log
      t - the error to log with the message
    • isBCAvailable

      public static boolean isBCAvailable()
      Return whether Bouncy Castle is available.
      Returns:
      whether BC available
    • genSpec

      private static ECParameterSpec genSpec(String name)
      Generate a spec from a curve name.
      Parameters:
      name - the standard curve name, e.g. secp256r1
      Returns:
      null if fail
    • genSpec

      private static ECParameterSpec genSpec(String name1, String name2, ECConstants.ECParms parms)
      Tries curve name1, then name2, then creates new from parms.
      Parameters:
      name1 - the first standard curve name to try
      name2 - null to skip
      parms - null to skip
      Returns:
      null if all fail
    • equals

      public static boolean equals(ECParameterSpec s1, ECParameterSpec s2)
      There is no Object.equals(Object). Needed to load family keys on Android via SigUtil.fromJavaKey(PublicKey).
      Parameters:
      s1 - the spec being compared; null is tolerated only if s2 is also null
      s2 - the spec being compared; null is tolerated only if s1 is also null
      Returns:
      true if equal