Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hpke-js

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hpke-js - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

55

esm/src/aeads/aesGcm.d.ts

@@ -14,14 +14,69 @@ import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";

}
/**
* The AES-128-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes128Gcm`.
*
* @example
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*/
export declare class Aes128Gcm implements AeadInterface {
/** AeadId.Aes128Gcm (0x0001) */
readonly id: AeadId;
/** 16 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
createEncryptionContext(key: ArrayBuffer): AeadEncryptionContext;
}
/**
* The AES-256-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes256Gcm`
* as follows:
*
* @example
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes256Gcm(),
* });
* ```
*/
export declare class Aes256Gcm extends Aes128Gcm {
/** AeadId.Aes256Gcm (0x0002) */
readonly id: AeadId;
/** 32 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
}

@@ -55,4 +55,28 @@ import { NativeAlgorithm } from "../algorithm.js";

}
/**
* The AES-128-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes128Gcm`.
*
* @example
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*/
export class Aes128Gcm {
constructor() {
/** AeadId.Aes128Gcm (0x0001) */
Object.defineProperty(this, "id", {

@@ -64,2 +88,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "keySize", {

@@ -71,2 +96,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -78,2 +104,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -90,5 +117,30 @@ enumerable: true,

}
/**
* The AES-256-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes256Gcm`
* as follows:
*
* @example
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes256Gcm(),
* });
* ```
*/
export class Aes256Gcm extends Aes128Gcm {
constructor() {
super(...arguments);
/** AeadId.Aes256Gcm (0x0002) */
Object.defineProperty(this, "id", {

@@ -100,2 +152,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "keySize", {

@@ -107,2 +160,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -114,2 +168,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -116,0 +171,0 @@ enumerable: true,

28

esm/src/aeads/chacha20Poly1305.d.ts

@@ -13,15 +13,20 @@ import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";

/**
* The ChaCha20Poly1305 AEAD.
* The ChaCha20Poly1305 for HPKE AEAD implementing {@link AeadInterface}.
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
* When using `@hpke/core`, the instance of this class can be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Chacha20Poly1305`
* as follows:
*
* The instance of this class can be specified to the
* {@link https://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
*
* ```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";
* 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({

@@ -33,9 +38,16 @@ * kem: new DhkemP256HkdfSha256(),

* ```
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
*/
export declare class Chacha20Poly1305 implements AeadInterface {
/** AeadId.Chacha20Poly1305 (0x0003) */
readonly id: AeadId;
/** 32 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
createEncryptionContext(key: ArrayBuffer): AeadEncryptionContext;
}

@@ -34,15 +34,20 @@ // @ts-ignore: for "npm:"

/**
* The ChaCha20Poly1305 AEAD.
* The ChaCha20Poly1305 for HPKE AEAD implementing {@link AeadInterface}.
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
* When using `@hpke/core`, the instance of this class can be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Chacha20Poly1305`
* as follows:
*
* The instance of this class can be specified to the
* {@link https://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
*
* ```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";
* 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({

@@ -54,5 +59,9 @@ * kem: new DhkemP256HkdfSha256(),

* ```
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
*/
export class Chacha20Poly1305 {
constructor() {
/** AeadId.Chacha20Poly1305 (0x0003) */
Object.defineProperty(this, "id", {

@@ -64,2 +73,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "keySize", {

@@ -71,2 +81,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -78,2 +89,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -80,0 +92,0 @@ enumerable: true,

import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";
import type { AeadInterface } from "../interfaces/aeadInterface.js";
import { AeadId } from "../identifiers.js";
/**
* The ExportOnly mode for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.ExportOnly`
* as follows:
*
* @example
*
* ```ts
* import {
* CipherSuite,
* DhkemP256HkdfSha256,
* ExportOnly,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new ExportOnly(),
* });
* ```
*/
export declare class ExportOnly implements AeadInterface {

@@ -5,0 +29,0 @@ readonly id: AeadId;

import { AeadId } from "../identifiers.js";
import { NotSupportedError } from "../errors.js";
/**
* The ExportOnly mode for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.ExportOnly`
* as follows:
*
* @example
*
* ```ts
* import {
* CipherSuite,
* DhkemP256HkdfSha256,
* ExportOnly,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new ExportOnly(),
* });
* ```
*/
export class ExportOnly {

@@ -4,0 +28,0 @@ constructor() {

@@ -0,10 +1,9 @@

import * as dntShim from "../_dnt.shims.js";
import { NotSupportedError } from "./errors.js";
import { isBrowser, isCloudflareWorkers } from "./utils/misc.js";
async function loadSubtleCrypto() {
if (isBrowser() || isCloudflareWorkers()) {
if (globalThis.crypto !== undefined) {
return globalThis.crypto.subtle;
}
// jsdom
if (dntShim.dntGlobalThis !== undefined && globalThis.crypto !== undefined) {
// Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
return globalThis.crypto.subtle;
}
// Node.js <= v18
try {

@@ -11,0 +10,0 @@ // @ts-ignore: to ignore "crypto"

@@ -9,3 +9,2 @@ import type { CipherSuiteParams } from "./interfaces/cipherSuiteParams.js";

* The class consists of the {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/x/chacha20Poly1305/mod.ts | @hpke/chcha20poly1305},

@@ -21,7 +20,7 @@ * {@link https://deno.land/x/hpke/x/dhkem-x25519/mod.ts | @hpke/dhkem-x25519} and

* - Creates encryption contexts both for senders and recipients.
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - Provides single-shot encryption API.
* - {@link seal}
* - {@link open}
* - {@link seal}
* - {@link open}
*

@@ -28,0 +27,0 @@ * The calling of the constructor of this class is the starting

@@ -21,3 +21,2 @@ import { Aes128Gcm, Aes256Gcm } from "./aeads/aesGcm.js";

* The class consists of the {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/x/chacha20Poly1305/mod.ts | @hpke/chcha20poly1305},

@@ -33,7 +32,7 @@ * {@link https://deno.land/x/hpke/x/dhkem-x25519/mod.ts | @hpke/dhkem-x25519} and

* - Creates encryption contexts both for senders and recipients.
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - Provides single-shot encryption API.
* - {@link seal}
* - {@link open}
* - {@link seal}
* - {@link open}
*

@@ -40,0 +39,0 @@ * The calling of the constructor of this class is the starting

@@ -21,15 +21,24 @@ import type { KdfInterface } from "../interfaces/kdfInterface.js";

export declare class HkdfSha256Native extends HkdfNative {
/** KdfId.HkdfSha256 (0x0001) */
readonly id: KdfId;
/** 32 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha384Native extends HkdfNative {
/** KdfId.HkdfSha384 (0x0002) */
readonly id: KdfId;
/** 48 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha512Native extends HkdfNative {
/** KdfId.HkdfSha512 (0x0003) */
readonly id: KdfId;
/** 64 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}

@@ -130,2 +130,3 @@ import { NativeAlgorithm } from "../algorithm.js";

super(...arguments);
/** KdfId.HkdfSha256 (0x0001) */
Object.defineProperty(this, "id", {

@@ -137,2 +138,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "hashSize", {

@@ -144,2 +146,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -160,2 +163,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha384 (0x0002) */
Object.defineProperty(this, "id", {

@@ -167,2 +171,3 @@ enumerable: true,

});
/** 48 */
Object.defineProperty(this, "hashSize", {

@@ -174,2 +179,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -190,2 +196,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha512 (0x0003) */
Object.defineProperty(this, "id", {

@@ -197,2 +204,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "hashSize", {

@@ -204,2 +212,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -206,0 +215,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X25519, HKDF-SHA256).
* The DHKEM(X25519, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -12,8 +12,29 @@ * This class is implemented using

*
* @example
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-x25519/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX25519HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemX25519HkdfSha256`
* can be used. You don't need to use this class.
*
* @example
*
* ```ts
* import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuite({
* kem: KemId.DhkemX25519HkdfSha256,
* kdf: KdfId.HkdfSha256,

@@ -25,8 +46,13 @@ * aead: AeadId.Aes128Gcm,

export declare class DhkemX25519HkdfSha256 extends Dhkem {
/** KemId.DhkemX25519HkdfSha256 (0x0020) */
readonly id: KemId;
/** 32 */
readonly secretSize: number;
/** 32 */
readonly encSize: number;
/** 32 */
readonly publicKeySize: number;
/** 32 */
readonly privateKeySize: number;
constructor();
}

@@ -6,3 +6,3 @@ import { KemId } from "../identifiers.js";

/**
* The DHKEM(X25519, HKDF-SHA256).
* The DHKEM(X25519, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -15,8 +15,29 @@ * This class is implemented using

*
* @example
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-x25519/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX25519HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemX25519HkdfSha256`
* can be used. You don't need to use this class.
*
* @example
*
* ```ts
* import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuite({
* kem: KemId.DhkemX25519HkdfSha256,
* kdf: KdfId.HkdfSha256,

@@ -31,2 +52,3 @@ * aead: AeadId.Aes128Gcm,

super(KemId.DhkemX25519HkdfSha256, new X25519(kdf), kdf);
/** KemId.DhkemX25519HkdfSha256 (0x0020) */
Object.defineProperty(this, "id", {

@@ -38,2 +60,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "secretSize", {

@@ -45,2 +68,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "encSize", {

@@ -52,2 +76,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "publicKeySize", {

@@ -59,2 +84,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "privateKeySize", {

@@ -61,0 +87,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X448, HKDF-SHA512).
* The DHKEM(X448, HKDF-SHA512) for HPKE KEM implementing {@link KemInterface}.
*

@@ -12,20 +12,44 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { CipherSuite, AeadId, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* aead: AeadId.Aes256Gcm,
* });
* ```
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* HkdfSha512,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: new HkdfSha512(),
* aead: new Aes256Gcm(),
* });
* ```
*/
export declare class DhkemX448HkdfSha512 extends Dhkem {
/** KemId.DhkemX448HkdfSha512 (0x0021) */
readonly id: KemId;
/** 64 */
readonly secretSize: number;
/** 56 */
readonly encSize: number;
/** 56 */
readonly publicKeySize: number;
/** 56 */
readonly privateKeySize: number;
constructor();
}

@@ -6,3 +6,3 @@ import { KemId } from "../identifiers.js";

/**
* The DHKEM(X448, HKDF-SHA512).
* The DHKEM(X448, HKDF-SHA512) for HPKE KEM implementing {@link KemInterface}.
*

@@ -15,12 +15,31 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { CipherSuite, AeadId, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* aead: AeadId.Aes256Gcm,
* });
* ```
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* HkdfSha512,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: new HkdfSha512(),
* aead: new Aes256Gcm(),
* });
* ```
*/

@@ -31,2 +50,3 @@ export class DhkemX448HkdfSha512 extends Dhkem {

super(KemId.DhkemX448HkdfSha512, new X448(kdf), kdf);
/** KemId.DhkemX448HkdfSha512 (0x0021) */
Object.defineProperty(this, "id", {

@@ -38,2 +58,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "secretSize", {

@@ -45,2 +66,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "encSize", {

@@ -52,2 +74,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "publicKeySize", {

@@ -59,2 +82,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "privateKeySize", {

@@ -61,0 +85,0 @@ enumerable: true,

/**
* Checks whether the execution env is browser or not.
*/
export declare const isBrowser: () => boolean;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export declare const isCloudflareWorkers: () => boolean;
/**
* Checks whether the execution env is Deno or not.

@@ -11,0 +3,0 @@ */

@@ -1,11 +0,2 @@

import * as dntShim from "../../_dnt.shims.js";
/**
* Checks whether the execution env is browser or not.
*/
export const isBrowser = () => typeof dntShim.dntGlobalThis !== "undefined";
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export const isCloudflareWorkers = () => typeof caches !== "undefined";
/**
* Checks whether the execution env is Deno or not.

@@ -12,0 +3,0 @@ */

@@ -6,3 +6,3 @@ {

"name": "hpke-js",
"version": "1.2.1",
"version": "1.2.2",
"description": "A Hybrid Public Key Encryption (HPKE) module for various JavaScript runtimes",

@@ -9,0 +9,0 @@ "repository": {

@@ -222,5 +222,5 @@ <h1 align="center">hpke-js</h1>

// use a specific version
import * as hpke from "https://deno.land/x/hpke@1.2.1/mod.ts";
// import * as hpke from "https://deno.land/x/hpke@1.2.1/core/mod.ts";
// import * as hpke from "https://deno.land/x/hpke@1.2.1/x/dhkem-x25519/mod.ts";
import * as hpke from "https://deno.land/x/hpke@1.2.2/mod.ts";
// import * as hpke from "https://deno.land/x/hpke@1.2.2/core/mod.ts";
// import * as hpke from "https://deno.land/x/hpke@1.2.2/x/dhkem-x25519/mod.ts";

@@ -243,4 +243,4 @@ // use the latest stable version

<script type="module">
import * as hpke from "https://esm.sh/hpke-js@1.2.1";
// import * as hpke from "https://esm.sh/@hpke/core@1.2.1";
import * as hpke from "https://esm.sh/hpke-js@1.2.2";
// import * as hpke from "https://esm.sh/@hpke/core@1.2.2";
// ...

@@ -262,4 +262,4 @@ </script>

<script type="module">
import * as hpke from "https://unpkg.com/hpke-js@1.2.1/esm/mod.js";
// import * as hpke from "https://unpkg.com/@hpke/core@1.2.1/esm/mod.js";
import * as hpke from "https://unpkg.com/hpke-js@1.2.2/esm/mod.js";
// import * as hpke from "https://unpkg.com/@hpke/core@1.2.2/esm/mod.js";
// ...

@@ -344,7 +344,7 @@ </script>

```js
import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke@1.2.1/mod.ts";
import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke@1.2.2/mod.ts";
// import {
// Aes128Gcm, CipherSuite, HkdfSha256,
// } from "https://deno.land/x/hpke@1.2.1/core/mod.ts";
// import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke@1.2.1/x/dhkem-x25519/mod.ts";
// } from "https://deno.land/x/hpke@1.2.2/core/mod.ts";
// import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke@1.2.2/x/dhkem-x25519/mod.ts";

@@ -432,6 +432,6 @@ async function doHpke() {

<script type="module">
import { AeadId, CipherSuite, KdfId, KemId } from "https://esm.sh/hpke-js@1.2.1";
import { AeadId, CipherSuite, KdfId, KemId } from "https://esm.sh/hpke-js@1.2.2";
// import {
// Aes128Gcm, CipherSuite, DhkemP256HkdfSha256, HkdfSha256,
// } from "@hpke/core@1.2.1";
// } from "@hpke/core@1.2.2";

@@ -438,0 +438,0 @@ globalThis.doHpke = async () => {

@@ -14,14 +14,69 @@ import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";

}
/**
* The AES-128-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes128Gcm`.
*
* @example
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*/
export declare class Aes128Gcm implements AeadInterface {
/** AeadId.Aes128Gcm (0x0001) */
readonly id: AeadId;
/** 16 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
createEncryptionContext(key: ArrayBuffer): AeadEncryptionContext;
}
/**
* The AES-256-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes256Gcm`
* as follows:
*
* @example
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes256Gcm(),
* });
* ```
*/
export declare class Aes256Gcm extends Aes128Gcm {
/** AeadId.Aes256Gcm (0x0002) */
readonly id: AeadId;
/** 32 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
}

@@ -68,4 +68,28 @@ (function (factory) {

exports.AesGcmContext = AesGcmContext;
/**
* The AES-128-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes128Gcm`.
*
* @example
*
* ```ts
* import {
* Aes128Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*/
class Aes128Gcm {
constructor() {
/** AeadId.Aes128Gcm (0x0001) */
Object.defineProperty(this, "id", {

@@ -77,2 +101,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "keySize", {

@@ -84,2 +109,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -91,2 +117,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -104,5 +131,30 @@ enumerable: true,

exports.Aes128Gcm = Aes128Gcm;
/**
* The AES-256-GCM for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Aes256Gcm`
* as follows:
*
* @example
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* DhkemP256HkdfSha256,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes256Gcm(),
* });
* ```
*/
class Aes256Gcm extends Aes128Gcm {
constructor() {
super(...arguments);
/** AeadId.Aes256Gcm (0x0002) */
Object.defineProperty(this, "id", {

@@ -114,2 +166,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "keySize", {

@@ -121,2 +174,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -128,2 +182,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -130,0 +185,0 @@ enumerable: true,

@@ -13,15 +13,20 @@ import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";

/**
* The ChaCha20Poly1305 AEAD.
* The ChaCha20Poly1305 for HPKE AEAD implementing {@link AeadInterface}.
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
* When using `@hpke/core`, the instance of this class can be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Chacha20Poly1305`
* as follows:
*
* The instance of this class can be specified to the
* {@link https://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
*
* ```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";
* 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({

@@ -33,9 +38,16 @@ * kem: new DhkemP256HkdfSha256(),

* ```
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
*/
export declare class Chacha20Poly1305 implements AeadInterface {
/** AeadId.Chacha20Poly1305 (0x0003) */
readonly id: AeadId;
/** 32 */
readonly keySize: number;
/** 12 */
readonly nonceSize: number;
/** 16 */
readonly tagSize: number;
createEncryptionContext(key: ArrayBuffer): AeadEncryptionContext;
}

@@ -47,15 +47,20 @@ (function (factory) {

/**
* The ChaCha20Poly1305 AEAD.
* The ChaCha20Poly1305 for HPKE AEAD implementing {@link AeadInterface}.
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
* When using `@hpke/core`, the instance of this class can be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.Chacha20Poly1305`
* as follows:
*
* The instance of this class can be specified to the
* {@link https://deno.land/x/hpke/core/mod.ts?s=CipherSuiteParams | CipherSuiteParams} as follows:
*
* @example
*
* ```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";
* 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({

@@ -67,5 +72,9 @@ * kem: new DhkemP256HkdfSha256(),

* ```
*
* This class is implemented using
* {@link https://github.com/paulmillr/noble-ciphers | @noble/ciphers}.
*/
class Chacha20Poly1305 {
constructor() {
/** AeadId.Chacha20Poly1305 (0x0003) */
Object.defineProperty(this, "id", {

@@ -77,2 +86,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "keySize", {

@@ -84,2 +94,3 @@ enumerable: true,

});
/** 12 */
Object.defineProperty(this, "nonceSize", {

@@ -91,2 +102,3 @@ enumerable: true,

});
/** 16 */
Object.defineProperty(this, "tagSize", {

@@ -93,0 +105,0 @@ enumerable: true,

import type { AeadEncryptionContext } from "../interfaces/aeadEncryptionContext.js";
import type { AeadInterface } from "../interfaces/aeadInterface.js";
import { AeadId } from "../identifiers.js";
/**
* The ExportOnly mode for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.ExportOnly`
* as follows:
*
* @example
*
* ```ts
* import {
* CipherSuite,
* DhkemP256HkdfSha256,
* ExportOnly,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new ExportOnly(),
* });
* ```
*/
export declare class ExportOnly implements AeadInterface {

@@ -5,0 +29,0 @@ readonly id: AeadId;

@@ -15,2 +15,26 @@ (function (factory) {

const errors_js_1 = require("../errors.js");
/**
* The ExportOnly mode for HPKE AEAD implementing {@link AeadInterface}.
*
* When using `@hpke/core`, the instance of this class must be specified
* to the `aead` parameter of {@link CipherSuiteParams} instead of `AeadId.ExportOnly`
* as follows:
*
* @example
*
* ```ts
* import {
* CipherSuite,
* DhkemP256HkdfSha256,
* ExportOnly,
* HkdfSha256,
* } from "http://deno.land/x/hpke/core/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemP256HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new ExportOnly(),
* });
* ```
*/
class ExportOnly {

@@ -17,0 +41,0 @@ constructor() {

@@ -30,3 +30,3 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./errors.js", "./utils/misc.js"], factory);
define(["require", "exports", "../_dnt.shims.js", "./errors.js"], factory);
}

@@ -38,11 +38,10 @@ })(function (require, exports) {

exports.NativeAlgorithm = void 0;
const dntShim = __importStar(require("../_dnt.shims.js"));
const errors_js_1 = require("./errors.js");
const misc_js_1 = require("./utils/misc.js");
async function loadSubtleCrypto() {
if ((0, misc_js_1.isBrowser)() || (0, misc_js_1.isCloudflareWorkers)()) {
if (globalThis.crypto !== undefined) {
return globalThis.crypto.subtle;
}
// jsdom
if (dntShim.dntGlobalThis !== undefined && globalThis.crypto !== undefined) {
// Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
return globalThis.crypto.subtle;
}
// Node.js <= v18
try {

@@ -49,0 +48,0 @@ // @ts-ignore: to ignore "crypto"

@@ -9,3 +9,2 @@ import type { CipherSuiteParams } from "./interfaces/cipherSuiteParams.js";

* The class consists of the {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/x/chacha20Poly1305/mod.ts | @hpke/chcha20poly1305},

@@ -21,7 +20,7 @@ * {@link https://deno.land/x/hpke/x/dhkem-x25519/mod.ts | @hpke/dhkem-x25519} and

* - Creates encryption contexts both for senders and recipients.
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - Provides single-shot encryption API.
* - {@link seal}
* - {@link open}
* - {@link seal}
* - {@link open}
*

@@ -28,0 +27,0 @@ * The calling of the constructor of this class is the starting

@@ -33,3 +33,2 @@ (function (factory) {

* The class consists of the {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/core/mod.ts | @hpke/core},
* {@link https://deno.land/x/hpke/x/chacha20Poly1305/mod.ts | @hpke/chcha20poly1305},

@@ -45,7 +44,7 @@ * {@link https://deno.land/x/hpke/x/dhkem-x25519/mod.ts | @hpke/dhkem-x25519} and

* - Creates encryption contexts both for senders and recipients.
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - {@link createSenderContext}
* - {@link createRecipientContext}
* - Provides single-shot encryption API.
* - {@link seal}
* - {@link open}
* - {@link seal}
* - {@link open}
*

@@ -52,0 +51,0 @@ * The calling of the constructor of this class is the starting

@@ -21,15 +21,24 @@ import type { KdfInterface } from "../interfaces/kdfInterface.js";

export declare class HkdfSha256Native extends HkdfNative {
/** KdfId.HkdfSha256 (0x0001) */
readonly id: KdfId;
/** 32 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha384Native extends HkdfNative {
/** KdfId.HkdfSha384 (0x0002) */
readonly id: KdfId;
/** 48 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}
export declare class HkdfSha512Native extends HkdfNative {
/** KdfId.HkdfSha512 (0x0003) */
readonly id: KdfId;
/** 64 */
readonly hashSize: number;
/** The parameters for Web Cryptography API */
protected readonly algHash: HmacKeyGenParams;
}

@@ -143,2 +143,3 @@ (function (factory) {

super(...arguments);
/** KdfId.HkdfSha256 (0x0001) */
Object.defineProperty(this, "id", {

@@ -150,2 +151,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "hashSize", {

@@ -157,2 +159,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -174,2 +177,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha384 (0x0002) */
Object.defineProperty(this, "id", {

@@ -181,2 +185,3 @@ enumerable: true,

});
/** 48 */
Object.defineProperty(this, "hashSize", {

@@ -188,2 +193,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -205,2 +211,3 @@ enumerable: true,

super(...arguments);
/** KdfId.HkdfSha512 (0x0003) */
Object.defineProperty(this, "id", {

@@ -212,2 +219,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "hashSize", {

@@ -219,2 +227,3 @@ enumerable: true,

});
/** The parameters for Web Cryptography API */
Object.defineProperty(this, "algHash", {

@@ -221,0 +230,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X25519, HKDF-SHA256).
* The DHKEM(X25519, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -12,8 +12,29 @@ * This class is implemented using

*
* @example
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-x25519/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX25519HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemX25519HkdfSha256`
* can be used. You don't need to use this class.
*
* @example
*
* ```ts
* import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuite({
* kem: KemId.DhkemX25519HkdfSha256,
* kdf: KdfId.HkdfSha256,

@@ -25,8 +46,13 @@ * aead: AeadId.Aes128Gcm,

export declare class DhkemX25519HkdfSha256 extends Dhkem {
/** KemId.DhkemX25519HkdfSha256 (0x0020) */
readonly id: KemId;
/** 32 */
readonly secretSize: number;
/** 32 */
readonly encSize: number;
/** 32 */
readonly publicKeySize: number;
/** 32 */
readonly privateKeySize: number;
constructor();
}

@@ -18,3 +18,3 @@ (function (factory) {

/**
* The DHKEM(X25519, HKDF-SHA256).
* The DHKEM(X25519, HKDF-SHA256) for HPKE KEM implementing {@link KemInterface}.
*

@@ -27,8 +27,29 @@ * This class is implemented using

*
* @example
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import {
* Aes128Gcm,
* CipherSuite,
* HkdfSha256,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX25519HkdfSha256 } from "https://deno.land/x/hpke/x/dhkem-x25519/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX25519HkdfSha256(),
* kdf: new HkdfSha256(),
* aead: new Aes128Gcm(),
* });
* ```
*
* When using `hpke-js` (`https://deno.land/x/hpke/mod.ts`), `KemId.DhkemX25519HkdfSha256`
* can be used. You don't need to use this class.
*
* @example
*
* ```ts
* import { AeadId, CipherSuite, KdfId, KemId } from "https://deno.land/x/hpke/mod.ts";
*
* const suite = new CipherSuite({
* kem: KemId.DhkemX25519HkdfSha256,
* kdf: KdfId.HkdfSha256,

@@ -43,2 +64,3 @@ * aead: AeadId.Aes128Gcm,

super(identifiers_js_1.KemId.DhkemX25519HkdfSha256, new x25519_js_1.X25519(kdf), kdf);
/** KemId.DhkemX25519HkdfSha256 (0x0020) */
Object.defineProperty(this, "id", {

@@ -50,2 +72,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "secretSize", {

@@ -57,2 +80,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "encSize", {

@@ -64,2 +88,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "publicKeySize", {

@@ -71,2 +96,3 @@ enumerable: true,

});
/** 32 */
Object.defineProperty(this, "privateKeySize", {

@@ -73,0 +99,0 @@ enumerable: true,

import { KemId } from "../identifiers.js";
import { Dhkem } from "./dhkem.js";
/**
* The DHKEM(X448, HKDF-SHA512).
* The DHKEM(X448, HKDF-SHA512) for HPKE KEM implementing {@link KemInterface}.
*

@@ -12,20 +12,44 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { CipherSuite, AeadId, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* aead: AeadId.Aes256Gcm,
* });
* ```
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* HkdfSha512,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: new HkdfSha512(),
* aead: new Aes256Gcm(),
* });
* ```
*/
export declare class DhkemX448HkdfSha512 extends Dhkem {
/** KemId.DhkemX448HkdfSha512 (0x0021) */
readonly id: KemId;
/** 64 */
readonly secretSize: number;
/** 56 */
readonly encSize: number;
/** 56 */
readonly publicKeySize: number;
/** 56 */
readonly privateKeySize: number;
constructor();
}

@@ -18,3 +18,3 @@ (function (factory) {

/**
* The DHKEM(X448, HKDF-SHA512).
* The DHKEM(X448, HKDF-SHA512) for HPKE KEM implementing {@link KemInterface}.
*

@@ -27,12 +27,31 @@ * This class is implemented using

*
* @example
* @example Use with `hpke-js` (`https://deno.land/x/hpke/mod.ts`).
*
* ```ts
* import { KdfId, AeadId, CipherSuite } from "http://deno.land/x/hpke/core/mod.ts";
* import { CipherSuite, AeadId, KdfId } from "https://deno.land/x/hpke/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: KdfId.HkdfSha512,
* aead: AeadId.Aes128Gcm,
* aead: AeadId.Aes256Gcm,
* });
* ```
*
* @example Use with `@hpke/core` (`https://deno.land/x/hpke/core/mod.ts`).
*
* ```ts
* import {
* Aes256Gcm,
* CipherSuite,
* HkdfSha512,
* } from "https://deno.land/x/hpke/core/mod.ts";
* import { DhkemX448HkdfSha512 } from "https://deno.land/x/hpke/x/dhkem-x448/mod.ts";
*
* const suite = new CipherSuite({
* kem: new DhkemX448HkdfSha512(),
* kdf: new HkdfSha512(),
* aead: new Aes256Gcm(),
* });
* ```
*/

@@ -43,2 +62,3 @@ class DhkemX448HkdfSha512 extends dhkem_js_1.Dhkem {

super(identifiers_js_1.KemId.DhkemX448HkdfSha512, new x448_js_1.X448(kdf), kdf);
/** KemId.DhkemX448HkdfSha512 (0x0021) */
Object.defineProperty(this, "id", {

@@ -50,2 +70,3 @@ enumerable: true,

});
/** 64 */
Object.defineProperty(this, "secretSize", {

@@ -57,2 +78,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "encSize", {

@@ -64,2 +86,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "publicKeySize", {

@@ -71,2 +94,3 @@ enumerable: true,

});
/** 56 */
Object.defineProperty(this, "privateKeySize", {

@@ -73,0 +97,0 @@ enumerable: true,

/**
* Checks whether the execution env is browser or not.
*/
export declare const isBrowser: () => boolean;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
export declare const isCloudflareWorkers: () => boolean;
/**
* Checks whether the execution env is Deno or not.

@@ -11,0 +3,0 @@ */

@@ -1,24 +0,1 @@

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
(function (factory) {

@@ -30,3 +7,3 @@ if (typeof module === "object" && typeof module.exports === "object") {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../../_dnt.shims.js"], factory);
define(["require", "exports"], factory);
}

@@ -36,15 +13,4 @@ })(function (require, exports) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.base64UrlToBytes = exports.concat = exports.i2Osp = exports.isCryptoKeyPair = exports.isDeno = exports.isCloudflareWorkers = exports.isBrowser = void 0;
const dntShim = __importStar(require("../../_dnt.shims.js"));
exports.base64UrlToBytes = exports.concat = exports.i2Osp = exports.isCryptoKeyPair = exports.isDeno = void 0;
/**
* Checks whether the execution env is browser or not.
*/
const isBrowser = () => typeof dntShim.dntGlobalThis !== "undefined";
exports.isBrowser = isBrowser;
/**
* Checks whether the execution env is Cloudflare Workers or not.
*/
const isCloudflareWorkers = () => typeof caches !== "undefined";
exports.isCloudflareWorkers = isCloudflareWorkers;
/**
* Checks whether the execution env is Deno or not.

@@ -51,0 +17,0 @@ */

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc