(digestmod: &PyObjectRef, vm: &VirtualMachine)
| 216 | } |
| 217 | |
| 218 | fn resolve_digestmod(digestmod: &PyObjectRef, vm: &VirtualMachine) -> PyResult<String> { |
| 219 | if let Some(name) = digestmod.downcast_ref::<PyStr>() |
| 220 | && let Some(name_str) = name.to_str() |
| 221 | { |
| 222 | return Ok(name_str.to_lowercase()); |
| 223 | } |
| 224 | if let Ok(name_obj) = digestmod.get_attr("__name__", vm) |
| 225 | && let Some(name) = name_obj.downcast_ref::<PyStr>() |
| 226 | && let Some(name_str) = name.to_str() |
| 227 | && let Some(algo) = name_str.strip_prefix("openssl_") |
| 228 | { |
| 229 | return Ok(algo.to_owned()); |
| 230 | } |
| 231 | Err(vm.new_exception_msg( |
| 232 | UnsupportedDigestmodError::static_type().to_owned(), |
| 233 | "unsupported digestmod".into(), |
| 234 | )) |
| 235 | } |
| 236 | |
| 237 | fn hash_digest_size(name: &str) -> Option<usize> { |
| 238 | match name { |
no test coverage detected