Skip to content

Commit

Permalink
refactor: group operations to the same folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ythepaut committed Apr 27, 2024
1 parent 38d652c commit eb471aa
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 37 deletions.
14 changes: 7 additions & 7 deletions build/exports.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export { bytesToHex, hexToBytes, bytesToBase64, base64ToBytes, base64ToHex, hexToBase64 } from "@occult-app/crypto/types";
export { randomBytes } from "@occult-app/crypto/random";
export { sha256, sha512 } from "@occult-app/crypto/sha2";
export { kdf } from "@occult-app/crypto/kdf";
export { ppf } from "@occult-app/crypto/ppf";
export { hmac } from "@occult-app/crypto/hmac";
export { generateEd25519KeyPair, sign, verify } from "@occult-app/crypto/ed25519";
export { generateRSAKeyPair, exportAsPem, rsaEncrypt, rsaDecrypt } from "@occult-app/crypto/rsa";
export { randomBytes } from "@occult-app/crypto/operations/random";
export { sha256, sha512 } from "@occult-app/crypto/operations/sha2";
export { kdf } from "@occult-app/crypto/operations/kdf";
export { ppf } from "@occult-app/crypto/operations/ppf";
export { hmac } from "@occult-app/crypto/operations/hmac";
export { generateEd25519KeyPair, sign, verify } from "@occult-app/crypto/operations/ed25519";
export { generateRSAKeyPair, exportAsPem, rsaEncrypt, rsaDecrypt } from "@occult-app/crypto/operations/rsa";
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
base64ToHex,
hexToBase64
} from "./types";
import { randomBytes } from "./random";
import { sha256, sha512 } from "./sha2";
import { kdf } from "./kdf";
import { ppf } from "./ppf";
import { hmac } from "./hmac";
import { generateEd25519KeyPair, sign, verify } from "./ed25519";
import { generateRSAKeyPair, exportAsPem, rsaEncrypt, rsaDecrypt } from "./rsa";
import { randomBytes } from "./operations/random";
import { sha256, sha512 } from "./operations/sha2";
import { kdf } from "./operations/kdf";
import { ppf } from "./operations/ppf";
import { hmac } from "./operations/hmac";
import { generateEd25519KeyPair, sign, verify } from "./operations/ed25519";
import { generateRSAKeyPair, exportAsPem, rsaEncrypt, rsaDecrypt } from "./operations/rsa";
2 changes: 1 addition & 1 deletion src/ed25519.ts → src/operations/ed25519.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ByteArray } from "./types";
import { ByteArray } from "../types";
import { ed25519 } from "@noble/curves/ed25519";

interface KeyPair {
Expand Down
2 changes: 1 addition & 1 deletion src/hmac.ts → src/operations/hmac.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { subtle } from "crypto";
import { ByteArray } from "./types";
import { ByteArray } from "../types";

/**
* Computes the HMAC-SHA256 tag (hash) of the input data using the provided key.
Expand Down
2 changes: 1 addition & 1 deletion src/kdf.ts → src/operations/kdf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { subtle } from "crypto";
import { ByteArray } from "./types";
import { ByteArray } from "../types";

interface KDFContext {
info: string;
Expand Down
2 changes: 1 addition & 1 deletion src/ppf.ts → src/operations/ppf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ByteArray } from "./types";
import { ByteArray } from "../types";
import { argon2id } from "@noble/hashes/argon2";

const ARGON2ID_ITERATION_COUNT: number = 3;
Expand Down
2 changes: 1 addition & 1 deletion src/random.ts → src/operations/random.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ByteArray } from "./types";
import { ByteArray } from "../types";

/**
* Generates cryptographically secure random bytes using the Web Crypto API.
Expand Down
4 changes: 2 additions & 2 deletions src/rsa.ts → src/operations/rsa.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { subtle } from "crypto";
import { ByteArray, bytesToBase64 } from "./types";
import DecryptionException from "./exceptions/DecryptionException";
import { ByteArray, bytesToBase64 } from "../types";
import DecryptionException from "../exceptions/DecryptionException";

interface KeyPair {
pub: ByteArray;
Expand Down
2 changes: 1 addition & 1 deletion src/sha2.ts → src/operations/sha2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ByteArray } from "./types";
import { ByteArray } from "../types";
import { createHash, Hash } from "crypto";

type Algorithm = "SHA-256" | "SHA-512";
Expand Down
4 changes: 2 additions & 2 deletions tests/ed25519.spec.ts → tests/operations/ed25519.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ByteArray, hexToBytes } from "../src/types";
import { generateEd25519KeyPair, sign, verify } from "../src/ed25519";
import { ByteArray, hexToBytes } from "../../src/types";
import { generateEd25519KeyPair, sign, verify } from "../../src/operations/ed25519";

describe("Ed25519", () => {
const secret: ByteArray = hexToBytes(
Expand Down
4 changes: 2 additions & 2 deletions tests/hmac.spec.ts → tests/operations/hmac.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ByteArray, bytesToHex, hexToBytes } from "../src/types";
import { hmac } from "../src/hmac";
import { ByteArray, bytesToHex, hexToBytes } from "../../src/types";
import { hmac } from "../../src/operations/hmac";

describe("HMAC", () => {
it("should compute the HMAC-SHA256 hash", async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/kdf.spec.ts → tests/operations/kdf.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ByteArray, bytesToHex } from "../src/types";
import { kdf } from "../src/kdf";
import { ByteArray, bytesToHex } from "../../src/types";
import { kdf } from "../../src/operations/kdf";

describe("KDF", () => {
const key: ByteArray = new Uint8Array([
Expand Down
4 changes: 2 additions & 2 deletions tests/ppf.spec.ts → tests/operations/ppf.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ppf } from "../src/ppf";
import { ByteArray, bytesToHex } from "../src/types";
import { ppf } from "../../src/operations/ppf";
import { ByteArray, bytesToHex } from "../../src/types";

describe("Password Processing Function", () => {
const password: string = "SuperS3cret!";
Expand Down
4 changes: 2 additions & 2 deletions tests/random.spec.ts → tests/operations/random.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomBytes } from "../src/random";
import { ByteArray } from "../src/types";
import { randomBytes } from "../../src/operations/random";
import { ByteArray } from "../../src/types";

describe("CSPRNG", () => {
it("should return a random number", async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/rsa.spec.ts → tests/operations/rsa.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exportAsPem, generateRSAKeyPair, rsaDecrypt, rsaEncrypt } from "../src/rsa";
import { base64ToBytes, ByteArray } from "../src/types";
import DecryptionException from "../src/exceptions/DecryptionException";
import { exportAsPem, generateRSAKeyPair, rsaDecrypt, rsaEncrypt } from "../../src/operations/rsa";
import { base64ToBytes, ByteArray } from "../../src/types";
import DecryptionException from "../../src/exceptions/DecryptionException";

describe("RSA", () => {
const pub: ByteArray = base64ToBytes(
Expand Down
4 changes: 2 additions & 2 deletions tests/sha2.spec.ts → tests/operations/sha2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ByteArray, bytesToHex } from "../src/types";
import { sha256, sha512 } from "../src/sha2";
import { ByteArray, bytesToHex } from "../../src/types";
import { sha256, sha512 } from "../../src/operations/sha2";

describe("SHA2", () => {
const input: string = "hash me!";
Expand Down

0 comments on commit eb471aa

Please sign in to comment.