mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(ext/crypto): use NotSupportedError for importKey() (#12289)
This commit is contained in:
parent
774302b9bb
commit
c11ad5dba9
1 changed files with 24 additions and 10 deletions
|
@ -1100,13 +1100,20 @@ pub async fn op_crypto_import_key(
|
||||||
RSA_ENCRYPTION_OID => None,
|
RSA_ENCRYPTION_OID => None,
|
||||||
// id-RSASSA-PSS
|
// id-RSASSA-PSS
|
||||||
RSASSA_PSS_OID => {
|
RSASSA_PSS_OID => {
|
||||||
// TODO(@littledivy): NotSupported error
|
|
||||||
let params = PssPrivateKeyParameters::try_from(
|
let params = PssPrivateKeyParameters::try_from(
|
||||||
pk_info.algorithm.parameters.ok_or_else(|| {
|
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_alg = params.hash_algorithm;
|
||||||
let hash = match hash_alg.oid {
|
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 {
|
if params.mask_gen_algorithm.oid != ID_MFG1 {
|
||||||
// TODO(@littledivy): NotSupportedError
|
return Err(custom_error(
|
||||||
return Err(type_error(
|
"DOMExceptionNotSupportedError",
|
||||||
"Unsupported hash algorithm".to_string(),
|
"Unsupported hash algorithm".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -1207,13 +1214,20 @@ pub async fn op_crypto_import_key(
|
||||||
RSA_ENCRYPTION_OID => None,
|
RSA_ENCRYPTION_OID => None,
|
||||||
// id-RSAES-OAEP
|
// id-RSAES-OAEP
|
||||||
RSAES_OAEP_OID => {
|
RSAES_OAEP_OID => {
|
||||||
// TODO(@littledivy): NotSupported error
|
|
||||||
let params = OaepPrivateKeyParameters::try_from(
|
let params = OaepPrivateKeyParameters::try_from(
|
||||||
pk_info.algorithm.parameters.ok_or_else(|| {
|
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_alg = params.hash_algorithm;
|
||||||
let hash = match hash_alg.oid {
|
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 {
|
if params.mask_gen_algorithm.oid != ID_MFG1 {
|
||||||
// TODO(@littledivy): NotSupportedError
|
return Err(custom_error(
|
||||||
return Err(type_error(
|
"DOMExceptionNotSupportedError",
|
||||||
"Unsupported hash algorithm".to_string(),
|
"Unsupported hash algorithm".to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue