export class CipherType { constructor(id: number) { this.id = id } id: number } export class KeyUsage { constructor(id: number) { this.id = id } id: number } export class KeyStatus { constructor(id: number) { this.id = id } id: number } export class AlgoType { constructor(id: number) { this.id = id } id: number } export class KeyType { constructor(id: number) { this.id = id } id: number } export namespace Constants { export const DEFAULT_KEYID_LEN: number = 16 export type KeyIdStatus = 'Malformed' | 'Decryptable' | 'Feasible' | 'UnDecryptable' export enum KStoreType { ENC_STORE = 1, DEC_STORE = 2, } export class CipherTypes { static Weak: CipherType = new CipherType(0) static Regular: CipherType = new CipherType(1) static Large: CipherType = new CipherType(2) } export class KeyUsages { static N: KeyUsage = new KeyUsage(-1) static E: KeyUsage = new KeyUsage(0) static D: KeyUsage = new KeyUsage(1) static ED: KeyUsage = new KeyUsage(2) static from_value(value: string): KeyUsage { if (!value) { throw new Error(`key usage is null.`) } if (value === 'N') { return this.N } else if (value === 'E') { return this.E } else if (value === 'D') { return this.D } else if (value === 'ED') { return this.ED } throw new Error(`unknown key usage.`) } } export class KeyStatuses { static Active: KeyStatus = new KeyStatus(0) static Suspended: KeyStatus = new KeyStatus(1) static Revoked: KeyStatus = new KeyStatus(2) static from_value(value: number) { if (value === 0) { return this.Active } else if (value === 1) { return this.Suspended } else if (value === 2) { return this.Revoked } throw new Error(`unknown key status.`) } } export class KeyTypes { static Aes: KeyType = new KeyType(0) static from_value(value: string) { if (!value) { throw new Error(`key type is null.`) } if (value === 'AES') { return this.Aes } throw new Error(`unknown key type.`) } } export class AlgoTypes { static AesCbc128: AlgoType = new AlgoType(4) static aes_cbc_128() { return this.AesCbc128 } static from_value(value: number) { if (value === 4) { return this.AesCbc128 } throw new Error(`unknown algo type.`) } } }