How to use the @aws-crypto/material-management-node.KeyringTraceFlag.WRAPPING_KEY_DECRYPTED_DATA_KEY function in @aws-crypto/material-management-node

To help you get started, we’ve selected a few @aws-crypto/material-management-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-encryption-sdk-javascript / modules / raw-rsa-keyring-node / src / raw_rsa_keyring_node.ts View on Github external
const _unwrapKey = async (material: NodeDecryptionMaterial, edk: EncryptedDataKey) => {
      /* Precondition: Private key must be defined to support decrypt. */
      if (!privateKey) throw new Error('No private key defined in constructor.  Decrypt disabled.')

      const trace: KeyringTrace = {
        keyName: this.keyName,
        keyNamespace: this.keyNamespace,
        flags: KeyringTraceFlag.WRAPPING_KEY_DECRYPTED_DATA_KEY
      }

      const { buffer, byteOffset, byteLength } = edk.encryptedDataKey
      const encryptedDataKey = Buffer.from(buffer, byteOffset, byteLength)
      const unencryptedDataKey = privateDecrypt(
        { key: privateKey, padding },
        encryptedDataKey)
      return material.setUnencryptedDataKey(unencryptedDataKey, trace)
    }