19 lines
625 B
TypeScript
19 lines
625 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { deriveKey, sha256 } from "../../src/kdbx/crypto";
|
|
|
|
describe("kdbx crypto helpers", () => {
|
|
test("sha256 hashes data deterministically", () => {
|
|
const digest = sha256("abc");
|
|
expect(Array.from(digest)).toHaveLength(32);
|
|
});
|
|
|
|
test("deriveKey rejects invalid rounds", () => {
|
|
expect(() => deriveKey("secret", new Uint8Array([1, 2, 3]), 0)).toThrow("Invalid key derivation rounds");
|
|
});
|
|
|
|
test("deriveKey produces a 32-byte key", () => {
|
|
const key = deriveKey("secret", new Uint8Array([1, 2, 3]), 1000);
|
|
expect(Array.from(key)).toHaveLength(32);
|
|
});
|
|
});
|