You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ring::signature::Signature should probably be a lot like ring::digest::Digest, a fixed-sized buffer convertible to a slice.
SigningKey should look a lot like ring::hmac::SigningKey. Note in particular that it needs to store the private key (for ECC, things, just use ring::ec::PrivateKey) and it needs to cache the computed public key, so it doesn't need to be recomputed over and over.
The main issue is that RSA signatures are large (256 bytes vs 32/48 bytes for ECC signatures), RSA public keys are huge (2048-8192 bits, plus change), and RSA private keys are giant. So, for RSA, we probably want to have `reference to a heap-allocated things, instead of expanding the inline fixed-sized buffers to accommodate things.
See the issues linked above for algorithm-/curve- specific concerns.
We should almost definitely do these in the order presented above. At the very least, we should do Ed25519 first because it is by far the simplest to implement.
Creating a good generic signing API is difficult because:
ECDSA and RSA require a SecureRandom to generates nonces/blndings, but Ed25519 doesn't,
ECDSA and RSA are parameterized by digest algorithm, and one might use the same private key with multiple digest algorithms in practice. However, Ed25519 only works with SHA-512.
ECDSA and RSA need their sign functions to return Result<Signature, ()> because they can fail, but Ed25519 cannot fail (IIRC) so it should just return Signature.
So, I suggest that we punt on the generic API for now. Instead, users that need to support mutliple key types can define their own wrappers around whatever algorithm-specific APIs we create. Then, later, we can learn from what people are doing and create a usable general interface, maybe.
Despite what I said in the previous comment, I started working on an generic signing API: use ring::signature::key_pair_from_pkcs8() to parse the PKCS#8 private key. Use ring::signature::sign() to do the signing. SigningAlgorithms are defined for ECDSA only right now: ring::signature::{ ECDSA_P256_SHA256_ASN1_SIGNING, ECDSA_P256_SHA256_FIXED_SIGNING, ECDSA_P384_SHA384_ASN1_SIGNING, ECDSA_P384_SHA384_FIXED_SIGNING}.
In the case of Ed25519 we'll have a SecureRandom argument that goes unused. However, I think that's OK. In general I think we'll probably have a special Ed25519-specific API and then require the use of the generic API for ECDSA and RSA, removing RSAKeyPair and ECDSAKeyPair from the public API.
All the issues tracked in the summary have been closed as all of Ed25519/P-256/P-384/RSA-PKCS#1/RSA-PSS signing have been implemented, so I'm closing this.
The signing API needs to be improved and made more generic, but we should do those improvements in other issues/PRs.
Activity
briansmith commentedon May 31, 2016
The signing function should be something like:
ring::signature::Signatureshould probably be a lot likering::digest::Digest, a fixed-sized buffer convertible to a slice.SigningKeyshould look a lot likering::hmac::SigningKey. Note in particular that it needs to store the private key (for ECC, things, just usering::ec::PrivateKey) and it needs to cache the computed public key, so it doesn't need to be recomputed over and over.The main issue is that RSA signatures are large (256 bytes vs 32/48 bytes for ECC signatures), RSA public keys are huge (2048-8192 bits, plus change), and RSA private keys are giant. So, for RSA, we probably want to have `reference to a heap-allocated things, instead of expanding the inline fixed-sized buffers to accommodate things.
See the issues linked above for algorithm-/curve- specific concerns.
briansmith commentedon May 31, 2016
We should almost definitely do these in the order presented above. At the very least, we should do Ed25519 first because it is by far the simplest to implement.
briansmith commentedon Jun 4, 2016
Creating a good generic signing API is difficult because:
SecureRandomto generates nonces/blndings, but Ed25519 doesn't,signfunctions to returnResult<Signature, ()>because they can fail, but Ed25519 cannot fail (IIRC) so it should just returnSignature.So, I suggest that we punt on the generic API for now. Instead, users that need to support mutliple key types can define their own wrappers around whatever algorithm-specific APIs we create. Then, later, we can learn from what people are doing and create a usable general interface, maybe.
briansmith commentedon May 31, 2018
Despite what I said in the previous comment, I started working on an generic signing API: use
ring::signature::key_pair_from_pkcs8()to parse the PKCS#8 private key. Usering::signature::sign()to do the signing.SigningAlgorithmsare defined for ECDSA only right now:ring::signature::{ ECDSA_P256_SHA256_ASN1_SIGNING, ECDSA_P256_SHA256_FIXED_SIGNING, ECDSA_P384_SHA384_ASN1_SIGNING, ECDSA_P384_SHA384_FIXED_SIGNING}.In the case of Ed25519 we'll have a
SecureRandomargument that goes unused. However, I think that's OK. In general I think we'll probably have a special Ed25519-specific API and then require the use of the generic API for ECDSA and RSA, removingRSAKeyPairandECDSAKeyPairfrom the public API.briansmith commentedon Jan 5, 2019
All the issues tracked in the summary have been closed as all of Ed25519/P-256/P-384/RSA-PKCS#1/RSA-PSS signing have been implemented, so I'm closing this.
The signing API needs to be improved and made more generic, but we should do those improvements in other issues/PRs.