export interface AESUtils { encryptWithRawKey(rawKey: string, plainData: ArrayBuffer | Uint8Array): Promise; encrypt(cryptoKey: CryptoKey, plainData: ArrayBuffer | Uint8Array, rawKey?: string): Promise; decryptWithRawKey(rawKey: string, plainData: ArrayBuffer | Uint8Array): Promise; /** * * @param cryptoKey (CryptoKey) * @param encryptedData (ArrayBuffer) * @param rawKey * @returns {Promise} will be ArrayBuffer */ decrypt(cryptoKey: CryptoKey, encryptedData: ArrayBuffer | Uint8Array, rawKey?: string): Promise; /** * @deprecated this method is not correct: in some cases decryption may not fail even if the wrong key is used: if the * first provided keys are wrong and the last one is correct the decryption will succeed for sure, but there is a small * chance that you will get garbage */ decryptSome(cryptoKeys: CryptoKey[], uint8Array: Uint8Array): Promise; /** * * @param toHex boolean, if true, it returns hex String * @returns {Promise} either Hex string or CryptoKey */ generateCryptoKey(toHex: false): Promise; generateCryptoKey(toHex: true): Promise; generateCryptoKey(toHex: boolean): Promise; generateIV(ivByteLength: number): Uint8Array; /** * This function return a promise which will be the key Format will be either 'raw' or 'jwk'. * JWK: Json Web key (ref. http://tools.ietf.org/html/draft-ietf-jose-json-web-key-11) * * @param cryptoKey CryptoKey * @param format will be 'raw' or 'jwk' * @returns {Promise} will the AES Key */ exportKey(cryptoKey: CryptoKey, format: 'raw'): Promise; exportKey(cryptoKey: CryptoKey, format: 'jwk'): Promise; exportKey(cryptoKey: CryptoKey, format: 'jwk' | 'raw'): Promise; /** * the ability to import a key that have already been created elsewhere, for use within the web * application that is invoking the import function, for use within the importing web application's * origin. This necessiates an interoperable key format, such as JSON Web Key [JWK] which may be * represented as octets. * * https://chromium.googlesource.com/chromium/blink.git/+/6b902997e3ca0384c8fa6fe56f79ecd7589d3ca6/LayoutTests/crypto/resources/common.js * * @param format 'raw' or 'jwk' * @param aesKey * @returns {*} */ importKey(format: 'jwk' | 'raw', aesKey: JsonWebKey | ArrayBuffer | Uint8Array): Promise; } export declare class AESUtilsImpl implements AESUtils { /********* AES Config **********/ ivLength: number; aesAlgorithmEncryptName: string; aesKeyGenParams: AesKeyGenParams; private crypto; private _debug; set debug(value: boolean); constructor(crypto?: Crypto); encryptWithRawKey(rawKey: string, plainData: ArrayBuffer | Uint8Array): Promise; encrypt(cryptoKey: CryptoKey, plainData: ArrayBuffer | Uint8Array, rawKey?: string): Promise; decryptWithRawKey(rawKey: string, plainData: ArrayBuffer | Uint8Array): Promise; /** * * @param cryptoKey (CryptoKey) * @param encryptedData (ArrayBuffer) * @param rawKey * @returns {Promise} will be ArrayBuffer */ decrypt(cryptoKey: CryptoKey, encryptedData: ArrayBuffer | Uint8Array, rawKey?: string): Promise; decryptSome(cryptoKeys: CryptoKey[], uint8Array: Uint8Array): Promise; /** * * @param toHex boolean, if true, it returns hex String * @returns {Promise} either Hex string or CryptoKey */ generateCryptoKey(toHex: false): Promise; generateCryptoKey(toHex: true): Promise; generateIV(ivByteLength: number): Uint8Array; /** * This function return a promise which will be the key Format will be either 'raw' or 'jwk'. * JWK: Json Web key (ref. http://tools.ietf.org/html/draft-ietf-jose-json-web-key-11) * * @param cryptoKey CryptoKey * @param format will be 'raw' or 'jwk' * @returns {Promise} will the AES Key */ exportKey(cryptoKey: CryptoKey, format: 'raw'): Promise; exportKey(cryptoKey: CryptoKey, format: 'jwk'): Promise; /** * the ability to import a key that have already been created elsewhere, for use within the web * application that is invoking the import function, for use within the importing web application's * origin. This necessiates an interoperable key format, such as JSON Web Key [JWK] which may be * represented as octets. * * https://chromium.googlesource.com/chromium/blink.git/+/6b902997e3ca0384c8fa6fe56f79ecd7589d3ca6/LayoutTests/crypto/resources/common.js * * @param format 'raw' or 'jwk' * @param aesKey * @returns {*} */ importKey(format: 'jwk' | 'raw', aesKey: JsonWebKey | ArrayBuffer | Uint8Array): Promise; } export declare const AES: AESUtilsImpl;