browserify-hybrid-crypto
Version:
TypeScript implementation Hybrid encryption and signing library built on Web Crypto (AES + RSA + HMAC).
38 lines (34 loc) • 1.18 kB
text/typescript
export type AESAlgorithm = "AES-GCM" | "AES-CBC" | "AES-CTR";
export type AESKeyLength = 128 | 192 | 256;
export type HMACHash = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
export type RSAOAEPHash = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
export interface HybridCryptoOptions {
/** AES block cipher mode for data encryption */
aesAlgorithm?: AESAlgorithm;
/** AES key length in bits */
aesKeyLength?: AESKeyLength;
/** Initialization vector length in bytes (12 for GCM, 16 for CBC/CTR) */
ivLength?: number;
/** Hash function for HMAC signing */
hmacHash?: HMACHash;
/** Hash function for RSA-OAEP key encryption */
rsaOaepHash?: RSAOAEPHash;
/** Counter for AES-CTR mode (if used) */
ctrCounter?: Uint8Array;
/** Counter length in bits for AES-CTR mode (default: 64) */
ctrLength?: number;
}
export interface HybridEncryption {
encryptedSessionKey: ArrayBuffer;
encryptedSigningKey: ArrayBuffer;
encryptedData: ArrayBuffer;
signature: ArrayBuffer;
iv: Uint8Array;
}
export interface NormalizedHybridEncryption {
encryptedSessionKey: string;
encryptedSigningKey: string;
encryptedData: string;
signature: string;
iv: string;
}