At 7/9/16 03:16 PM, MSGhero wrote:
security
I heard my name.
Q: let's say the as3crypto algos are all good, and someone translates them to haxe. When haxe does its thing to each target, is there anything that can happen that would render the algos all of a sudden insecure? It's just math to me, and I don't see what bad could happen (temp variables will lose scope, etc).
Should be fine, but it would ultimately depend on the algorithm and the implementation. If you're encrypting a file using AES then a malicious program digging into memory will find the key somewhere. It may not know what it's found or where the key is if it's even looking for it, but it's in memory somewhere. Alternatively, if you're using something like DH/RSA then I suppose it's possible the client's private key can be leaked on the network somehow by a bad implementation. It's definitely going to be in memory for at least a good while, though, so I'd honestly be more worried about that than anything else. Any way you look at it, I wouldn't worry much. As long as the implementation follows RFC standards, everything will be fine.
Besides, isn't there a native crypto library implementation for Haxe somewhere anyway? What are you really worried about?
As a side-note on the topic of public/private keys at hand:
The whole thing works just as it sounds. I'll use PGP as a quick example, but the schamtics follows the same any way you look at it.
You create a public/private keypair that are cryptographically sound in one way or another (many specifications for such) such as PGP. You give your public key to as many people as you possibly can and you keep your private key as secure as you possibly can (mine is encrypted with three different algorithms and three different passwords, one of which is randomly generated and I don't even know what it is). The private key is for signing and decryption, and the public key is for verification and encryption. Neither can be used for the other's job.
For example: You sign a file with your private key. The public key can then verify that signature to guarantee that file A) hasn't been tampered with, and B) is from you. You can also sign text and whatnot, but entire files are more impressive :)
Another example: Someone uses your public key to encrypt a file/message to you. You use your private key to decrypt that message. Nobody else but you, with your private key, can decrypt that message.
Public/private keypairs are used in RSA as well, usually granted with a DH-like key exchange algorithm (see my previous post on that + quantum computing earlier) - this is common in the TLS protocol (which is most common with HTTPS)
Less common (but still very common) are public/private keys for, say, RESTful applications. The public key usually encrypts data to the private key in these situations, though in this particular instance (the one in this thread) it seems the private key (on your server's end) is used to sign the message sent to NG's server (the public key) - This most probably is an RSA implementation, but I could be wrong and NG may just have a ton of public keys (one for each user)
(I also could be completely wrong about NG's implementation, I just guessed at it based on your posts)
Edit:
The specifications, by the way, are pretty clear-cut. The biggest mistake I can foresee is not using a CSPRNG when prompted for random numbers (either from your own code or the library you're using). Though I swear to god if I see you use Dual_EC_DRGB I will take your code and bash you over the head with it until you learn >:(