UNPKG

pooja-docucomb-tink-crypto

Version:

A multi-language, cross-platform library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.

28 lines (25 loc) 786 B
/** * @license * Copyright 2020 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import {SecurityException} from '../exception/security_exception'; import {KeysetWriter} from './keyset_writer'; import {PbEncryptedKeyset, PbKeyset} from './proto'; /** * KeysetWriter knows how to write a keyset or an encrypted keyset. * * @final */ export class BinaryKeysetWriter implements KeysetWriter { encodeBinary(keyset: PbKeyset|PbEncryptedKeyset): Uint8Array { // keep serializeBinary calls monomorphic if (keyset instanceof PbKeyset) { return keyset.serializeBinary(); } if (keyset instanceof PbEncryptedKeyset) { return keyset.serializeBinary(); } throw new SecurityException('unexpected type for keyset.'); } }