From: Chris Duncan Date: Tue, 24 Dec 2024 08:05:54 +0000 (-0800) Subject: Delete unused files. X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=ba06848f32adc3aa89828e4e949547825ff8ffb5;p=libnemo.git Delete unused files. --- diff --git a/src/lib/workers/nano-nacl.d.ts b/src/lib/workers/nano-nacl.d.ts deleted file mode 100644 index 78c4f78..0000000 --- a/src/lib/workers/nano-nacl.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -// Type definitions for TweetNaCl.js - -export as namespace nacl; - -declare var nacl: nacl; -export = nacl; - -declare namespace nacl { - export interface BoxKeyPair { - publicKey: Uint8Array; - secretKey: Uint8Array; - } - - export interface SignKeyPair { - publicKey: Uint8Array; - secretKey: Uint8Array; - } - - export interface secretbox { - (msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; - open(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; - readonly keyLength: number; - readonly nonceLength: number; - readonly overheadLength: number; - } - - export interface scalarMult { - (n: Uint8Array, p: Uint8Array): Uint8Array; - base(n: Uint8Array): Uint8Array; - readonly scalarLength: number; - readonly groupElementLength: number; - } - - namespace boxProps { - export interface open { - (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null; - after(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null; - } - - export interface keyPair { - (): BoxKeyPair; - fromSecretKey(secretKey: Uint8Array): BoxKeyPair; - } - } - - export interface box { - (msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; - before(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array; - after(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array; - open: boxProps.open; - keyPair: boxProps.keyPair; - readonly publicKeyLength: number; - readonly secretKeyLength: number; - readonly sharedKeyLength: number; - readonly nonceLength: number; - readonly overheadLength: number; - } - - namespace signProps { - export interface detached { - (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; - verify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean; - } - - export interface keyPair { - (): SignKeyPair; - fromSecretKey(secretKey: Uint8Array): SignKeyPair; - fromSeed(secretKey: Uint8Array): SignKeyPair; - } - } - - export interface sign { - (msg: Uint8Array, secretKey: Uint8Array): Uint8Array; - open(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null; - detached: signProps.detached; - keyPair: signProps.keyPair; - readonly publicKeyLength: number; - readonly secretKeyLength: number; - readonly seedLength: number; - readonly signatureLength: number; - } - - export interface hash { - (msg: Uint8Array): Uint8Array; - readonly hashLength: number; - } -} - -declare interface nacl { - randomBytes(n: number): Uint8Array; - secretbox: nacl.secretbox; - scalarMult: nacl.scalarMult; - box: nacl.box; - sign: nacl.sign; - hash: nacl.hash; - verify(x: Uint8Array, y: Uint8Array): boolean; - setPRNG(fn: (x: Uint8Array, n: number) => void): void; -} diff --git a/src/lib/workers/passkey.ts b/src/lib/workers/passkey.ts deleted file mode 100644 index 648f1bd..0000000 --- a/src/lib/workers/passkey.ts +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-FileCopyrightText: 2024 Chris Duncan -// SPDX-License-Identifier: GPL-3.0-or-later - -/** -* Web Worker which generates an AES-GCM `CryptoKey`. The message sent to this -* worker should be an object containing a password string and initialization -* vector bytes which are used to generate an intermediate PBKDF2 `CryptoKey`. -* This intermediate key is used to derive the final key that is returned to the -* calling function as an ArrayBuffer. This buffer can ultimately be processed -* using the `importKey()` method of the SubtleCrypto interface. -*/ -async function passkey () { - /** - * Message listener for this Web Worker thread. - */ - addEventListener('message', async (message: any) => { - const { password, iv } = message.data ?? message - const keyBuffer = await keygen(password, iv) - postMessage(keyBuffer, { transfer: [keyBuffer] }) - }) - - /** - * Derives an AES-GCM key from a password and initialization vector. - * - * @param {string} password - User-provided text to use as initial key data - * @param {Uint8Array} iv - Initialization vector in byte representation - * @returns {Promise} - */ - async function keygen (password: string, iv: Uint8Array): Promise { - const extractable = true - const notExtractable = false - const passkey = await crypto.subtle.importKey( - 'raw', - new TextEncoder().encode(password), - 'PBKDF2', - notExtractable, - ['deriveBits', 'deriveKey'] - ) - const key = await crypto.subtle.deriveKey( - { name: 'PBKDF2', hash: 'SHA-512', salt: iv, iterations: 210000 }, - passkey, - { name: 'AES-GCM', length: 256 }, - extractable, - ['encrypt'] - ) - return crypto.subtle.exportKey('raw', key) - } -} - -const workerUrl = `data:text/javascript,(${passkey.toString()})()` -export { workerUrl }