node-noise
Version:
46 lines (45 loc) • 2.15 kB
TypeScript
import type { bytes, bytes32 } from '../@types/basic';
import type { CipherState, MessageBuffer, SymmetricState } from '../@types/handshake';
import type { ICryptoInterface } from '../crypto';
import { Nonce } from '../nonce';
import { KeyPair } from '../@types/keypair';
import { NoiseSession } from '../@types/handshake';
export declare abstract class AbstractHandshake {
crypto: ICryptoInterface;
constructor(crypto: ICryptoInterface);
abstract initSession(initiator: boolean, prologue: bytes32, s: KeyPair, remotePublicKey: bytes | null): NoiseSession;
encryptWithAd(cs: CipherState, ad: Uint8Array, plaintext: Uint8Array): bytes;
decryptWithAd(cs: CipherState, ad: Uint8Array, ciphertext: Uint8Array, dst?: Uint8Array): {
plaintext: bytes;
valid: boolean;
};
protected hasKey(cs: CipherState): boolean;
protected createEmptyKey(): bytes32;
protected isEmptyKey(k: bytes32): boolean;
protected encrypt(k: bytes32, n: Nonce, ad: Uint8Array, plaintext: Uint8Array): bytes;
protected encryptAndHash(ss: SymmetricState, plaintext: bytes): bytes;
protected decrypt(k: bytes32, n: Nonce, ad: bytes, ciphertext: bytes, dst?: Uint8Array): {
plaintext: bytes;
valid: boolean;
};
protected decryptAndHash(ss: SymmetricState, ciphertext: bytes): {
plaintext: bytes;
valid: boolean;
};
protected dh(privateKey: bytes32, publicKey: bytes32): bytes32;
protected mixHash(ss: SymmetricState, data: bytes): void;
protected getHash(a: Uint8Array, b: Uint8Array): bytes32;
protected mixKey(ss: SymmetricState, ikm: bytes32): void;
protected initializeKey(k: bytes32): CipherState;
protected initializeSymmetric(protocolName: string): SymmetricState;
protected hashProtocolName(protocolName: Uint8Array): bytes32;
split(ss: SymmetricState): {
cs1: CipherState;
cs2: CipherState;
};
protected writeMessageRegular(cs: CipherState, payload: bytes): MessageBuffer;
protected readMessageRegular(cs: CipherState, message: MessageBuffer): {
plaintext: bytes;
valid: boolean;
};
}