Skip to content
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

ECDSA support #69

Merged
merged 8 commits into from Apr 17, 2024
Merged

ECDSA support #69

merged 8 commits into from Apr 17, 2024

Conversation

olegbespalov
Copy link
Contributor

@olegbespalov olegbespalov commented Apr 10, 2024

What?

This PR is based on #67 and extends support of elliptic curves in xk6-webcrypto.

It brings support to the ECDSA for the following methods:

  • import/export keys
  • sign
  • verify

It also brings the spki format support for both ECDH and ECDSA.

Why?

Closes: #48
Closes: #70

@olegbespalov olegbespalov self-assigned this Apr 10, 2024
@olegbespalov olegbespalov force-pushed the feat/ecdsa branch 2 times, most recently from 3851c78 to a8aa30e Compare April 11, 2024 14:50
@olegbespalov olegbespalov force-pushed the feat/ecdh branch 2 times, most recently from a15ebeb to cb23f63 Compare April 12, 2024 07:07
@olegbespalov olegbespalov mentioned this pull request Apr 12, 2024
@olegbespalov olegbespalov marked this pull request as ready for review April 12, 2024 12:52
@olegbespalov olegbespalov requested a review from a team as a code owner April 12, 2024 12:52
@olegbespalov olegbespalov requested review from mstoykov and oleiade and removed request for a team April 12, 2024 12:52
Base automatically changed from feat/ecdh to main April 12, 2024 13:28
Comment on lines +37 to +49
const string2ArrayBuffer = (str) => {
let buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
let bufView = new Uint16Array(buf);
for (let i = 0, strLen = str.length; i < strLen; i++) {
bufView[i] = str.charCodeAt(i);
}
return buf;
};

const printArrayBuffer = (buffer) => {
let view = new Uint8Array(buffer);
return Array.from(view);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having seen this in a bunch of places at this point - maybe move them to a helper functio( in another PR)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was asking myself the same question but ended up this way since I wanted that example to be "completed" (without the need to have multiple files), just copy/run. Do you think it makes sense?

webcrypto/subtle_crypto.go Outdated Show resolved Hide resolved
webcrypto/subtle_crypto.go Outdated Show resolved Hide resolved
webcrypto/subtle_crypto.go Show resolved Hide resolved
webcrypto/subtle_crypto.go Outdated Show resolved Hide resolved
}

resolve(rt.NewArrayBuffer(signature))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same problem as in the previous PRs with using the runtime in a goroutine off the event loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but I'd like to do this separately (in ~1h I'll push a PR with fixing all methods)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See a draft #75

Copy link
Contributor

@mstoykov mstoykov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if #75 is merged just after this.

Copy link
Member

@oleiade oleiade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@olegbespalov olegbespalov merged commit 5a9109d into main Apr 17, 2024
10 checks passed
@olegbespalov olegbespalov deleted the feat/ecdsa branch April 17, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subject Public Key Info (spki) format support Implement support for ECDSA across the supported APIs
3 participants