UNPKG

aes-universal-native

Version:
89 lines (84 loc) 4.7 kB
import { AbstractCbcCipher } from 'aes-universal'; import { AbstractGcmCipher } from 'aes-universal'; import { AesCipher } from 'aes-universal'; import { CbcDecryptInternalParams } from 'aes-universal'; import { CbcEncryptInternalParams } from 'aes-universal'; import { GcmDecryptInternalParams } from 'aes-universal'; import { GcmEncryptInternalParams } from 'aes-universal'; import { GcmEncryptInternalResult } from 'aes-universal'; import { GenerateTagParams } from 'aes-universal'; import { RandomBytes } from 'aes-universal'; /** * Native implementation of the AES cipher using node-forge. * * This class extends the base AesCipher class and provides implementations * for both CBC and GCM modes using node-forge functionality. */ export declare class NativeAesCipher extends AesCipher<NativeCbcCipher, typeof NativeCbcCipher, NativeGcmCipher, typeof NativeGcmCipher> { /** * Creates a new instance of NativeAesCipher. * * @param randomBytes - Function that generates cryptographically secure random bytes * Must implement the RandomBytes interface from aes-universal */ constructor(randomBytes: RandomBytes); } /** * Class representing a Native CBC mode cipher implementation using node-forge. * Extends the AbstractCbcCipher class to provide AES-CBC encryption and decryption * functionality for native environments using the node-forge cryptographic library. */ export declare class NativeCbcCipher extends AbstractCbcCipher { /** * Constructs a NativeCbcCipher instance. * @param randomBytes - The random bytes function to be used for cryptographic operations. */ constructor(randomBytes: RandomBytes); /** * Performs the internal encryption process using the AES-CBC algorithm via node-forge. * @param params - The arguments required for encryption, including the raw encryption key, IV, and plaintext. * @returns A promise that resolves to the encrypted data as a Uint8Array. * @throws Error if encryption fails */ encryptInternal: ({ encRawKey, iv, plaintext, }: CbcEncryptInternalParams) => Promise<Uint8Array>; /** * Performs the internal decryption process using the AES-CBC algorithm via node-forge. * @param params - The arguments required for decryption, including the raw encryption key, IV, and ciphertext. * @returns A promise that resolves to the decrypted data as a Uint8Array. * @throws Error if decryption fails */ decryptInternal: ({ encRawKey, iv, ciphertext, }: CbcDecryptInternalParams) => Promise<Uint8Array>; /** * Generates a tag using the HMAC algorithm via node-forge. * @param params - The arguments required for tag generation, including the raw MAC key, MAC data, and key bits. * @returns A promise that resolves to the generated tag as a Uint8Array. */ generateTag: ({ macRawKey, macData, keyBitLength, }: GenerateTagParams) => Promise<Uint8Array>; } /** * Class representing a Native GCM mode cipher implementation using node-forge. * Extends the AbstractGcmCipher class to provide AES-GCM encryption and decryption * functionality for native environments using the node-forge cryptographic library. */ export declare class NativeGcmCipher extends AbstractGcmCipher { /** * Constructs a NativeGcmCipher instance. * @param randomBytes - The random bytes function to be used for cryptographic operations. */ constructor(randomBytes: RandomBytes); /** * Performs the internal encryption process using the AES-GCM algorithm via node-forge. * @param params - The arguments required for encryption, including the raw encryption key, IV, plaintext, and additional authenticated data. * @returns A promise that resolves to the encrypted data and authentication tag as a Uint8Array. * @throws Error if encryption fails or IV length is invalid */ encryptInternal: ({ encRawKey, iv, plaintext, aad, }: GcmEncryptInternalParams) => Promise<GcmEncryptInternalResult>; /** * Performs the internal decryption process using the AES-GCM algorithm via node-forge. * @param params - The arguments required for decryption, including the raw encryption key, IV, ciphertext, authentication tag, and additional authenticated data. * @returns A promise that resolves to the decrypted data as a Uint8Array. * @throws Error if decryption fails, authentication fails, or IV length is invalid */ decryptInternal: ({ encRawKey, iv, ciphertext, tag, aad, }: GcmDecryptInternalParams) => Promise<Uint8Array>; } export { }