Comments (6)
My understanding of the raw representation of CryptoKey objects is that they are not equivalent to the HPKE public key serialized representation. If that's the case, then yes, something like the exportKey function you propose for KEMs would work well!
from hpke-js.
My understand of the raw representation of CryptoKey objects is that they are not equivalent to the HPKE public key serialized representation.
I guess in some cases they will be the same, in other cases they will be different. Understood. At least, we might have to avoid the function name like exportKey
which misleads that it's the same as Web Crypto API. Anyway, I'll implement it.
I'll ask you to review the PR. Wait for a few days.
from hpke-js.
Encoding the public key is sufficient for now -- thank you! This works perfectly.
from hpke-js.
Hi @chris-wood,
Actually, only in case for DHKEM(P-*), you can convert between raw keys and CryptoKeys in the following way.
const suite = new CipherSuite({
kem: Kem.DhkemP256HkdfSha256,
kdf: Kdf.HkdfSha256,
aead: Aead.Aes128Gcm
});
const rkp = await suite.generateKeyPair();
// CryptoKey to raw
const raw = await crypto.subtle.exportKey("raw", rkp.publicKey);
// raw to CryptoKey
const kemCtx = await suite.kemContext();
const cryptoKey = await kemCtx.importKey("raw", raw, true);
This method is not available in DHKEM(X*), so it might be better to have a utility function, for example, KemInterface.exportKey("raw", xxx).
KemInterface.exportKey() so that the upper application layer does not have to worry about Web Crypto API compatibility.
Is this what you want?
from hpke-js.
Perfect -- thanks!
from hpke-js.
... I'm very sorry. I was going to implement it, but I had already done it 2 months ago.
I completely forgot about it...
Could you update hpke-js to v0.18.2 and try it?
const suite = new CipherSuite({
kem: Kem.DhkemP256HkdfSha256,
kdf: Kdf.HkdfSha256,
aead: Aead.Aes128Gcm
});
const kemContext = await suite.kemContext();
const kp = await kemContext.generateKeyPair();
// CryptoKey to raw
const rawPubKey = await kemContext.serializePublicKey(kp.publicKey);
// raw to CryptoKey
const pubKey = await kemContext.deserializePublicKey(rawPubKey);
If you want serializePrivateKey()/deserializePrivateKey()
as well, feel free to ask me.
from hpke-js.
Related Issues (20)
- Add security policy document.
- Add Bun to supported JavaScript runtimes.
- Add fastly/js-compute to supported JavaScript runtimes.
- Add JWK support to importKey. HOT 3
- Strange interaction with vercel/ncc HOT 1
- Publish a new npm hpke-js pkg version
- Drop support for egg.
- Add package.json.
- Replace chacha20poly1305 with noble/ciphers
- Add support for X25519Kyber768
- Question about the JS module size HOT 2
- Fix docs for deno.land. HOT 1
- suite.kemContext is not a function HOT 2
- We are using bidirectional encryption support and cannot find way to re-implement it in v1.2.3 HOT 3
- IANA codepoint for DHKEM-over-secp256k1 HOT 4
- Suggestions for Browser Extension Manifest V3 HOT 3
- Expose HKDFs as utilities HOT 1
- Cannot find module './src/cipherSuite.js' HOT 5
- Consider adding ML-KEM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hpke-js.