-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
openssl_cipher_iv_length #22304
Comments
@nodejs/security-wg (proposed new API, I don't think there's any security implications but being cautious) |
What about ciphers such as CCM or OCB that don't have a single fixed IV length? |
@nodejs/crypto Is this something we'd consider adding? If likely not, should this be closed? |
@Trott I can see that this might be useful. However, there is no single correct IV length for some ciphers. I believe OpenSSL simply returns the shortest permitted length. |
I think this could be a nice addition. Is this easy information to get from openssl? |
Even a minimum would be useful. It doesn't seem reasonable that an API can return "length invalid", and yet somehow not know what lengths are valid. I'll take a look at this when I have some time. |
I don't know. What business do you have using a cipher if you don't know its key size or IV size? Adding functions to help automate key/IV creation seems like setting up people to shoot themselves in the foot. (Same argument goes for the block size, that currently isn't exposed either. Anyone want to argue that it should be?) Take the OP's example code. If it derived the key/IV size automatically and you tricked it into picking RC4-40, you can guess the key in at most 2^40 tries. Foot, meet bullet. |
I share this concern. |
Example, a file encryption tool where the user specifies the file, algorithm, and a pass phrase, and the utility runs the PBKDF, generates the key, creates a random sufficiently large IV, and writes CMS encrypted data to disk. The tool could have a data structure of acceptable algorithms, and with each alg keep its key size, its IV size, etc. But if OpenSSL already includes this, why duplicate this into user-land? |
In Go lang we have a helper: https://golang.org/pkg/crypto/aes/ (BlockSize) ...and why not in Node.js?
I have one |
Simple method for retrieving basic information about a cipher (such as block length, expected or default iv length, key length, etc) Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: nodejs#22304
Simple method for retrieving basic information about a cipher (such as block length, expected or default iv length, key length, etc) Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: nodejs#22304 PR-URL: nodejs#35368 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
I see some issues about
invalid IV length
orInvalid key length
.In PHP, there is a helper method (
openssl_cipher_iv_length
) that return the correct length for IV.Node could have a static method for this, something like:
crypto.cipherivLength(algorithm: string): number
crypto.cipherkeyLength(algorithm: string): number
Simple example:
Complex example:
The text was updated successfully, but these errors were encountered: