Skip to content

Commit

Permalink
Update tsdoc to follow hpke/core updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajiaji committed Aug 13, 2023
1 parent 837a9f6 commit 1613094
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/aeads/chacha20Poly1305.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ export class Chacha20Poly1305Context implements AeadEncryptionContext {
* {@link https://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
*
* ```ts
* import { KemId, KdfId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { CipherSuite, DhkemP256HkdfSha256, HkdfSha256 } from "http://deno.land/x/hpke/core/mod.ts";
* import { Chacha20Poly1305 } from "https://deno.land/x/hpke/x/chach20poly1305/mod.ts";
* const suite = new CipherSuite({
* kem: KemId.DhkemP256HkdfSha256,
* kdf: KdfId.HkdfSha256,
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Chacha20Poly1305(),
* });
* ```
Expand Down
37 changes: 34 additions & 3 deletions src/cipherSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,43 @@ import { CipherSuiteNative } from "./cipherSuiteNative.ts";
* - [DEPRECATED] Generates a key pair for the cipher suite.
* - [DEPRECATED] Derives a key pair for the cipher suite.
* - [DEPRECATED] Imports and converts a key to a CryptoKey.
* - Creates an encryption context both for senders and recipients.
* - Encrypts a message as a single-shot API.
* - Decrypts an encrypted message as as single-shot API.
* - Creates encryption contexts both for senders and recipients.
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - Provides single-shot encryption API.
* - {@link seal}
* - {@link open}
*
* The calling of the constructor of this class is the starting
* point for HPKE operations for both senders and recipients.
*
* @example Use only ciphersuites supported internally.
*
* ```ts
* import { AeadId, CipherSuite, KdfId, KemId } from "http://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuite({
* kem: KemId.DhkemP256HkdfSha256,
* kdf: KdfId.HkdfSha256,
* aead: AeadId.Aes128Gcm,
* });
* ```
*
* @example Use a ciphersuite consisting of an external module.
*
* ```ts
* import { AeadId, CipherSuite, KdfId } from "http://deno.land/x/hpke/mod.ts";
* // Use an extension module.
* import {
* HybridkemX25519Kyber768,
* } from "https://deno.land/x/hpke/x/hybridkem-x25519-kyber768/mod.ts";
*
* const suite = new CipherSuite({
* kem: new HybridkemX25519Kyber768(),
* kdf: KdfId.HkdfSha256,
* aead: AeadId.Aes128Gcm,
* });
* ```
*/
export class CipherSuite extends CipherSuiteNative {
/**
Expand Down
18 changes: 10 additions & 8 deletions src/cipherSuiteNative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,26 @@ const SUITE_ID_HEADER_HPKE = new Uint8Array([
* ```ts
* import {
* Aes128Gcm,
* DhkemP256HkdfSha256Native,
* HkdfSha256Native,
* CipherSuiteNative,
* DhkemP256HkdfSha256,
* HkdfSha256,
* CipherSuite,
* } from "http://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuiteNative({
* kem: new DhkemP256HkdfSha256Native(),
* kdf: new HkdfSha256Native(),
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* @example Use a ciphersuite which is currently not supported by Web Cryptography API.
*
* ```ts
* import { Aes128Gcm, HkdfSha256, CipherSuiteNative } from "http://deno.land/x/hpke/mod.ts";
* import { Aes128Gcm, HkdfSha256, CipherSuite } from "http://deno.land/x/hpke/mod.ts";
* // Use an extension module.
* import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-x25519/mod.ts";
* const suite = new CipherSuiteNative({
*
* const suite = new CipherSuite({
* kem: new DhkemX25519HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
Expand Down

0 comments on commit 1613094

Please sign in to comment.