Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

yubihsm setup: use hkd32 crate to derive key hierarchy #302

Merged
merged 1 commit into from
Jul 24, 2019
Merged

Conversation

tony-iqlusion
Copy link
Contributor

@tony-iqlusion tony-iqlusion commented Jul 24, 2019

hkd32 is an implementation of the same hierarchical key derivation algorithm the KMS was previously using, which is an extracted subset of the symmetric parts of BIP32 derivation (to the point it could potentially be used to implement a full BIP32).

The hkd32 crate has the advantage of using a zeroize-on-drop type for all key material, as opposed to some of the manual zeroization this crate was previously using. In addition, it has some richer types for things like derivation paths, which may be potentially useful in the future.

There is one case that deviated from the previous implementation, which is the behavior of calling derive with an empty derivation path. Before it would output the "chain code" derived after inputting the DERIVATION_VERSION, whereas when using hkd32 it correctly outputs the other half of the derived key material, which is intended to be used as a secret key.

Nothing presently calls the derivation function with an empty derivation path, except for a test I just added today in #299. While the output for this case differs, it has no practical impact, and if anything the function outputting the raw chain code for the first level of the hierarchy (which is the version number) is a sharp edge that could potentially leak what is the root key to the entire hierarchy if it were to be called with an empty derivation path.

hkd32 uses a fully uniform derivation algorithm which treats the DERIVATION_VERSION like any other part of the path, and therefore does not have this sharp edge.

Test vectors for path lengths of 1, 2, and 3 all pass with the original vectors.

`hkd32` is an implementation of the same hierarchical key derivation
algorithm the KMS was previously using, which is an extracted subset of
the symmetric parts of BIP32 derivation (to the point it could
potentially be used to implement a full BIP32).

The `hkd32` crate has the advantage of using a zeroize-on-drop type for
all key material, as opposed to some of the manual zeroization this
crate was previously using. In addition, it has some richer types for
things like derivation paths, which may be potentially useful in the
future.

There is one case that deviated from the previous implementation, which
is the behavior of calling derive with an empty derivation path.
Before it would output the "chain code" derived after inputting the
`DERIVATION_VERSION`, whereas when using `hkd32` it correctly outputs
the other half of the derived key material, which is intended to be
used as a secret key.

Nothing presently calls the derivation function with an empty derivation
path, except for a test I just added today in #299. While the output for
this case differs, it has no practical impact, and if anything the
function outputting the raw chain code for the first level of the
hierarchy (which is the version number) is a sharp edge that could
potentially leak what is the root key to the entire hierarchy if it were
to be called with an empty derivation path.

`hkd32` uses a fully uniform derivation algorithm which treats the
`DERIVATION_VERSION` like any other part of the path, and therefore does
not have this sharp edge.

Test vectors for path lengths of 1, 2, and 3 all pass with the original
vectors.
@tarcieri tarcieri merged commit 6099e2c into master Jul 24, 2019
@tarcieri tarcieri deleted the hkd32 branch July 24, 2019 06:51
@tarcieri tarcieri added the security Security-critical issues label Jul 25, 2019
This was referenced Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
security Security-critical issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants