Git Product home page Git Product logo

Comments (5)

slowli avatar slowli commented on June 18, 2024

Hi! Sorry for such a delay with the answer πŸ€¦β€β™‚οΈ

Would you be opposed to exposing a backend-agnostic API to import, export and generate asymmetric keys?

Do you mean using one-size-fits-all data types for all cryptographic backends? (That is, a data type for an "signing key".) Or for data types within a single algorithm with possible multiple backends? (That is, a data type for a "Ed25519 signing key".) I'm soft-opposed to the first idea; one of motivations behind the crate was type safety, which is hard to achieve with such all-encompassing types. Regarding the second idea, I'm more welcoming, but I'd like to elaborate on it still.

Even in the jwt-compact test suite, this is not convenient, as individual tests have to be written according to every possible backend.

I don't think that exposing backend-specific types is a bad idea per se. In the current crate architecture, it's the developer responsibility to enable the backend, and the key management is (intentionally) moved out of the area of responsibility of the crate - backends (usually) know how to deal with keys secure, and introducing additional layer of abstraction just increases the risks of something going terribly wrongβ„’, IMO.

Regarding the tests specifically, this is issue specific to tests. I think in most of use cases the library user will deal with fewer backends than are supported by the library, and certainly won't have to deal with the "overlapping" backends for the same crypto algorithm.

from jwt-compact.

jedisct1 avatar jedisct1 commented on June 18, 2024

Hi!

I meant the later. Having backend-independent types for a given algorithm.

Creating a key currently requires diving into the documentation of unrelated crates. Switching backends (e.g. using ed25519-compact in a WebAssembly envirionment and dalek otherwise) requires different code.
Since the backends are not re-exported, applications also have to explicitly reimport them, and make sure to import the same version as jwt-compact.

This makes usage of jwt-compact more complicated and confusing than it could, and the HS* schemes API inconsistent with asymmetric schemes.

from jwt-compact.

slowli avatar slowli commented on June 18, 2024

@jedisct1 I've sketched the abstraction layer in #16. Does it look passable to you, or is some functionality missing?

from jwt-compact.

jedisct1 avatar jedisct1 commented on June 18, 2024

Looking good!

I'm wondering if generate() couldn't eventually be a trait as well. But your changes are nice and clean.

from jwt-compact.

slowli avatar slowli commented on June 18, 2024

Moved the remaining part of the issue to #26.

from jwt-compact.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.