Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

FileUtils.sign() does not support ECDSA #89

Closed

Description

@hinca

When using an elliptic curve keypair, the the key algorithm is EC, but the signature algorithm is SHA256withECDSA.

Therefore the assumption that one can get the Signature like FileUtils:100 does not hold:

Signature sign = Signature.getInstance("SHA256with" + key.getAlgorithm());

Activity

  1. mordechaim commented on Mar 18, 2020

    @mordechaim
    Contributor

    What do you recommend as a catch all alternative? Perhaps allow passing the signature implementation to the signer method and a default overload with the current implementation?

  2. hinca commented on Mar 18, 2020

    @hinca
    Author

    That is a nice fallback/advanced possibility. However the suffix list is quite easily exhausted, so you might also choose to handle EC as an exception:

    https://docs.oracle.com/en/java/javase/14/docs/specs/security/standard-names.html#signature-algorithms

    (Sorry for fat fingers, closed by accident.)

  3. reopened this on Mar 18, 2020
  4. mordechaim commented on Mar 18, 2020

    @mordechaim
    Contributor

    Well, the JDK signature API is extensible and might extend to other implementations too. Can I safely assume that other then EC, all implementations have an exact corresponding SHA256with + implementation counterpart?

  5. hinca commented on Mar 18, 2020

    @hinca
    Author

    I don't think we can rely on that. But my thoughts are to either make the "auto-algorithm" robust enough to at support all standard ciphers (it's not far from that), or don't offer it at all and make the user always supply the algorithm name. (Which loses convenience.)

  6. mordechaim commented on Mar 18, 2020

    @mordechaim
    Contributor

    Or go between the lines and offer both.

  7. mordechaim commented on Mar 18, 2020

    @mordechaim
    Contributor

    The problem is that when we verify we also need the exact same algorithm used, and it gets tricky to pass around the user-provided algorithm.

  8. hinca commented on Mar 18, 2020

    @hinca
    Author

    Yes, I would support offering both with overloading.

    It's correct that we need that on verify time as well, but won't the developer of the launcher know exactly what kind of key the provider of the business app config used? (I mean, they have to exchange the key, so why not also exchange its properties? It is usually also determinable from the beginning of the key string.)

    We could also write that algorithm as an argument of the configuration XML for piece of mind.

  9. mordechaim commented on Mar 30, 2020

    @mordechaim
    Contributor

    I think I'll stick to simply check if algorithm is EC and append "DSA". If it will be requested otherwise I'll think of an advanced solution then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions