How to use the @aws-crypto/serialize.uInt16BE function in @aws-crypto/serialize

To help you get started, we’ve selected a few @aws-crypto/serialize 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 / cache-material / src / build_cryptographic_materials_cache_key_helpers.ts View on Github external
async function buildEncryptionMaterialCacheKey (
    partition: string,
    { suite, encryptionContext }: EncryptionRequest<s>
  ) {
    const algorithmInfo = suite
      ? [new Uint8Array([1]), uInt16BE(suite.id)]
      : [new Uint8Array([0])]

    const key = await sha512(
      await sha512(fromUtf8(partition)),
      ...algorithmInfo,
      await encryptionContextHash(encryptionContext)
    )
    return toUtf8(key)
  }
</s>
github aws / aws-encryption-sdk-javascript / modules / cache-material / src / build_cryptographic_materials_cache_key_helpers.ts View on Github external
async function buildDecryptionMaterialCacheKey (
    partition: string,
    { suite, encryptedDataKeys, encryptionContext }: DecryptionRequest<s>
  ) {
    const { id } = suite

    const key = await sha512(
      await sha512(fromUtf8(partition)),
      uInt16BE(id),
      ...(await encryptedDataKeysHash(encryptedDataKeys)),
      BIT_PAD_512,
      await encryptionContextHash(encryptionContext)
    )
    return toUtf8(key)
  }
</s>