TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

SJCL – Stanford JavaScript Crypto Library

160 pointsby remxabout 8 years ago

16 comments

coleptabout 8 years ago
Shameless plug: SJCL is a great library and easy to work with.<p>I&#x27;ve used it to build a non-profit decentralized encryption tool that can be used to send and receive files that will self-decrypt using SJCL, JavaScript FileReader, and HTML5 download attributes.<p>User A creates a password to encrypt a file using this client-side mechanism - which produces a self-decrypting HTML file. User B opens this HTML file in their browser which will ask them for the password to decrypt the file allowing them to download the original file all without a server. The homepage can be downloaded and self-hosted at will.<p><a href="https:&#x2F;&#x2F;zipit.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;zipit.io&#x2F;</a><p>edit: I have uploaded it to Github today for easy self-hosting: <a href="https:&#x2F;&#x2F;github.com&#x2F;colepatrickturner&#x2F;zipit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;colepatrickturner&#x2F;zipit</a>
评论 #13822957 未加载
评论 #13822232 未加载
jpgoldbergabout 8 years ago
It is important to separate three security concerns:<p>1. Crypto delivered to the browser over HTTPS depends on the integrity of HTTPS.<p>2. A browser is a very hostile environment (injected JS, other browser extensions, etc.)<p>3. JavaScript may not be the best language for coding certain things (e.g., it is hard to remove strings from memory)<p>Depending on your use, some of these might be larger concerns than others. For us, 1Password.com, (1) is the biggest concern for those using the web-app. Our approach is to be very strict about TLS (TLS 1.2 only, HSTS, etc) and to encourage use of the native clients over the web-app.
评论 #13823386 未加载
评论 #13821973 未加载
lucideerabout 8 years ago
In every one of these threads, there are inevitable comments along the lines of &quot;in-browser crypto is inherently unsecure&quot;, which often follows to a more general &quot;javascript crypto is inherently unsecure&quot;.<p>This question might be slightly off-topic here, given this seems to be an in-browser library, but can anyone who knows a bit more about this topic than I comment on the state of out-of-browser JS crypto (e.g. NodeJS). The browser as environment does seem to introduce a stigma around security to the entire JS ecosystem, and I wonder if its warranted.
评论 #13821647 未加载
评论 #13821779 未加载
评论 #13821616 未加载
Quiarkabout 8 years ago
Browser crypto is really problematic. For one, the client is downloading the crypto JS implementation (almost) every time they are using the app. Server compromised? crypto.js is rendered useless. HTTPS certificate compromised? crypto.js is useless.<p>And also:<p>XSS vuln on your website? crypto.js is useless since attacker will just exfiltrate your private key &#x2F; password through XSS.<p>The browser is wonderful for UI but mashing together code and markup and then trying to permissively parse and execute it never goes well for security.
评论 #13825893 未加载
评论 #13821242 未加载
评论 #13821448 未加载
评论 #13821612 未加载
0XAFFEabout 8 years ago
How does this compare to libsodium(.js)[1][2]?<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;jedisct1&#x2F;libsodium" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jedisct1&#x2F;libsodium</a> [2] <a href="https:&#x2F;&#x2F;github.com&#x2F;jedisct1&#x2F;libsodium.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jedisct1&#x2F;libsodium.js</a>
评论 #13824002 未加载
gbrown_about 8 years ago
For someone not really familiar with javascript could someone explain how sensitive information is removed from memory when no longer needed? Does the runtime expose semantics to ensure memory is zeroed?<p>Also given javascript is garbage collected are there concerns about timing attacks? Or can you prevent the GC from running in critical sections like Go (I assume Java offers this too)?
评论 #13822409 未加载
评论 #13822418 未加载
评论 #13822789 未加载
babyabout 8 years ago
More interestingly, and recent, there is Web Crypto: <a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Web_Crypto_API" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;Web_Crypto_...</a><p>Although I have no idea about the state of the thing.
评论 #13821595 未加载
blablabla123about 8 years ago
There&#x27;s a discussion going on of people who claim doing Crypto in the browser is super insecure. (Crockford is one of them) I wonder to what degree this is true or what needs to be done to do at least some basic crypto in the browser like AES for personal user data.
评论 #13820977 未加载
评论 #13821057 未加载
评论 #13821118 未加载
评论 #13820999 未加载
calebmabout 8 years ago
On a related note, I made a little browser-based file encryption app: <a href="https:&#x2F;&#x2F;hypervault.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;hypervault.github.io&#x2F;</a> which uses the Triplesec library (<a href="https:&#x2F;&#x2F;github.com&#x2F;keybase&#x2F;triplesec" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;keybase&#x2F;triplesec</a>), which seemed a nice alternative to SJCL.<p>Since I know someone will bring up the insecurity of browser crypto: this app is entirely self-contained (the HTML file can be saved and run offline).
aabajianabout 8 years ago
One of my first jobs involved encrypting medical data in the client-side browser. The plan was to generate a new RSA private&#x2F;public key pair whenever a new user joined. The keys themselves were encrypted using the user&#x27;s password (w&#x2F;AES) on the client side. We stored the encrypted RSA keys and the user&#x27;s password hash on a server. When a user logged in we would validate the user&#x27;s password hash, and return the user&#x27;s encrypted keys. The user would <i>have</i> to know their password to decrypt the RSA key. The theory was that no medical data was visible on our server, even to us. We also used standard SSL for all connections.<p>The challenge was implementation. At the time there were no AES block-cipher JavaScript modules. My solution was to use GWT to compile BouncyCastle&#x27;s Java library into JavaScript. I had to strip the library of all low-level I&#x2F;O calls and replace the BigInteger class with a GWT-JSNI-wrapped version of the BigInteger class I found online. That BigInteger class was a side-project of a Stanford graduate student: <a href="http:&#x2F;&#x2F;www-cs-students.stanford.edu&#x2F;~tjw&#x2F;jsbn&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www-cs-students.stanford.edu&#x2F;~tjw&#x2F;jsbn&#x2F;</a><p>He also included a JavaScript implementation of RSA. Long story short, within a year there were several cryptography libraries, but I like to think we were ahead of our time.
评论 #13823964 未加载
评论 #13824212 未加载
fenguinabout 8 years ago
We&#x27;ve been using SJCL for 4 years in our browser extension to encrypt incognito mode bookmarks [1] and one of the things we&#x27;ve really appreciated is its backward compatibility -- version updates have been complete drop-in replacements which has made developing on this very pain-free.<p>[1] <a href="https:&#x2F;&#x2F;hushbookmarks.com" rel="nofollow">https:&#x2F;&#x2F;hushbookmarks.com</a>
nidxabout 8 years ago
I use in browser crypto to get &quot;better than plaintext&quot; encryption for my login pages. I am dealing with a server infrastructure that won&#x27;t let me easily or cheaply add https to client sites. I use a 512BIT RSA Key Pair regenerated every 5-10 seconds. I know it could be MITM&#x27;ed or Brute forced in about a day or two. Its not real security, but it is better than nothing. I wanted to stop sniffing for http logins (would have mitigated that cloudflare issue last week).
Sharmaabout 8 years ago
I am 99% sure this post was submitted to HN after user read following comment yesterday:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13810217" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13810217</a>
libertymcateerabout 8 years ago
So, hopefully without shooting my mouth off (this time), here are some lessons I have been learning (the hard way) about SJCL:<p>* The SJCL library appears to be really great. It is super simple to use and has great documentation. Dan Boneh has a reputation that precedes him. I&#x27;ve been pointed in the direction of his work multiple times, independently, by different sources. [0]<p>* The SJCL library is only going to be as good as its implementation in the browser. For instance, how is it getting in the browser? Is it stored in an extension, or is it being loaded dynamically? If it is loaded dynamically, you are going to be vulnerable to a whole host of attacks, including cross-site and MITM. That aside, even if it is loaded dynamically and it gets there in one piece, is it loaded into the runtime securely? This last one is the real kicker for me. If you are implementing it as injected code onto a third party page, you are leaving it open to trivial manipulation by third parties. I was savaged by Nikcub for this, and rightly so. For embarrassing exchange, you can see my history.<p>* What is the threat model? Browser-based encryption is only ever going to deal with certain threat models - as we are seeing in the recent days, there is good reason to assume that end-point security on a host of devices may be compromised by state actors. Please note <i>I am not declaring this to be the case</i> based on my authority - but it seems like in a world where we are getting leaks off of handsets prior to encryption by Signal and Whatsapp, assuming end-points are secure is a big assumption. Additionally, I know the wikileaks Vault7 only list compromises up to Chrome ~35 and for Android below Kitkat [1], I&#x27;ve read this list is likely dated, and I don&#x27;t think it is fair to assume that the development of zero days has stopped there. Accordingly, if you are trying to prevent intrusion from state actors, then there is reason to suspect that browser-based implementation will never get you there.<p>* Key generation and exchange remains an issue. Lots of people more qualified than I state that javascript RNGs are just not that great, which can significantly reduce entropy on keys. [2] On top of this, I want to talk about entropy more at length, in particular reference to SJCL: SJCL goes to some length to create &#x27;random&#x27; (I personally cannot verify this) salts and initialization vectors. However, as far as I can tell, you have two choices: you either store those separately and transmit them separately from the message, which creates a whole host of issues in the transmission and storage of those salts, or you send them with the message. As far as I can tell, if you send them with the message, the extra entropy they introduce is not relevant for warding off brute force attacks or attacks based on trying to compromise the password (e.g. dictionary attacks), but are only useful against crib-based attacks or other cryptanalytic attacks - which, again, as far as I can tell, if you are going up against the sort of entity that has the resources to actually try and crack AES128 or AES256 by attacking the cipher, rather than the key, I suspect you are dealing with some very nasty people and using javascript crypto is not your best bet.<p>* Importantly, and critically, security is a conclusion, not a feature. Adding SJCL onto a communications protocol is not going to make it secure. In fact, it has been expressed by people better than me that that the author of software cannot self-authenticate that it is secure.[3] It needs to be subjected to third party (and, ideally, public scrutiny). So, in the end, if you are going to be using a library like SJCL, it is important to have the <i>particular implementation</i> tested by disinterested third parties. Though the math and code behind SJCL may be secure, actually getting it into a piece of software that people want to use introduces a gigantic raft of issues.<p>On background, the reason I know this as a (software) lawyer is because I have been working with SJCL on a node based application for quite some time. I do not represent it is secure - if I have in the past, that was in error and an oversight on my part (hat-tip to all the people on HN who have very rightly pointed this out). However, working on it has been extremely instructive and has confirmed what I always suspected to be true - if you want to be able to say something is secure, you need to be working with people who work on security as a primary occupation, not a hobby or a side-interest. It is too enormous, complex and ever-changing a field for anyone to be an &#x27;expert&#x27; at it unless it is their primary concern.<p>As always, interested in any feedback or counterpoints. Especially on the math.<p>[0] <a href="http:&#x2F;&#x2F;crypto.stanford.edu&#x2F;~dabo&#x2F;" rel="nofollow">http:&#x2F;&#x2F;crypto.stanford.edu&#x2F;~dabo&#x2F;</a> ; <a href="https:&#x2F;&#x2F;www.linkedin.com&#x2F;in&#x2F;dan-boneh-8b599020&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.linkedin.com&#x2F;in&#x2F;dan-boneh-8b599020&#x2F;</a><p>[1] <a href="https:&#x2F;&#x2F;wikileaks.org&#x2F;ciav7p1&#x2F;cms&#x2F;page_11629096.html" rel="nofollow">https:&#x2F;&#x2F;wikileaks.org&#x2F;ciav7p1&#x2F;cms&#x2F;page_11629096.html</a><p>[2] <a href="http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;17280390&#x2F;can-local-storage-ever-be-considered-secure&#x2F;24677597#24677597" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;17280390&#x2F;can-local-storag...</a> - hat tip to <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=bmh_ca" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;user?id=bmh_ca</a> , who, based on this thread, I have discovered was the author of that post on stackoverflow, which is instructive.<p>[3] <a href="https:&#x2F;&#x2F;www.schneier.com&#x2F;blog&#x2F;archives&#x2F;2011&#x2F;04&#x2F;schneiers_law.html" rel="nofollow">https:&#x2F;&#x2F;www.schneier.com&#x2F;blog&#x2F;archives&#x2F;2011&#x2F;04&#x2F;schneiers_law...</a>
woranlabout 8 years ago
Is there a market for end-to-end encrypted app in the browser?
评论 #13821984 未加载
评论 #13821534 未加载
评论 #13821668 未加载
评论 #13821600 未加载
评论 #13821262 未加载
评论 #13822437 未加载
singularity2001about 8 years ago
Does it contain elliptic NSA curses &#x2F; curves ?