-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d62fbcf
commit 5fce067
Showing
8 changed files
with
372 additions
and
112 deletions.
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,28 @@ | ||
import { crypto } from "k6/x/webcrypto"; | ||
|
||
export default async function () { | ||
const jwk = { | ||
kty: "EC", | ||
crv: "P-521", | ||
x: "AVb0efjfHiCn_8BM5CDD4VSuJRmWvuQvA0uE1Bt0PzTkXzEbgTqc3sjNpZu7vTHUYLMpJSHnwbci5WZ8A9svrnU_", | ||
y: "AVAXNs_iRzlDINjkr8L9ObWpMxBhuB4iQSgrnheJGCK1t54FL0WXtZZD_Tk3nFG9USXE9IvD8CXOPNNpUyhsyzj7", | ||
d: "APQIdYNoupMPMPdq4FT-XNLOf9osn3am1DbPddZsRAv-YzHHwXKhJHgZPIJRSHvJEmP6UCF_hf9jb1nNVG46tIO0", | ||
}; | ||
|
||
console.log("static key: " + JSON.stringify(jwk)); | ||
|
||
|
||
const importedKey = await crypto.subtle.importKey( | ||
"jwk", | ||
jwk, | ||
{ name: "ECDSA", namedCurve: "P-256" }, | ||
true, | ||
["sign"] | ||
); | ||
|
||
console.log("imported: " + JSON.stringify(importedKey)); | ||
|
||
const exportedAgain = await crypto.subtle.exportKey("jwk", importedKey); | ||
|
||
console.log("exported again: " + JSON.stringify(exportedAgain)); | ||
} |
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
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,11 @@ | ||
package webcrypto | ||
|
||
import "encoding/base64" | ||
|
||
func base64URLEncode(data []byte) string { | ||
return base64.RawURLEncoding.EncodeToString(data) | ||
} | ||
|
||
func base64URLDecode(data string) ([]byte, error) { | ||
return base64.RawURLEncoding.DecodeString(data) | ||
} |
Oops, something went wrong.