-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive Key #83
Draft
catdevman
wants to merge
26
commits into
grafana:main
Choose a base branch
from
catdevman:feature/derive-key
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Derive Key #83
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d5d68ac
Add algorithms that didn't already exist
catdevman e573a20
Add ECDHKeyDeriveParams
catdevman 977dc76
skeleton appears to be there, just need internal implementation
catdevman 007e5bc
add derivekey operation
catdevman 381ba93
skeleton
catdevman 0298e06
params skeleton
catdevman 638f53c
getting keydata
catdevman 4eff252
deriveKey example without param
catdevman a24f7d8
Remove derivekey for derivebits which seems to be the operation the s…
catdevman 2cb65bc
add DeriveKey to ecdh, hkdf, pbkdf2
catdevman 60b701a
add examples and running them for test
catdevman 425121f
good progress
catdevman 1d64240
making some changes
catdevman 4db18da
temp place to put these
catdevman c692850
I think this a good test... I took the example from MDN :shrug:
catdevman bbd2469
adding some algos that I think need to be implemented to fully do der…
catdevman bc62565
detect new key type and handle creating a KeyImportParam for PBKDF2
catdevman 11d2c3c
continuing to write algo for DeriveKey
catdevman 8a2cc56
more testing
catdevman e53faec
remove example for derive_key
catdevman 58bcbd3
remove this file that had nothing in it
catdevman 31ceaca
add pbkdf2 files; figure out why this is passing even though it shoul…
catdevman 6023599
fix up tests so they run, failing tests are a good sign of being on t…
catdevman 6ad2f28
add path for PBKDF2
catdevman 1548174
privateKey and publicKey for deriveBitsPBKDF2 but I think this needs …
catdevman f2e26e5
clean this up later
catdevman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const key = await crypto.subtle.deriveKey(); | ||
|
||
console.log(JSON.stringify(key)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package webcrypto | ||
|
||
import "github.com/grafana/sobek" | ||
|
||
func newECDHDeriveParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*ECDHKeyDeriveParams, error) { | ||
//TODO: add implmentation | ||
return nil, nil | ||
} | ||
|
||
func (e *ECDHKeyDeriveParams) DeriveKey() (CryptoKeyGenerationResult, error){ | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package webcrypto | ||
|
||
import "github.com/grafana/sobek" | ||
|
||
func newHKDFKeyDeriveParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*HKDFParams, error) { | ||
//TODO: add implmentation | ||
return nil, nil | ||
} | ||
|
||
func (h HKDFParams) DeriveKey() (CryptoKeyGenerationResult, error){ | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package webcrypto | ||
|
||
import "github.com/grafana/sobek" | ||
|
||
func newPBKDF2KeyDeriveParams(rt *sobek.Runtime, normalized Algorithm, params sobek.Value) (*PBKDF2Params, error) { | ||
//TODO: add implmentation | ||
hashValue, err := traverseObject(rt, params, "hash") | ||
if err != nil { | ||
return nil, NewError(SyntaxError, "could not get hash from algorithm parameter") | ||
} | ||
|
||
normalizedHash, err := normalizeAlgorithm(rt, hashValue, OperationIdentifierDeriveKey) | ||
if err != nil { | ||
|
||
return nil, err | ||
} | ||
return &PBKDF2Params{ | ||
Name: normalized.Name, | ||
Hash: normalizedHash.Name, | ||
Salt: []byte{}, | ||
}, nil | ||
} | ||
|
||
func (p PBKDF2Params) DeriveKey() (CryptoKeyGenerationResult, error){ | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
OperationIdentifierDeriveKey
instead? 🙇♂️ (note that maybederiveKey
might rely on the bits derivation under the hood and I'm not just aware of it)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that is what I found the step 2 in the spec here for deriveKey requires deriveBits. So I think the issues for deriveBits need worked on first before I can continue so that is my current side mission 😄 I also realized that step 6 requires a "get key length" which was the util function I was referring to in my part 2 of the question from the other day. I think that is also going to be needed for the deriveBits issues so 2 birds 1 stone type of thing going on. Either way I am fairly sure that function will need to be our own implementation because I am not seeing it in any of the libraries that you mentioned.