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
exportasyncfunctionaesTest(){/* You need to specify a name * and a namespace for raw encryption key providers. * The name and namespace that you use in the decryption keyring *must* be an exact, * *case-sensitive* match for the name and namespace in the encryption keyring. */constkeyName='aes-name'constkeyNamespace='aes-namespace'/* The wrapping suite defines the AES-GCM algorithm suite to use. */constwrappingSuite=RawAesWrappingSuiteIdentifier.AES256_GCM_IV12_TAG16_NO_PADDING// Get your plaintext master key from wherever you store it.// eslint-disable-next-line @typescript-eslint/no-magic-numbersconstunencryptedMasterKey=randomBytes(32)/* Configure the Raw AES keyring. */constkeyring=newRawAesKeyringNode({
keyName,
keyNamespace,
unencryptedMasterKey,
wrappingSuite,})/* Encryption context is a *very* powerful tool for controlling and managing access. * It is ***not*** secret! * Encrypted data is opaque. * You can use an encryption context to assert things about the encrypted data. * Just because you can decrypt something does not mean it is what you expect. * For example, if you are are only expecting data from 'us-west-2', * the origin can identify a malicious actor. * See: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/concepts.html#encryption-context */constcontext={stage: 'demo',purpose: 'simple demonstration app',origin: 'us-west-2',}/* Find data to encrypt. A simple string. */constcleartext='asdf'/* Encrypt the data. */const{ result }=awaitencrypt(keyring,cleartext,{encryptionContext: context,})/* Decrypt the data. */const{ plaintext, messageHeader }=awaitdecrypt(keyring,result)/* Grab the encryption context so you can verify it. */const{ encryptionContext }=messageHeader/* Verify the encryption context. * If you use an algorithm suite with signing, * the Encryption SDK adds a name-value pair to the encryption context that contains the public key. * Because the encryption context might contain additional key-value pairs, * do not add a test that requires that all key-value pairs match. * Instead, verify that the key-value pairs you expect match. */for(const[key,value]ofObject.entries(context)){if(encryptionContext[key]!==value)thrownewError('Encryption Context does not match expected values')}/* Return the values so the code can be tested. */return{ plaintext, result, cleartext }}
I get following error:
Error: Unsupported dataKey type
Using nodejs v18.15.0 and @aws-crypto/client-node v3.2.0.
Since I'm just getting familiar with Encryption SDK I am not sure what seems to be the culprit at the moment. Might even be duplicate of #970.
Appreciate any helpful tips.
The text was updated successfully, but these errors were encountered:
Problem:
I tried to run example in https://github.com/aws/aws-encryption-sdk-javascript/blob/master/modules/example-node/src/aes_simple.ts:
I get following error:
Using nodejs v18.15.0 and @aws-crypto/client-node v3.2.0.
Since I'm just getting familiar with Encryption SDK I am not sure what seems to be the culprit at the moment. Might even be duplicate of #970.
Appreciate any helpful tips.
The text was updated successfully, but these errors were encountered: