Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
WebCryptoMaterialsManager // eslint-disable-line no-unused-vars
} from '@aws-crypto/material-management-browser'
import {
deserializeSignature,
MessageHeader, // eslint-disable-line no-unused-vars
deserializeFactory,
kdfInfo,
decodeBodyHeader,
aadFactory,
concatBuffers,
der2raw,
HeaderInfo // eslint-disable-line no-unused-vars
} from '@aws-crypto/serialize'
import { fromUtf8, toUtf8 } from '@aws-sdk/util-utf8-browser'
const deserialize = deserializeFactory(toUtf8, WebCryptoAlgorithmSuite)
const { messageAADContentString, messageAAD } = aadFactory(fromUtf8)
export interface DecryptResult {
messageHeader: MessageHeader
plaintext: Uint8Array
}
export async function decrypt (
cmm: KeyringWebCrypto|WebCryptoMaterialsManager,
ciphertext: Uint8Array
): Promise {
/* If the cmm is a Keyring, wrap it with WebCryptoDefaultCryptographicMaterialsManager. */
cmm = cmm instanceof KeyringWebCrypto
? new WebCryptoDefaultCryptographicMaterialsManager(cmm)
: cmm