Skip to content
This repository was archived by the owner on Jul 30, 2018. It is now read-only.

Conversation

@jason0x43
Copy link
Member

This is the base API for crypto, along with the Node-backed implementation.

@kfranqueiro
Copy link
Member

My initial thoughts/concerns on this are largely around limits it imposes on extensibility. Because hash and sign have distinct exported functions, it seems like it'd be difficult for people to add additional algorithms or provider features if they wanted without needing to basically eschew the default top-level modules (despite the fact that the underlying provider could potentially accommodate as many algorithms/features as they want).

I'm also at least a little concerned that there's more than a fair share of indirection going on here and I'm not sure it's entirely warranted. Currently main isn't something that's typically expected to be directly used (unless the user wants to override the default provider), but looking at the top-level hash or sign modules leads you through an adventure through create<Whatever>Function, back to main, then to whichever implementation-dependent subfolder applies. It doesn't sound that bad but it was pretty disorienting when first looking at it.

@jason0x43
Copy link
Member Author

There's only one level of indirection src/hash.method -> provider.method(), where provider is either src/node/hash, src/script/hash, or src/webcrypto/hash. Hmmm...that may not be super apparent, though.

Some of the messiness is due to competing ways of dividing this up. On the one hand, there are some distinct sets of functionality: hashes, signing functions, and others (key generators, ciphers, ...). On the other hand, there's the platform-based breakdown: node, browser, and pure JS. The current API uses both divisions, which makes for a lot of unnecessary exports.

@jason0x43
Copy link
Member Author

I'm revising this to be a bit simpler and more easily extensible.

@eheasley eheasley added this to the Milestone 1 milestone Jun 3, 2015
@eheasley eheasley assigned kfranqueiro and unassigned bryanforbes Jun 12, 2015
src/crypto.ts Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in a dedicated has module. See dojo-dom/has for an example.

@kfranqueiro
Copy link
Member

Some of the comments I've left on the hash side of things are also applicable to sign.

This branch needs to be rebased against master.

Test coverage probably isn't quite where we'd like it to be yet. A few things that aren't covered:

  • NodeHasher#abort and NodeHasher#start (both before and after the provider loads)
  • getHash and getSign with invalid algorithm strings
  • calling sign before the provider has loaded
  • calling setProvider
  • I'm not sure how we would go about testing the "else if not AMD" branches of getProvider...

Switching from HMAC to a more general Sign grouping is in progress.

References dojo#1, dojo#2
`let provider = <CryptoProvider> {` will allow missing properties in the
provider, while `let provider: CryptoProvider = {` will not.

References dojo#1, dojo#2
Add documentation to crypto.ts describing how the package is
architected.

References dojo#1, dojo#2, dojo#5, dojo#8
- Algorithm validation is handled at both the module level and provider
  level. The module checks algorithms against the standard list until a
  provider is loaded, at which point the provider takes over.
- Tests coverage is much improved.
@jason0x43
Copy link
Member Author

This has been rebased on master and cleaned up based on Ken's comments. Test coverage is much improved. The only untested code is loader-related; more of that will be exercised when we have additional providers.

README.md Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to move this to the top of the file since it is first used in the SignFunction interface definition

@kitsonk kitsonk removed this from the Milestone 1 milestone Apr 8, 2016
@dylans dylans added this to the long-grass milestone Jan 12, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants