Skip to content

Add signing API #205

Closed
Closed

Description

@briansmith

Activity

  1. briansmith commented on May 31, 2016

    @briansmith
    OwnerAuthor

    The signing function should be something like:

    ring::signature::sign(key: &ring::signature::SigningKey, msg: ring::input::Input) -> ring::signature::Signature { }
    

    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.

  2. briansmith commented on May 31, 2016

    @briansmith
    OwnerAuthor

    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.

  3. briansmith commented on Jun 4, 2016

    @briansmith
    OwnerAuthor

    Creating a good generic signing API is difficult because:

    1. ECDSA and RSA require a SecureRandom to generates nonces/blndings, but Ed25519 doesn't,
    2. 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.
    3. 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.

  4. briansmith commented on May 31, 2018

    @briansmith
    OwnerAuthor

    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.

  5. briansmith commented on Jan 5, 2019

    @briansmith
    OwnerAuthor

    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.

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