dom-examples
dom-examples copied to clipboard
Why ECDH derived key always starts with 00-byte?
https://github.com/mdn/dom-examples/blob/224c7f14cd824fb589404ed0048e2fd1edd5bddc/web-crypto/derive-key/ecdh.js#L85
when CryptoKey (shared secret) is made and exported, it is 32 byte sequence with first zero-byte? So,
- Why zero-byte?
- How to get full/longer byte-sequence?
Here is the keys (a is made on server, b in browser):

- Oookey, it not always starts with zerobyte... usually first 4 bits are zeroes.
- These:
deriveParams: {
name: 'HMAC'
hash: 'SHA-512'
length: 528
}
may be used to export full byte sequence later, but keyUsage parameter in deriveKey may not be empty, so I've used ['sign']...
Also, sometimes derived & exported key is smaller than 528, can be 520. that's strange but maybe i did something wrong again...
@wbamberg , can you comment on this one? Thanks!
@chrisdavidmills hey,
check this out: http://raw.githack.com/determin1st/httpFetch/master/test-7/index.html
works in firefox, but not in chrome :/
Due to the age of this issue I'm closing it 👍