Skip to content

Commit

Permalink
refactor(deps): migrate to deno.json
Browse files Browse the repository at this point in the history
  • Loading branch information
aykxt committed Feb 13, 2025
1 parent 6643132 commit 1f0bd45
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 30 deletions.
19 changes: 19 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"lock": false,
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.0",
"@std/encoding/hex": "jsr:@std/encoding@^1.0.0/hex",
"@std/hash": "https://deno.land/[email protected]/hash/mod.ts"
},
"exports": {
"./aes": "./aes.ts",
"./block-modes": "./block-modes.ts",
"./blowfish": "./blowfish.ts",
"./cast5": "./cast5.ts",
"./des": "./des.ts",
"./hkdf": "./hkdf.ts",
"./hmac": "./hmac.ts",
"./pbkdf2": "./pbkdf2.ts",
"./tdes": "./tdes.ts"
}
}
2 changes: 0 additions & 2 deletions deps.ts

This file was deleted.

13 changes: 0 additions & 13 deletions dev_deps.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/hkdf/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hmac, outputSizes } from "../hmac/mod.ts";
import type { SupportedAlgorithm } from "../hmac/mod.ts";
import { hmac, outputSizes } from "../hmac/mod.ts";

export type { SupportedAlgorithm };

Expand All @@ -12,7 +12,7 @@ export function hkdf(
ikm: Uint8Array,
salt?: Uint8Array,
info?: Uint8Array,
) {
): Uint8Array {
const hashLen = outputSizes[hash];

if (!salt) salt = new Uint8Array(hashLen);
Expand Down
9 changes: 6 additions & 3 deletions src/hmac/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createHash, SupportedAlgorithm } from "../../deps.ts";

export type { SupportedAlgorithm } from "../../deps.ts";
import { createHash, SupportedAlgorithm } from "@std/hash";
export type { SupportedAlgorithm } from "@std/hash";

export const blockSizes: Record<SupportedAlgorithm, number> = {
"sha3-512": 72,
Expand All @@ -21,6 +20,8 @@ export const blockSizes: Record<SupportedAlgorithm, number> = {
keccak384: 48,
keccak256: 136,
keccak224: 144,
blake3: 64,
tiger: 64,
};

export const outputSizes: Record<SupportedAlgorithm, number> = {
Expand All @@ -42,6 +43,8 @@ export const outputSizes: Record<SupportedAlgorithm, number> = {
keccak384: 48,
keccak256: 32,
keccak224: 28,
blake3: 32,
tiger: 24,
};

/**
Expand Down
3 changes: 2 additions & 1 deletion tests/aes.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { Aes } from "../aes.ts";
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";

// https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/aes/AESAVS.pdf

Expand Down
3 changes: 2 additions & 1 deletion tests/block-modes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { Aes } from "../aes.ts";
import { Cbc, Cfb, Ctr, Ecb, Ige, Ofb } from "../block-modes.ts";
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";

const key = new Uint8Array(16);
const iv = new Uint8Array(16);
Expand Down
3 changes: 2 additions & 1 deletion tests/blowfish.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { Blowfish } from "../blowfish.ts";

Deno.test("[Block Cipher] Blowfish", () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/cast5.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { Cast5 } from "../cast5.ts";
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";

// https://tools.ietf.org/html/rfc2144#appendix-B.1

Expand Down
3 changes: 2 additions & 1 deletion tests/des.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { Des } from "../des.ts";

Deno.test("[Block Cipher] DES", () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/hkdf.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertEquals } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { hkdf } from "../hkdf.ts";
import { assertEquals, decodeHex } from "../dev_deps.ts";

// https://tools.ietf.org/html/rfc5869#appendix-A

Expand Down
3 changes: 2 additions & 1 deletion tests/hmac.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertEquals } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { hmac, SupportedAlgorithm } from "../hmac.ts";
import { assertEquals, decodeHex } from "../dev_deps.ts";

// https://tools.ietf.org/html/rfc4231#section-4

Expand Down
2 changes: 1 addition & 1 deletion tests/padding.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { assertEquals, assertThrows } from "../dev_deps.ts";
import { assertEquals, assertThrows } from "@std/assert";
import { pad, Padding, unpad } from "../src/utils/padding.ts";

Deno.test("[Padding] PKCS#7", () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/pbkdf2.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assertEquals } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { pbkdf2 } from "../src/pbkdf2/mod.ts";
import { assertEquals, decodeHex } from "../dev_deps.ts";

// https://tools.ietf.org/html/rfc6070#section-2
Deno.test("[KDF] PBKDF2 HMAC-SHA1", () => {
Expand Down
3 changes: 2 additions & 1 deletion tests/tdes.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assertEquals, assertThrows, decodeHex } from "../dev_deps.ts";
import { assertEquals, assertThrows } from "@std/assert";
import { decodeHex } from "@std/encoding/hex";
import { TripleDes } from "../tdes.ts";

Deno.test("[Block Cipher] 3DES", () => {
Expand Down

0 comments on commit 1f0bd45

Please sign in to comment.