How to use the @aws-crypto/material-management-node.getEncryptHelper 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 / encrypt-node / src / encrypt_stream.ts View on Github external
.then(async (material) => {
      const { dispose, getSigner } = getEncryptHelper(material)

      const { getCipher, messageHeader, rawHeader } = getEncryptionInfo(material, frameLength)

      wrappingStream.emit('MessageHeader', messageHeader)

      const encryptStream = getFramedEncryptStream(getCipher, messageHeader, dispose, plaintextLength)
      const signatureStream = new SignatureStream(getSigner)

      pipeline(encryptStream, signatureStream)

      wrappingStream.setReadable(signatureStream)
      // Flush the rawHeader through the signatureStream
      rawHeader.forEach(buff => signatureStream.write(buff))

      // @ts-ignore until readable-stream exports v3 types...
      wrappingStream.setWritable(encryptStream)
github aws / aws-encryption-sdk-javascript / modules / encrypt-node / src / encrypt_stream.ts View on Github external
export function getEncryptionInfo (material : NodeEncryptionMaterial, frameLength: number) {
  const { kdfGetCipher } = getEncryptHelper(material)
  const { encryptionContext } = material

  const messageId = randomBytes(MESSAGE_ID_LENGTH)
  const { id, ivLength } = material.suite
  const messageHeader: MessageHeader = Object.freeze({
    version: SerializationVersion.V1,
    type: ObjectType.CUSTOMER_AE_DATA,
    suiteId: id,
    messageId,
    encryptionContext,
    encryptedDataKeys: Object.freeze(material.encryptedDataKeys), // freeze me please
    contentType: ContentType.FRAMED_DATA,
    headerIvLength: ivLength,
    frameLength
  })