How to use the @aws-crypto/client-node.needs function in @aws-crypto/client-node

To help you get started, we’ve selected a few @aws-crypto/client-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 / integration-node / src / integration_tests.ts View on Github external
export async function testEncryptVector ({ name, keysInfo, encryptOp, plainTextData }: EncryptTestVectorInfo, decryptOracle: URL): Promise {
  try {
    const cmm = encryptMaterialsManagerNode(keysInfo)
    const { result: encryptResult } = await encrypt(cmm, plainTextData, encryptOp)

    const decryptResponse = await got.post(decryptOracle, {
      headers: {
        'Content-Type': 'application/octet-stream',
        'Accept': 'application/octet-stream'
      },
      body: encryptResult,
      encoding: null
    })
    needs(decryptResponse.statusCode === 200, 'decrypt failure')
    const { body } = decryptResponse
    const result = plainTextData.equals(body)
    return { result, name }
  } catch (err) {
    return { result: false, name, err }
  }
}
github aws / aws-encryption-sdk-javascript / modules / integration-node / src / decrypt_materials_manager_node.ts View on Github external
export function rsaPadding (keyInfo: RsaKeyInfo) {
  const paddingAlgorithm = keyInfo['padding-algorithm']
  const paddingHash = keyInfo['padding-hash']

  if (paddingAlgorithm === 'pkcs1') return constants.RSA_PKCS1_PADDING
  needs(paddingHash === 'sha1', 'Not supported at this time.')

  return constants.RSA_PKCS1_OAEP_PADDING
}