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.
72 lines (71 loc) • 2.72 kB
TypeScript
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as keyManager from '../../../internal/key_manager';
import { PbHpkePrivateKey, PbKeyData, PbMessage } from '../../../internal/proto';
import * as util from '../../../internal/util';
import { HybridDecrypt } from '../hybrid_decrypt';
/**
* A container for methods that generate new HPKE key pairs.
* These methods are separate from the KeyManager as their functionality is
* independent of the primitive of the corresponding KeyManager.
* @final
*/
declare class HpkePrivateKeyFactory implements keyManager.PrivateKeyFactory {
/**
* Generates a new random HPKE key according to 'keyFormat'.
*
* @param keyFormat is either a KeyFormat
* proto or a serialized KeyFormat proto
* @return the new generated HPKE private key
*/
newKey(keyFormat: PbMessage | Uint8Array): Promise<PbHpkePrivateKey>;
/**
* Generates a new random HPKE key based on the "serialized_key_format" and
* returns it as a KeyData proto.
*/
newKeyData(serializedKeyFormat: PbMessage | Uint8Array): Promise<PbKeyData>;
/**
* Returns an HPKE public key data extracted from the given serialized HPKE
* private key.
*/
getPublicKeyData(serializedPrivateKey: Uint8Array): PbKeyData;
/**
* The input keyFormat is either deserialized (in case that the input is
* Uint8Array) or checked to be an HpkeKeyFormat-proto (otherwise).
*/
private static getKeyFormatProto;
private static deserializeKeyFormat;
}
/**
* Key manager that generates new {@link HpkePrivateKey} keys and produces new
* instances of {@link HpkeDecrypt} primitives.
*
* @final
*/
export declare class HpkePrivateKeyManager implements keyManager.KeyManager<HybridDecrypt> {
private static readonly SUPPORTED_PRIMITIVE;
static KEY_TYPE: string;
keyFactory: HpkePrivateKeyFactory;
/**
* Constructs an instance of the 'HybridDecrypt' primitive for a given HPKE
* key.
*/
getPrimitive(primitiveType: util.Constructor<HybridDecrypt>, key: PbKeyData | PbMessage): Promise<HybridDecrypt>;
/** Returns true if this KeyManager supports 'HpkePrivateKey' key type. */
doesSupport(keyType: string): boolean;
/** Returns the URL which identifies the keys managed by this KeyManager. */
getKeyType(): string;
/**
* Returns the type of primitive which can be generated by this KeyManager,
* i.e. 'HybridDecrypt'
*/
getPrimitiveType(): typeof HybridDecrypt;
getVersion(): number;
getKeyFactory(): HpkePrivateKeyFactory;
private static getKeyProto;
private static getKeyProtoFromKeyData;
}
export {};