Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
#Scrypt For NodeJS node-scrypt is a native node C++ wrapper for Colin Percival's scrypt key derivation utility. It is fully asynchronous (in fact, there is no synchronous mode due to the time input of scrypt which would block the event loop).
node-scrypt wraps scrypt's atomic key derivation operations. In other words, this library does not implement an authentication scheme, it merely implements the atomics that are necessary for it.
##What Is Scrypt? Scrypt is an advanced crypto library used for key derivation for user authentication (i.e. password authenticator). More information can be found:
For additional interest, also read the key derivation function article on wikipedia.
##Why Use Scrypt? It is probably the most advanced means of performing authentication out there. This is quote taken from a comment in hacker news:
Passwords hashed with scrypt with sufficiently-high strength values (there are 3 tweakable input numbers) are fundamentally impervious to being cracked. I use the word "fundamental" in the literal sense, here; even if you had the resources of a large country, you would not be able to design any hardware (whether it be GPU hardware, custom-designed hardware, or otherwise) which could crack these hashes. Ever. (For sufficiently-small definitions of "ever". At the very least "within your lifetime"; probably far longer.)
The three tweakable inputs mentioned above are as follows (Quoting from the author):
maxtime
maxtime will instruct scrypt to spend at most maxtime seconds computing the derived encryption key from the password; for encryption, this value will determine how secure the encrypted data is, while for decryption this value is used as an upper limit (if scrypt detects that it would take too long to decrypt the data, it will exit with an error message).
maxmemfrac
maxmemfrac instructs scrypt to use at most the specified fraction of the available RAM for computing the derived encryption key. For encryption, increasing this value might increase the security of the encrypted data, depending on the maxtime value; for decryption, this value is used as an upper limit and may cause scrypt to exit with an error.
maxmem
maxmem instructs scrypt to use at most the specified number of bytes of RAM when computing the derived encryption key.
Here are some pros and cons for using it:
###Pros
I will end this section with a quote from Colin Percival (author of scrypt):
We estimate that on modern (2009) hardware, if 5 seconds are spent computing a derived key, the cost of a hardware brute-force attack against scrypt is roughly 4000 times greater than the cost of a similar attack against bcrypt (to find the same password), and 20000 times greater than a similar attack against PBKDF2.
###Cons There is just one con: It is a relatively new library (only been around since 2009). Cryptographers don't really like new libraries for production deployment as it has not been battle tested. That being said, it is being actively used in Tarsnap (as mentioned above) and the author is very active.
#Security Issues/Concerns As should be the case with any security tool, this library should be scrutinized by anyone using it. If you find or suspect an issue with the code- please bring it to my attention and I'll spend some time trying to make sure that this tool is as secure as possible.
#Dependencies
#Installation Instructions As of now (Dec 2012), this library has been tested and works on Linux (Ubuntu to be exact). ##From NPM
npm install scrypt
##From Source
You will need node-gyp
to get this to work (install it if you don't have it: npm install -g node-gyp
):
git clone https://github.com/barrysteyn/node-scrypt.git
cd node-scrypt
node-gyp configure build
#Usage I will write an example application that uses scrypt for authentication in a few days time. What follows here is using scrypt to encrypt and decrypt data. Note that for the case of pure encryption and decryption, scrypt is not a good candidate (rather use AES). Remember that scrypt is designed to be a key derivation function, and therefore being slow is an advantage.
var scrypt = require("scrypt");
var message = "Hello World";
var password = "Pass";
var max_time = 1.0;
scrypt.encrypt(message, password, max_time, function(err, cipher) {
console.log(cipher);
scrypt.decrypt(cipher, password, max_time, function(err, msg) {
console.log(msg);
});
});
Note that maxmem
and maxmemfrac
can also be passed to the functions. If they are not passed, then maxmem
defaults to 0
and maxmemfrac
defaults to 0.5
. If these values are to be passed, then they must be passed after max_time
and before the callback function like so:
var scrypt = require("scrypt");
var message = "Hello World";
var password = "Pass";
var max_time = 1.0;
var maxmem = 1; //Defaults to 0 if not set
var maxmemfrac = 1.5; //Defaults to 0.5 if not set
scrypt.encrypt(message, password, max_time, maxmem, maxmemfrac, function(err, cipher) {
console.log(cipher);
scrypt.decrypt(cipher, password, max_time, maxmem, maxmemfrac, function(err, msg) {
console.log(msg);
});
});
#Still To Do
FAQs
The scrypt crypto library for NodeJS
The npm package scrypt receives a total of 5,150 weekly downloads. As such, scrypt popularity was classified as popular.
We found that scrypt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.