Comments (2)
This probably doesn't just apply to HmacSecretKey
, but all places where we do importJsonWebKey
.
I think on the web window.crypto.subtle.importKey
always requires that you explicitly specify:
- (a) the key (
format
andkeyData
) - (b) what kind of key you want to import (
algorithm
parameter, likeHmacImportParams
). - (c) what the key may be used for (
extractable
andkeyUsages
).
We've largely opted not to do (c), see discussion in #53.
But yes, in some cases parts of (b) could be omitted. In particular when talking about JWKs.
I guess the benefit of reading the hash
from the JWK, is that it's easier to just download a JWK from somewhere and use it. Where as, the way the API currently looks you have to read the alg
property of the JWKand switch on
HS1,
HS256, etc, to pass instances of
Hash.sha1or
Hash.sha256in the
hash` parameter. This isn't super convenient.
On the other hand, if you download a JWK from somewhere without checking to see what hash it's using, you might unintentionally be using a weaker hash than you intended. And on most use cases you probably know what kind of algorithm you expect to be using, and you shouldn't want your code to dynamically use a different hash.
So perhaps it's best to say that you can import a JWK, but you must specify what you expect the JWK to be.
And if you want to support importing any kind if JWK, then it's in convenient, and you'll have read the JWK alg
, etc...
I'm actually leaning towards the current API, just because we don't necessarily want this package to provide something that is possibly too smart. And maybe it's better to be simple and a little inconvenient. And if someone really wants a smart crypto library that an import any JWK by just parsing the JWK, then maybe that someone should make a high-level package with a high-level API for this purpose.
from webcrypto.dart.
As such maybe the only take away from this is:
- Let's delete the TODO comments 🤣
- Let's always make sure that whenever a JWK has a property, the value of said property is consistent what how we intend to use it.
(This might especially make sense since most JWKs have lots of optional properties).
But I'm also interested in hearing other perspectives.
from webcrypto.dart.
Related Issues (20)
- Make dartdoc examples self-contained. HOT 1
- Documentation for AES-GCM should discourage AES-192 and encourage nonce size 96 (12 bytes) HOT 1
- Add .toString() methods on all private classes HOT 7
- Avoid @sealed annotation, using `final class` for everything HOT 3
- Upgrade BoringSSL
- Declare privacy manifest file for Apple HOT 4
- Consider using [!NOTE] blockquote for browser/platform compatibility notes HOT 10
- Re-enable `flutter test --platform chrome` on Windows
- Migrate away from imperative apply of Flutter's Gradle plugins
- Tests if P-521 works on Safari
- Document the maximum length in EcdhPrivateKey.deriveBits for each curve HOT 1
- Add test coverage collection with coveralls
- Support for Gradle 8 HOT 4
- Upgrade ffigen HOT 1
- Upgrade flutter_lints
- debug intermittent iOS integration tests HOT 1
- Figure out how to enable LTO on Android
- Give access to the authorization tag in AES-GCM mode HOT 2
- EcdsaPrivateKey.importRawKey unavailable HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcrypto.dart.