/** * @license * @preserve * * KeeeX SAS Public code * https://keeex.me * Copyright 2013-2023 KeeeX All Rights Reserved. * * These computer program listings and specifications, herein, * are and remain the property of KeeeX SAS. The intellectual * and technical concepts herein are proprietary to KeeeX SAS * and may be covered by EU and foreign patents, * patents in process, trade secrets and copyright law. * * These listings are published as a way to provide third party * with the ability to process KeeeX data. * As such, support for public inquiries is limited. * They are provided "as-is", without warrany of any kind. * * They shall not be reproduced or copied or used in whole or * in part as the basis for manufacture or sale of items unless * prior written permission is obtained from KeeeX SAS. * * For a license agreement, please contact: * * */ import { type Awaitable } from "@keeex/utils/types/types.js"; import type { CryptoKey } from "./keystypes.js"; /** * Symmetric algorithms available. * * @public */ export declare enum Algorithms { AESCTR = "AES-CTR", AESCBC = "AES-CBC" } /** * A basic cipher context that provide means to encrypt/decrypt data. * * @public */ export interface CipherContext { /** Add input data */ update: (data: Uint8Array) => Awaitable; /** Must be called after processing to return the last block of data */ final: () => Awaitable; } /** * Interface to implement symmetric encryption in a cryptographic provider. * * To implement symmetric encryption within a cryptographic provider, at least one of the raw * immediate functions or the context functions must be provided. * If the other is not available, a fallback will be used using the provided one. * * @public */ export interface CipherProvider { /** * Return the expected size of the IV for the given algorithm. * * Optional; basic IV size are setup in the crypto library as fallback. */ getIVSize?(algorithm: Algorithms): Awaitable; /** * Generate an IV for the given algorithm. * * Optional; random generation using the library is used with values from `getIVSize()`. */ generateIV?(algorithm: Algorithms): Awaitable; /** * Simple interface to cipher a buffer in one call. * * Optional if `createEncryptionContext()` is provided. */ encryptRawImmediate?(data: Uint8Array, iv: Uint8Array, key: CryptoKey): Awaitable; /** * Counterpart to encryptRawImmediate(). * * Optional if `createDecryptionContext()` is provided. */ decryptRawImmediate?(data: Uint8Array, iv: Uint8Array, key: CryptoKey): Awaitable; /** * Create a generic encryption context. * * Optional if `encryptRawImmediate()` is provided, but it is recommended to have this function if * possible to handle large data. */ createEncryptionContext?(key: CryptoKey, iv: Uint8Array): Awaitable; /** * Create a generic decryption context. * * Optional if `decryptRawImmediate()` is provided, but it is recommended to have this function if * possible to handle large data. */ createDecryptionContext?(key: CryptoKey, iv: Uint8Array): Awaitable; } /** @internal */ export declare const isCipherProvider: import("@keeex/utils/types/types.js").TypePredicate;