-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Ruby: add CryptoAlgorithms library #7273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've revisited this since the first version and changed it s.t. |
|
Updated again, with a few significant changes:
|
b80633a to
0481385
Compare
nickrolfe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, LGTM. It'd be good to get sign-off from JS/Python as well.
|
You add the |
True, I added this for symmetry with I've removed this predicate. |
…hmNames Strong encryption algorithms: ARIA, IDEA, SEED, SM4 Strong block modes: CBC, CFB, CTR, OFB
Co-authored-by: Nick Rolfe <nickrolfe@github.com>
…AlgorithmNames.qll
cb516f8 to
3da98ec
Compare
This PR copies
CryptoAlgorithms.qllto Ruby and extends it with some additional encryption algorithms (ARIA,IDEA,SM4,SEED,GOST,CAST,CHACHA,CAMELLIA- all classified as strong) and block modes (ECB- classified as weak, andCBC,CCM,CFB,CTR,GCM,OFB- classified as strong).It then adds a new library,
OpenSSL.qll, for Ruby that models parts of theOpenSSL::Cipherlibrary component. The aim here is mostly to be able to take astring cipherNamethat can be used to construct anOpenSSL::Cipherinstance, s.t. we can pass judgement on whether that cipher is "strong" or "weak". This is used in #7313 to decide if this is a safe way to encrypt cookies or not. Some of the implementation here is taken from the JavaEncryption.qlllibrary, in particular the regex matching code.The
OpenSSLRuby library itself wraps a COpenSSL/LibreSSLlibrary. The known ciphers here were generated usingOpenSSL 1.1.1landLibreSSL 3.4.1, which each support some algorithms that the other does not.Original description
Adds a
CryptoAlgorithms.qlllibrary for Ruby. This is similar to the libraries of the same name for JS and Python, but currently not identical to them. It would be good to unify as much of these as possible, but there may be some parts of this Ruby implementation that are language specific and need to move out into a separate file.The main change here, relative to the JS/Python version, is the addition of an
OpenSSLmodule. This is specifically to support an upcoming PR which will use this to determine strong/weak ciphers supported by OpenSSL. These ciphers can include both the underlying block encryption algorithm and also the block mode (e.g.aes-256-ecb) - which in particular means that we say that a cipher is weak if either of these components are considered weak. These ciphers are encoded in theOpenSSLCipherclass, which is added here as a type ofCryptographicAlgorithm.I've uploaded the diff of this change relative to the existing versions at https://gist.github.com/alexrford/92426d26cb6b0def5d8967d49a0be0a4. In addition to the OpenSSL related changes, I've pulled in some of the regex matching code from the C++ Encryption.qll library, and added a few more encryption algorithms (Cast, GOST, ChaCha).
@RasmusWL I believe you worked on unifying the JS and Python versions of this library? I'd be interested to get your thoughts on what to do in this case, in particular if:
CryptoAlgorithms.qllas it is (perhaps with Cast/GOST/ChaCha added)?