browserify / crypto-browserify

partial implementation of node's `crypto` for the browser
MIT License
654 stars 200 forks source link

version 2 #31

Closed dominictarr closed 10 years ago

dominictarr commented 10 years ago

I'm working on v2,

here is the basic idea:

I minimum set of operations I'd like to support:

this will give a minimal useable subset of the node api, although, the set of algorithms is lessened.

@jducanator @jdeblese @chrisdickinson @brianloveswords @tonistiigi @juliangruber

dominictarr commented 10 years ago

@jduncanator I know what unrolled code looks like, posting that into this issue doesn't help. I have already refactored browserify to be mulitple modules, and if you can just publish his latest work as a module then I'll use that too. I don't really care whether or not it's an org.

@jduncanator the fork you are working from is out of date. just please publish the hashes you've done as their own modules as you go. that is the whole point of modules!

jduncanator commented 10 years ago

I understand. I'm not publishing them until I'm happy with the improvements and until I've finished other modules. These are being used in production so when I push changes to my site, I'll publish a module.

AES is coming too.

EDIT: Looking into AES and other Ciphers. We are going to run into issues very quickly with the lack of a decent random number generator implementation in crypto-browserify. I have my CSPRNG but work won't let me publicly make it available, atleast until we push all our new code to the website. Sorry.

jprichardson commented 10 years ago

I have already refactored browserify to be mulitple modules, and if you can just publish his latest work as a module then I'll use that too. I don't really care whether or not it's an org.

@dominictarr Sorry, I didn't see any deps for crypto-browserify other than sha1.js so I assumed it wasn't refactored into multiple modules. But nice work on the project overall. I was just thinking that an org would give more clarity to users and developers. If you should change your mind and want to do the crypto-browserify org, let me know - naturally, you'd be the owner.

dominictarr commented 10 years ago

there is only sha.js which implements sha1 and sha256. there is still md5 the old way, but of course you should not use md5 (or sha1) in a new system.

I would like to bring in https://github.com/jduncanator/dh-browserify but it needs tests.

aes is the next thing, and then we'll have a shallow coverage of the openssl features (we can do the sort of things openssl can do, although we won't support all the algorithms)

then sign and verify, though I have been working on stuff for curves, since that in better than RSA nowadays.

jprichardson commented 10 years ago

Excellent. I have AES completed: https://github.com/cryptocoinjs/aes with tests included. It's extracted from SJCL. It still needs ebc and cbc bolted on though.

jduncanator commented 10 years ago

@dominictarr & @jprichardson: you are both still missing the point that without secure and reliable random number generation, all symmetric ciphers a basically useless. We need a decent and secure source of IVs and we can't do that with Math.random

jprichardson commented 10 years ago

@jduncanator how do they use a RNG? AES doesn't, at least not that I'm aware of. (Forgive the ignorance on my part). I'm fully aware of the problems of using an insecure RNG btw. Also, what's wrong with window.crypto.getRandomValues() ?

jduncanator commented 10 years ago

When sending AES encrypted messages across the network (anywhere it can be "publicly" seen) the IV needs to be random and unpredictable. In fact, that's basically what the algorithm depends on. When encrypting files, the IV is single use so that's fine, but just like TCP sequence numbers, AES encrypted messages need to have 100% unpredictable IVs to avoid plain text attacks and other side channel attacks. Weak IV = Weak Encryption. Math.random is extremely predictable in the overall scheme of random number generation so we need something A LOT better.

jprichardson commented 10 years ago

@jduncanator Yeah, I'm aware of the weakness in Math.random() for cryptography. What's wrong with using window.crypto.getRandomValues() though?

jduncanator commented 10 years ago

It's not widely supported and we would be throwing away backward compatibility.

jprichardson commented 10 years ago

@jduncanator If there is anything worse than a shoddy RNG, it's making people feel safe with bad crypto. i.e. IMHO, screw the legacy browsers. Crypto is too important to get incorrect. Yeah, there are seeding techniques a la http://bitaddress.org, but they're not very user friendly.

jduncanator commented 10 years ago

Sadly unsupported browsers are more numerous than you think. Sure chrome and Firefox support it (I think) but not even internet explorer 9 has crypto API and that makes up 30% browser share. I'll share my ported Linux CSPRNG as soon as I can under a license work lets me...

dominictarr commented 10 years ago

@jduncanator hmm, wheren't you working on getRandom? what happened to that?

jduncanator commented 10 years ago

@dominictarr Thats what I was talking about above.

dominictarr commented 10 years ago

we can just borrow the RNG from sjcl until we want to rewrite it.

dcousens commented 10 years ago

We are currently at version 3. Perhaps best to close and open a new issue if necessary? Most of the goals were reached, granted however the lack of a substitute RNG still exists.