import { CryptoPrimitives } from './CryptoPrimitives'; import { HMACUtils } from './HMACUtils'; import { ShamirClass } from './shamir'; import { AESUtils } from './AES'; import { RSAUtils } from './RSA'; /** * Allows to use the expo-kryptom module as crypto primitives. This is necessary when building expo (react native) apps. */ export declare class NativeCryptoPrimitivesBridge implements CryptoPrimitives { constructor(expoKryptomModule: { Aes: AesService; Rsa: RsaService; Hmac: HmacService; StrongRandom: StrongRandomService; Digest: DigestService; }); readonly AES: AESUtils; readonly HMAC: HMACUtils; readonly RSA: RSAUtils; readonly shamir: ShamirClass; private readonly strongRandom; private readonly digest; randomBytes(n: number): Uint8Array; randomUuid(): string; sha256(data: ArrayBuffer | Uint8Array): Promise; sha512(data: ArrayBuffer | Uint8Array): Promise; } declare enum AesAlgorithm { AesCbcPkcs7 = "AesCbcPkcs7" } declare enum RsaEncryptionAlgorithm { OaepWithSha1 = "OaepWithSha1", OaepWithSha256 = "OaepWithSha256" } declare enum RsaSignatureAlgorithm { PssWithSha256 = "PssWithSha256" } type RsaAlgorithm = RsaEncryptionAlgorithm | RsaSignatureAlgorithm; declare enum HmacAlgorithm { HmacSha512 = "HmacSha512" } interface HmacKey { algorithmIdentifier: HmacAlgorithm; } interface AesKey { algorithmIdentifier: AesAlgorithm; } interface RsaKeyPair { algorithmIdentifier: RsaAlgorithm; } interface RsaPrivateKey { algorithmIdentifier: RsaAlgorithm; } interface RsaPublicKey { algorithmIdentifier: RsaAlgorithm; } type PrivateRsaKeyJwk = { alg: string; d: string; dp: string; dq: string; e: string; ext: boolean; key_ops: string[]; n: string; p: string; q: string; qi: string; }; type PublicRsaKeyJwk = { alg: string; e: string; ext: boolean; key_ops: string[]; n: string; }; interface AesService { generateKey(algorithmIdentifier: AesAlgorithm, size: number): Promise; encrypt(data: Uint8Array, key: AesKey, iv: Uint8Array | null): Promise; decrypt(ivAndEncryptedData: Uint8Array, key: AesKey): Promise; exportRawKey(key: AesKey): Promise; importRawKey(rawKey: Uint8Array, algorithmIdentifier: AesAlgorithm): Promise; } interface RsaService { generateKey(algorithmIdentifier: RsaAlgorithm, size: number): Promise; encrypt(data: Uint8Array, key: RsaPublicKey): Promise; decrypt(data: Uint8Array, key: RsaPrivateKey): Promise; signature(data: Uint8Array, key: RsaPrivateKey): Promise; verify(signature: Uint8Array, data: Uint8Array, key: RsaPublicKey): Promise; exportPrivateKeyPkcs8(key: RsaPrivateKey): Promise; exportPrivateKeyJwk(key: RsaPrivateKey): Promise; exportPublicKeySpki(key: RsaPublicKey): Promise; exportPublicKeyJwk(key: RsaPublicKey): Promise; importPrivateKeyPkcs8(privateKeyPkcs8: Uint8Array, algorithmIdentifier: RsaAlgorithm): Promise; importPrivateKeyJwk(privateKey: PrivateRsaKeyJwk, algorithmIdentifier: RsaAlgorithm): Promise; importPublicKeySpki(publicKeySpki: Uint8Array, algorithmIdentifier: RsaAlgorithm): Promise; importPublicKeyJwk(publicKey: PublicRsaKeyJwk, algorithmIdentifier: RsaAlgorithm): Promise; importKeyPair(privateKeyPkcs8: Uint8Array, algorithmIdentifier: RsaAlgorithm): Promise; } interface HmacService { generateKey(algorithmIdentifier: HmacAlgorithm): Promise; sign(data: Uint8Array, key: HmacKey): Promise; verify(signature: Uint8Array, data: Uint8Array, key: HmacKey): Promise; exportRawKey(key: HmacKey): Promise; importRawKey(rawKey: Uint8Array, algorithmIdentifier: HmacAlgorithm): Promise; } interface StrongRandomService { randomBytes(length: number): Uint8Array; randomUUID(): string; } interface DigestService { sha256(data: Uint8Array): Promise; } export {};