summaryrefslogtreecommitdiff
path: root/ext/crypto/shared.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/crypto/shared.rs')
-rw-r--r--ext/crypto/shared.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/crypto/shared.rs b/ext/crypto/shared.rs
index 21fddc745..d5b2d6593 100644
--- a/ext/crypto/shared.rs
+++ b/ext/crypto/shared.rs
@@ -98,11 +98,9 @@ impl V8RawKeyData {
pub fn as_ec_public_key_p256(&self) -> Result<p256::EncodedPoint, AnyError> {
match self {
- V8RawKeyData::Public(data) => {
- // public_key is a serialized EncodedPoint
- p256::EncodedPoint::from_bytes(data)
- .map_err(|_| type_error("expected valid public EC key"))
- }
+ V8RawKeyData::Public(data) => p256::PublicKey::from_sec1_bytes(data)
+ .map(|p| p.to_encoded_point(false))
+ .map_err(|_| type_error("expected valid public EC key")),
V8RawKeyData::Private(data) => {
let signing_key = p256::SecretKey::from_pkcs8_der(data)
.map_err(|_| type_error("expected valid private EC key"))?;
@@ -115,11 +113,9 @@ impl V8RawKeyData {
pub fn as_ec_public_key_p384(&self) -> Result<p384::EncodedPoint, AnyError> {
match self {
- V8RawKeyData::Public(data) => {
- // public_key is a serialized EncodedPoint
- p384::EncodedPoint::from_bytes(data)
- .map_err(|_| type_error("expected valid public EC key"))
- }
+ V8RawKeyData::Public(data) => p384::PublicKey::from_sec1_bytes(data)
+ .map(|p| p.to_encoded_point(false))
+ .map_err(|_| type_error("expected valid public EC key")),
V8RawKeyData::Private(data) => {
let signing_key = p384::SecretKey::from_pkcs8_der(data)
.map_err(|_| type_error("expected valid private EC key"))?;