Cipher.d.ts
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { BufferedBlockAlgorithm, BufferedBlockAlgorithmProps } from "../BufferedBlockAlgorithm";
import type { Word32Array } from "../../Word32Array";
export interface CipherProps extends BufferedBlockAlgorithmProps {
key: Word32Array;
iv: Word32Array;
transformMode: number;
}
export declare type PropsWithKey<T extends CipherProps> = Partial<T> & Pick<T, "key">;
export declare class Cipher extends BufferedBlockAlgorithm {
static readonly ENC_TRANSFORM_MODE = 1;
static readonly DEC_TRANSFORM_MODE = 2;
static readonly keySize: number;
static readonly ivSize: number;
protected _props: PropsWithKey<CipherProps>;
protected _transformMode: number;
protected _key: Word32Array;
protected _iv?: Word32Array;
constructor(props: PropsWithKey<CipherProps>);
get iv(): Word32Array | undefined;
/**
* Resets this cipher to its initial state.
* @example
* cipher.reset();
*/
reset(data?: Word32Array, nBytes?: number): void;
/**
* Adds data to be encrypted or decrypted.
* @param {Word32Array|string} dataUpdate The data to encrypt or decrypt.
* @return {Word32Array} The data after processing.
* @example
* var encrypted = cipher.process('data');
* var encrypted = cipher.process(wordArray);
*/
process(dataUpdate: Word32Array | string): Word32Array;
/**
* Finalizes the encryption or decryption process.
* Note that the finalize operation is effectively a destructive, read-once operation.
* @param {Word32Array|string?} dataUpdate The final data to encrypt or decrypt.
* @return {Word32Array} The data after final processing.
* @example
* var encrypted = cipher.finalize();
* var encrypted = cipher.finalize('data');
* var encrypted = cipher.finalize(wordArray);
*/
finalize(dataUpdate?: Word32Array | string): Word32Array;
/**
* @abstract
*/
protected _doReset(): void;
/**
* @abstract
*/
protected _doProcessBlock(words: number[], offset: number): void;
/**
* @abstract
*/
protected _doFinalize(): Word32Array;
/**
* Creates this cipher in encryption mode.
*
* @param {Word32Array} key The key.
* @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation.
* @return {Cipher} A cipher instance.
* @example
* var cipher = AES.createEncryptor(keyWordArray, { iv: ivWordArray });
*/
static createEncryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher;
/**
* Creates this cipher in decryption mode.
* @param {Word32Array} key The key.
* @param {Partial<CipherProps>?} props (Optional) The configuration options to use for this operation.
* @return {Cipher} A cipher instance.
* @example
* var cipher = AES.createDecryptor(keyWordArray, { iv: ivWordArray });
*/
static createDecryptor(key: Word32Array, props?: Partial<CipherProps>): Cipher;
}