You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As best as I can tell, the root cause of this is that decrypt calls getEnvKeychain which calls importKeychain which itself calls decryptString and then decryptAesGcm which passes to decryptAesGcmSync. It is here, in decryptAesGcmSync that the Node's Decipher returns an empty array after the final update + final, which is unexpected.
I tried writing a failing test, but got blocked on being able to pass stdin to Commander in jest. Something like this is the foundation though:
importprogramfrom'./cli';constOLD_ENV=process.env;beforeEach(()=>{jest.resetModules();process.env={
...OLD_ENV,CLOAK_MASTER_KEY: 'k1.aesgcm256.2itF7YmMYIP4b9NNtKMhIx2axGi6aI50RcwGBiFq-VA=',};});afterAll(()=>{process.env=OLD_ENV;});test('decrypt',()=>{constcipher='v1.aesgcm256.710bb0e2.F5wkSytfdVv4xvtN.8uNajc7ufhVmMFpDdzWgKMKhOY4ZR2OSv1DFjvnm'constexpected='Hello, World !'expect(()=>{program.parse(['decrypt',cipher]);}).toReturnWith(expected)})
The text was updated successfully, but these errors were encountered:
jdjkelly
changed the title
CLI command decrypt fails
CLI command decrypt fails with 'Key is not available'
Dec 29, 2022
Your example uses the master key to encrypt, but then uses the keychain to try and decrypt. The master key is not part of the keychain (as it's used to encrypt the keychain), hence the message Key is not available.
Example:
As best as I can tell, the root cause of this is that
decrypt
callsgetEnvKeychain
which callsimportKeychain
which itself callsdecryptString
and thendecryptAesGcm
which passes todecryptAesGcmSync
. It is here, indecryptAesGcmSync
that the Node'sDecipher
returns an empty array after the finalupdate
+final
, which is unexpected.I tried writing a failing test, but got blocked on being able to pass stdin to Commander in jest. Something like this is the foundation though:
The text was updated successfully, but these errors were encountered: