Comparing version 1.4.3 to 1.5.0
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP256HkdfSha256 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP256.d.ts.map |
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP384HkdfSha384 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP384.d.ts.map |
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP521HkdfSha512 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP521.d.ts.map |
{ | ||
"name": "hpke-js", | ||
"version": "1.4.3", | ||
"version": "1.5.0", | ||
"description": "A Hybrid Public Key Encryption (HPKE) module for various JavaScript runtimes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -45,4 +45,2 @@ <h1 align="center">hpke-js</h1> | ||
```js | ||
// import { AeadId, CipherSuite, KdfId, KemId } from "hpke-js"; | ||
// const { AeadId, CipherSuite, KdfId, KemId } = require("@hpke/hpke-js"); | ||
import { | ||
@@ -56,10 +54,2 @@ Aes128Gcm, | ||
async function doHpke() { | ||
// When using "hpke-js", specify the cryptographic algorithm as follows: | ||
// const suite = new CipherSuite({ | ||
// kem: KemId.DhkemP256HkdfSha256, | ||
// kdf: KdfId.HkdfSha256, | ||
// aead: AeadId.Aes128Gcm, | ||
// }); | ||
// When using "@hpke/core", specify the cryptographic algorithm instances | ||
// as follows, instead of identities above: | ||
const suite = new CipherSuite({ | ||
@@ -71,14 +61,32 @@ kem: new DhkemP256HkdfSha256(), | ||
// A recipient generates a key pair. | ||
const rkp = await suite.kem.generateKeyPair(); | ||
const jwkPkR = { | ||
kty: "EC", | ||
crv: "P-256", | ||
kid: "P-256-01", | ||
x: "-eZXC6nV-xgthy8zZMCN8pcYSeE2XfWWqckA2fsxHPc", | ||
y: "BGU5soLgsu_y7GN2I3EPUXS9EZ7Sw0qif-V70JtInFI", | ||
key_ops: [], | ||
}; | ||
const pkR = await suite.kem.importKey("jwk", jwkPkR, true); | ||
// A sender encrypts a message with the recipient public key. | ||
// The sender encrypts a message. | ||
const sender = await suite.createSenderContext({ | ||
recipientPublicKey: rkp.publicKey, | ||
recipientPublicKey: pkR, | ||
}); | ||
const ct = await sender.seal(new TextEncoder().encode("Hello world!")); | ||
const jwkSkR = { | ||
kty: "EC", | ||
crv: "P-256", | ||
kid: "P-256-01", | ||
x: "-eZXC6nV-xgthy8zZMCN8pcYSeE2XfWWqckA2fsxHPc", | ||
y: "BGU5soLgsu_y7GN2I3EPUXS9EZ7Sw0qif-V70JtInFI", | ||
d: "kwibx3gas6Kz1V2fyQHKSnr-ybflddSjN0eOnbmLmyo", | ||
key_ops: ["deriveBits"], | ||
}; | ||
const skR = await suite.kem.importKey("jwk", jwkSkR, false); | ||
// The recipient decrypts it. | ||
const recipient = await suite.createRecipientContext({ | ||
recipientKey: rkp.privateKey, | ||
recipientKey: skR, | ||
enc: sender.enc, | ||
@@ -454,3 +462,8 @@ }); | ||
<script type="module"> | ||
import { AeadId, CipherSuite, KdfId, KemId } from "https://esm.sh/hpke-js@<SEMVER>"; | ||
import { | ||
AeadId, | ||
CipherSuite, | ||
KdfId, | ||
KemId, | ||
} from "https://esm.sh/hpke-js@<SEMVER>"; | ||
// import { | ||
@@ -465,15 +478,14 @@ // Aes128Gcm, CipherSuite, DhkemP256HkdfSha256, HkdfSha256, | ||
kdf: KdfId.HkdfSha256, | ||
aead: AeadId.Aes128Gcm | ||
aead: AeadId.Aes128Gcm, | ||
}); | ||
const rkp = await suite.kem.generateKeyPair(); | ||
const sender = await suite.createSenderContext({ | ||
recipientPublicKey: rkp.publicKey | ||
recipientPublicKey: rkp.publicKey, | ||
}); | ||
// encrypt | ||
const ct = await sender.seal(new TextEncoder().encode("Hello world!")); | ||
const recipient = await suite.createRecipientContext({ | ||
@@ -492,4 +504,3 @@ recipientKey: rkp.privateKey, // rkp (CryptoKeyPair) is also acceptable. | ||
} | ||
} | ||
}; | ||
</script> | ||
@@ -533,4 +544,4 @@ <button type="button" onclick="doHpke()">do HPKE</button> | ||
doHpke(); | ||
} catch (err) { | ||
console.log("failed:", err.message); | ||
} catch (err: unknown) { | ||
console.log("failed:", (err as Error).message); | ||
} | ||
@@ -575,4 +586,4 @@ ``` | ||
doHpke(); | ||
} catch (err) { | ||
console.log("failed:", err.message); | ||
} catch (err: unknown) { | ||
console.log("failed:", (err as Error).message); | ||
} | ||
@@ -583,3 +594,3 @@ ``` | ||
Node.js: | ||
Deno: | ||
@@ -629,4 +640,4 @@ ```ts | ||
doHpke(); | ||
} catch (err) { | ||
console.log("failed:", err.message); | ||
} catch (err: unknown) { | ||
console.log("failed:", (err as Error).message); | ||
} | ||
@@ -675,4 +686,4 @@ ``` | ||
doHpke(); | ||
} catch (err) { | ||
console.log("failed:", err.message); | ||
} catch (err: unknown) { | ||
console.log("failed:", (err as Error).message); | ||
} | ||
@@ -731,4 +742,4 @@ ``` | ||
doHpke(); | ||
} catch (err) { | ||
console.log("failed:", err.message); | ||
} catch (err: unknown) { | ||
console.log("failed:", (err as Error).message); | ||
} | ||
@@ -735,0 +746,0 @@ ``` |
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP256HkdfSha256 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP256.d.ts.map |
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP384HkdfSha384 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP384.d.ts.map |
import { Dhkem, KemId } from "@hpke/common"; | ||
export declare class DhkemP521HkdfSha512 extends Dhkem { | ||
readonly id: KemId; | ||
readonly secretSize: number; | ||
readonly encSize: number; | ||
readonly publicKeySize: number; | ||
readonly privateKeySize: number; | ||
id: KemId; | ||
secretSize: number; | ||
encSize: number; | ||
publicKeySize: number; | ||
privateKeySize: number; | ||
constructor(); | ||
} | ||
//# sourceMappingURL=dhkemP521.d.ts.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
745
183537