55 points · by bigiain · 15y ago · 43 comments
It requires a receiver who is a) knowledgeable enough to decrypt it using something like openssl and b) have access to the actual private key.
If that's the case it is highly likely that this person is either capable of using something like PGP or facilitate a file upload form on the apparently available website. Both of which are at least as secure and a whole lot more convenient.
Something related to this I would be really interested in would be a way to encrypt a file client-side, in the browser using javascript prior to uploading it (without the need for the user to do special tricks beyond picking a password). So far this only seems remotely possible using something like flash or silverlight.
Much encryption can be done in javascript.
https://ziyan.info/2008/10/javascript-rsa/
http://www-cs-students.stanford.edu/~tjw/jsbn/
http://www.beanizer.org/site/index.php/en/Articles/Practical...
If on the other hand you don't exclusively communicate with SSL-using web developers, you're better off using a PGP implementation. Unfortunately Symantec bought PGP Corporation, but GPG4Win[1] is free, as are GPG-based PGP implementations for almost every other platform.
Worried about it being hard? It really isn't. In fact it's easy to get up and running with encrypting your Gmail in Firefox[2] even if you have a Mac or something else[3].
[1] - http://www.gpg4win.org/
[2] - http://www.instructables.com/id/Send-and-Receive-Encrypted-E...
[3] - http://www.instructables.com/id/Encrypt-your-Gmail-Email/
It's not for communicating with web developers. It's for publicly and provably, but responsibly exposing vulnerabilities in software. The people/entities who write such software are likely to have a public website with SSL. If they don't, it's unlikely to be very important or widely used software. In that context, PGP makes no sense.
http://www.gnupg.org/gph/en/manual.html
The biggest thing to worry about is that you only want the private key on systems you trust. If you put your private key on a USB stick, and use the local library or computer lab, you've already lost the battle. If you're running a totally infected Win95 machine, you've already lost the battle.
Second biggest thing is to make sure you properly generate a revocation certificate, and a backup, and store them in a location you consider secure. (And maybe that secure location is just a shoebox in your bedroom closet unless you're worried about the NSA or something.) Then if you realize you've done something stupid, you can just revoke the key and create a new one.
Other than that, there's not much to screw up if you follow the default settings when creating a key with gpg.
For email, I would also highly recommend using a local MUA that connects to gmail. Most people use Thunderbird + Enigmail, but there are other options. Enigmail also has a pretty good manual that covers both the how and why.
http://enigmail.mozdev.org/documentation/handbook.php.html
The various gpg-related mailing lists are also pretty friendly. They're low-traffic enough that people are always happy to answer basic questions; no RTFM replies.
That's why PHP provides the openssl_seal function can do exactly the same (and more) as the given code. (http://php.net/manual/en/function.openssl-seal.php)
When you Google for it there are also implementations for other languages available.
The things that keep you from doing this in the real world with RSA are security and speed.
It's first of all much slower to perform a single RSA operation than it is to perform the AES block transform. AES involves no bignum math at all, let alone bignum modular multiplication.
Secondly and more importantly, RSA encryption is fundamentally volatile and dangerous. As an exercise, go implement it in Python or Ruby (you're going to find it's remarkably easy, since both those languages automatically promote to bignums). RSA is just a simple formula. As a result, there are a variety of pitfalls to using it safely. Among the important ones is the fact that you can't safely encrypt related messages, and that messages require a certain proportion of random padding.
This, on the other hand, turns any web developer's SSL cert into their PGP key without their advance cooperation. (They don't have to have one, understand why they need one, or create one and publish the public key. They just have to have an https site, like all my clients already do.) Limited utility, since decrypting is impossible for regular people and larger corps would have that private key locked down like crazy, but a very neat hack. I could actually see myself using it, too, for secure geek-2-geek transmissions.
s_client.c calls SSL_CTX_set_verify() (the default verifier). Results from that can be obtained from SSL_get_verify_result() and are documented in verify(1).
All of the CRL/revocation-related return codes there are marked "unused". There is no mention of OCSP.
I found found a "crl_check/crl_check_all" option for verify(1). Command line help mentions an "ocsphelper". OpenSSL does have a separate OCSP client. But I don't think any of this machinery is activated by default.
Also note that there are interesting complications in relation to file data long-term storage on SSD drives. It should be investigated.
I don't know of an implementation that uses RSA encryption that doesn't use RSA to encrypt a (heavily padded, very random) key which they then use to encrypt the final payload using say AES or IDEA (in the original PGP).
See:
https://secure.wikimedia.org/wikipedia/en/wiki/Session_key
https://secure.wikimedia.org/wikipedia/en/wiki/Ciphertext-on...
http://academic.csuohio.edu/zhao_w/teaching/Old/EEC693-S07/l...
You create some random key K.
You encrypt k using the public key of the recipient, ie. e(k).
You encrypt the message using K.
You send both of those to the recipient. A cyphertext only attack can recover K from your message M. It is not then possible to recover a private key from K.
In neither case do you ever have the private key, as such it cannot ever be recovered from a core dump. In this script it seems like they are simply doing this twice, for some unknown reason.
See:
https://secure.wikimedia.org/wikipedia/en/wiki/Fortuna_%28PR...
Basically /dev/random takes entropy from the system and feeds it to you.
/dev/urandom is a psudorandom number generator that reseeds from entropy as it gets it. Ie. if it has no entropy, your random numbers are anything but random.
In any case, this is entirely irrelevant to the discussion at hand. You can absolutely use /dev/urandom to make a one-shot crypto key. You shouldn't wire /dev/urandom up into an online cryptosystem (don't use it to produce DH parameters, for instance), but even then, urandom isn't going to be how your system really gets broken.
In your case, experimenting with encrypting whole files with RSA instead of using RSA to exchange keys is what's really going to break your system. This is almost a decent example of how people obsess over the wrong things in cryptosystem design, and why perhaps generalist programmers should stay far, far away from this stuff.