Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate JCA signing from DER encoding to P1363 encoding #155

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

iaik-jheher
Copy link
Collaborator

DER-encoded ECDSA signatures are an ASN.1 structure, with variable length integer representation. P1363-encoded ECDSA signatures are fixed-length concatenated integers with no additional structure.

This means that P1363 -> DER is easy, while DER -> P1363 is impossible without additional information (such as the curve used).
We currently use the RawByteEncodable marker interface to indicate whether a given (EC) signature can be encoded to P1363.

The JCA extensions in Indispensable currently produce and consume DER signatures. This is awkward, since it means that CryptoSignature.parseFromJCA cannot return RawByteEncodable signatures -- not even in the RSA case!

This PR fixes this. It declares the individual parts of the signing process as hazmat (since they are encoding dependent) and switches them to use P1363. The stable API going forward for signing ops using the JCA will be .signWithJCA, which guarantees that the signature object and signature byte decoding use the same encoding (whatever that may be on any given platform).

@iaik-jheher iaik-jheher changed the base branch from main to development October 4, 2024 13:11
@iaik-jheher iaik-jheher marked this pull request as draft October 7, 2024 07:48
@JesusMcCloud
Copy link
Collaborator

so… do you want me to add a dedicated android target? if you fear duplicated code, we can just add a jvmAndroidMain source folder and hook it into the JVM and Android source sets, so everything but the culprit can be shared and we require no code duplication

@JesusMcCloud
Copy link
Collaborator

@iaik-jheher so… what do you want me to do about this?

@iaik-jheher
Copy link
Collaborator Author

not sure, I might even abandon it altogether, since it "just" deals with glue code... I though this would be a quick and free fix

@iaik-jheher
Copy link
Collaborator Author

the extra source set hierarchy for android/java might be a good idea regardless, just so we can get rid of the "isAndroid" classpath checking hack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants