Skip to content

Commit 3ee2082

Browse files
authored
Merge pull request #330 from dajiaji/refine-chacha20poly1305-test
Make chacha20poly1305 test use @hpke/core.
2 parents 43e6e71 + c96e1cf commit 3ee2082

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

deno.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"deno.json",
1616
"deno.lock",
1717
"mod.ts",
18+
"mod_core.ts",
1819
"src/",
1920
"x/chacha20poly1305/src/"
2021
],
@@ -36,6 +37,7 @@
3637
"core/",
3738
"dnt.ts",
3839
"mod.ts",
40+
"mod_core.ts",
3941
"samples/",
4042
"src/",
4143
"x/",

mod_core.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// workaround for dnt.
2+
// It's the samme as core/mod.ts and a temporary solution until dnt supports.
3+
export type { AeadEncryptionContext } from "./core/src/interfaces/aeadEncryptionContext.ts";
4+
export type { AeadInterface } from "./core/src/interfaces/aeadInterface.ts";
5+
export type { CipherSuiteParams } from "./core/src/interfaces/cipherSuiteParams.ts";
6+
export type {
7+
EncryptionContext,
8+
RecipientContext,
9+
SenderContext,
10+
} from "./core/src/interfaces/encryptionContext.ts";
11+
export type { KdfInterface } from "./core/src/interfaces/kdfInterface.ts";
12+
export type { KemInterface } from "./core/src/interfaces/kemInterface.ts";
13+
export type { PreSharedKey } from "./core/src/interfaces/preSharedKey.ts";
14+
export type { RecipientContextParams } from "./core/src/interfaces/recipientContextParams.ts";
15+
export type { CipherSuiteSealResponse } from "./core/src/interfaces/responses.ts";
16+
export type { SenderContextParams } from "./core/src/interfaces/senderContextParams.ts";
17+
18+
export { Aes128Gcm, Aes256Gcm } from "./core/src/aeads/aesGcm.ts";
19+
export { ExportOnly } from "./core/src/aeads/exportOnly.ts";
20+
export * from "./core/src/errors.ts";
21+
export { AeadId, KdfId, KemId } from "./core/src/identifiers.ts";
22+
23+
export {
24+
CipherSuite,
25+
DhkemP256HkdfSha256,
26+
DhkemP384HkdfSha384,
27+
DhkemP521HkdfSha512,
28+
HkdfSha256,
29+
HkdfSha384,
30+
HkdfSha512,
31+
} from "./core/src/native.ts";

x/chacha20poly1305/test/chacha20poly1305.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { assertEquals } from "@std/assert";
22
import { describe, it } from "@std/testing/bdd";
33

4-
import { AeadId, CipherSuite, KdfId, KemId } from "../../../mod.ts";
4+
import { AeadId } from "../../../core/src/identifiers.ts";
5+
import {
6+
CipherSuite,
7+
DhkemP256HkdfSha256,
8+
HkdfSha256,
9+
} from "../../../mod_core.ts";
10+
511
import { loadCrypto } from "../../../core/test/utils.ts";
612

713
import { Chacha20Poly1305 } from "../mod.ts";
@@ -52,8 +58,8 @@ describe("CipherSuite", () => {
5258
describe("constructor with Chacha20Poly1305", () => {
5359
it("should have a correct ciphersuite", () => {
5460
const suite: CipherSuite = new CipherSuite({
55-
kem: KemId.DhkemP256HkdfSha256,
56-
kdf: KdfId.HkdfSha256,
61+
kem: new DhkemP256HkdfSha256(),
62+
kdf: new HkdfSha256(),
5763
aead: new Chacha20Poly1305(),
5864
});
5965

@@ -69,8 +75,8 @@ describe("CipherSuite", () => {
6975
it("should work normally", async () => {
7076
// setup
7177
const suite = new CipherSuite({
72-
kem: KemId.DhkemP256HkdfSha256,
73-
kdf: KdfId.HkdfSha256,
78+
kem: new DhkemP256HkdfSha256(),
79+
kdf: new HkdfSha256(),
7480
aead: new Chacha20Poly1305(),
7581
});
7682

0 commit comments

Comments
 (0)