Skip to content

Commit

Permalink
Move HkdfSha*Native to @hpke/common.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Oct 5, 2024
1 parent eb476fb commit 7ae6963
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 18 deletions.
6 changes: 6 additions & 0 deletions packages/common/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export { Ec } from "./src/kems/dhkemPrimitives/ec.ts";
export { Hybridkem } from "./src/kems/hybridkem.ts";
export { XCryptoKey } from "./src/xCryptoKey.ts";

export {
HkdfSha256Native,
HkdfSha384Native,
HkdfSha512Native,
} from "./src/kdfs/hkdf.ts";

export { AEAD_USAGES } from "./src/interfaces/aeadEncryptionContext.ts";
export { LABEL_DKP_PRK, LABEL_SK } from "./src/interfaces/dhkemPrimitives.ts";
export { SUITE_ID_HEADER_KEM } from "./src/interfaces/kemInterface.ts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import type { KdfInterface } from "@hpke/common";
import type { KdfInterface } from "../interfaces/kdfInterface.ts";

import { EMPTY, InvalidParamError, KdfId, NativeAlgorithm } from "@hpke/common";
import { EMPTY } from "../consts.ts";
import { InvalidParamError } from "../errors.ts";
import { KdfId } from "../identifiers.ts";
import { NativeAlgorithm } from "../algorithm.ts";

// b"HPKE-v1"
const HPKE_VERSION = new Uint8Array([72, 80, 75, 69, 45, 118, 49]);
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/aeads/aesGcm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import type {
AeadEncryptionContext,
AeadInterface,
} from "@hpke/common";
import { AeadId, AEAD_USAGES, NativeAlgorithm } from "@hpke/common";
import type { AeadEncryptionContext, AeadInterface } from "@hpke/common";
import { AEAD_USAGES, AeadId, NativeAlgorithm } from "@hpke/common";

export class AesGcmContext extends NativeAlgorithm
implements AeadEncryptionContext {
Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/kems/dhkemNative.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Dhkem, Ec, KemId } from "@hpke/common";

import {
Dhkem,
Ec,
HkdfSha256Native,
HkdfSha384Native,
HkdfSha512Native,
} from "../kdfs/hkdf.ts";
KemId,
} from "@hpke/common";

export class DhkemP256HkdfSha256Native extends Dhkem {
public readonly id: KemId = KemId.DhkemP256HkdfSha256;
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/native.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { CipherSuiteNative } from "./cipherSuiteNative.ts";
import {
HkdfSha256Native,
HkdfSha384Native,
HkdfSha512Native,
} from "./kdfs/hkdf.ts";
} from "@hpke/common";

import { CipherSuiteNative } from "./cipherSuiteNative.ts";
import {
DhkemP256HkdfSha256Native,
DhkemP384HkdfSha384Native,
Expand Down
2 changes: 1 addition & 1 deletion packages/dhkem-secp256k1/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=../../import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/core @hpke/dhkem-secp256k1 && npm run test",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/common @hpke/dhkem-secp256k1 && npm run test",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno run --import-map=../../npm/import_map.json -A dnt.ts",
"minify": "esbuild ../../npm/packages/dhkem-secp256k1/esm/dhkem-secp256k1/mod.js --bundle --format=esm --minify"
Expand Down
2 changes: 1 addition & 1 deletion packages/dhkem-x25519/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=../../import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/core @hpke/dhkem-x25519 && npm run test",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/common @hpke/dhkem-x25519 && npm run test",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno run --import-map=../../npm/import_map.json -A dnt.ts",
"minify": "esbuild ../../npm/packages/dhkem-x25519/esm/dhkem-x25519/mod.js --bundle --format=esm --minify"
Expand Down
2 changes: 1 addition & 1 deletion packages/dhkem-x25519/src/hkdfSha256.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hmac } from "@noble/hashes/hmac";
import { sha256 } from "@noble/hashes/sha256";

import { HkdfSha256 as HkdfSha256Native } from "@hpke/core";
import { HkdfSha256Native } from "@hpke/common";

export class HkdfSha256 extends HkdfSha256Native {
public override async extract(
Expand Down
2 changes: 1 addition & 1 deletion packages/dhkem-x448/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=../../import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/core @hpke/dhkem-x448 && npm run test",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/common @hpke/dhkem-x448 && npm run test",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno run --import-map=../../npm/import_map.json -A dnt.ts",
"minify": "esbuild ../../npm/packages/dhkem-x448/esm/dhkem-x448/mod.js --bundle --format=esm --minify"
Expand Down
2 changes: 1 addition & 1 deletion packages/dhkem-x448/src/hkdfSha512.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { hmac } from "@noble/hashes/hmac";
import { sha512 } from "@noble/hashes/sha512";

import { HkdfSha512 as HkdfSha512Native } from "@hpke/core";
import { HkdfSha512Native } from "@hpke/common";

export class HkdfSha512 extends HkdfSha512Native {
public override async extract(
Expand Down
2 changes: 1 addition & 1 deletion packages/hybridkem-x25519-kyber768/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"tasks": {
"test": "deno fmt && deno lint && deno test --import-map=../../import_map.json -A --fail-fast --doc --coverage=coverage --parallel --allow-read",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/core @hpke/hybridkem-x25519-kyber768 && npm run test",
"test:cloudflare": "cd test/runtimes/cloudflare && npm install && npm link @hpke/common @hpke/hybridkem-x25519-kyber768 && npm run test",
"cov": "deno coverage ./coverage --lcov --exclude='test'",
"dnt": "deno run --import-map=../../npm/import_map.json -A dnt.ts",
"minify": "esbuild ../../npm/packages/hybridkem-x25519-kyber768/esm/hybridkem-x25519-kyber768/mod.js --bundle --format=esm --minify"
Expand Down

0 comments on commit 7ae6963

Please sign in to comment.