summaryrefslogtreecommitdiff
path: root/ext/crypto/lib.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2021-10-01 16:46:11 +0530
committerGitHub <noreply@github.com>2021-10-01 13:16:11 +0200
commit1dfa35b2ba1dadf0158a00b72e98d83cd3e69ee5 (patch)
treee4e418fbdb78ad8cdec97e8f1560811655404444 /ext/crypto/lib.rs
parentf68825eda03d43e2e75a8db7068ca19a88dfb6a7 (diff)
fix(ext/crypto): use NotSupportedError for importKey() (#12289)
Diffstat (limited to 'ext/crypto/lib.rs')
-rw-r--r--ext/crypto/lib.rs34
1 files changed, 24 insertions, 10 deletions
diff --git a/ext/crypto/lib.rs b/ext/crypto/lib.rs
index d990bf2a4..9db229266 100644
--- a/ext/crypto/lib.rs
+++ b/ext/crypto/lib.rs
@@ -1100,13 +1100,20 @@ pub async fn op_crypto_import_key(
RSA_ENCRYPTION_OID => None,
// id-RSASSA-PSS
RSASSA_PSS_OID => {
- // TODO(@littledivy): NotSupported error
let params = PssPrivateKeyParameters::try_from(
pk_info.algorithm.parameters.ok_or_else(|| {
- type_error("Malformed parameters".to_string())
+ custom_error(
+ "DOMExceptionNotSupportedError",
+ "Malformed parameters".to_string(),
+ )
})?,
)
- .map_err(|_| type_error("Malformed parameters".to_string()))?;
+ .map_err(|_| {
+ custom_error(
+ "DOMExceptionNotSupportedError",
+ "Malformed parameters".to_string(),
+ )
+ })?;
let hash_alg = params.hash_algorithm;
let hash = match hash_alg.oid {
@@ -1127,8 +1134,8 @@ pub async fn op_crypto_import_key(
};
if params.mask_gen_algorithm.oid != ID_MFG1 {
- // TODO(@littledivy): NotSupportedError
- return Err(type_error(
+ return Err(custom_error(
+ "DOMExceptionNotSupportedError",
"Unsupported hash algorithm".to_string(),
));
}
@@ -1207,13 +1214,20 @@ pub async fn op_crypto_import_key(
RSA_ENCRYPTION_OID => None,
// id-RSAES-OAEP
RSAES_OAEP_OID => {
- // TODO(@littledivy): NotSupported error
let params = OaepPrivateKeyParameters::try_from(
pk_info.algorithm.parameters.ok_or_else(|| {
- type_error("Malformed parameters".to_string())
+ custom_error(
+ "DOMExceptionNotSupportedError",
+ "Malformed parameters".to_string(),
+ )
})?,
)
- .map_err(|_| type_error("Malformed parameters".to_string()))?;
+ .map_err(|_| {
+ custom_error(
+ "DOMExceptionNotSupportedError",
+ "Malformed parameters".to_string(),
+ )
+ })?;
let hash_alg = params.hash_algorithm;
let hash = match hash_alg.oid {
@@ -1234,8 +1248,8 @@ pub async fn op_crypto_import_key(
};
if params.mask_gen_algorithm.oid != ID_MFG1 {
- // TODO(@littledivy): NotSupportedError
- return Err(type_error(
+ return Err(custom_error(
+ "DOMExceptionNotSupportedError",
"Unsupported hash algorithm".to_string(),
));
}