|
1 | | -// spell-checker:ignore usedforsecurity HASHXOF |
| 1 | +use crate::vm::{builtins::PyModule, PyRef, VirtualMachine}; |
2 | 2 |
|
3 | | -pub(crate) use _sha512::make_module; |
| 3 | +pub(crate) fn make_module(vm: &VirtualMachine) -> PyRef<PyModule> { |
| 4 | + let _ = vm.import("_hashlib", 0); |
| 5 | + _sha512::make_module(vm) |
| 6 | +} |
4 | 7 |
|
5 | 8 | #[pymodule] |
6 | 9 | mod _sha512 { |
7 | | - use crate::hashlib::_hashlib::{HashArgs, HashWrapper, PyHasher}; |
8 | | - use crate::vm::{PyObjectRef, PyPayload, PyResult, VirtualMachine}; |
9 | | - use sha2::{Sha384, Sha512}; |
| 10 | + use crate::hashlib::_hashlib::{local_sha384, local_sha512, HashArgs}; |
| 11 | + use crate::vm::{PyPayload, PyResult, VirtualMachine}; |
10 | 12 |
|
11 | | - #[pyfunction(name = "sha384")] |
12 | | - fn sha384(args: HashArgs, vm: &VirtualMachine) -> PyResult<PyObjectRef> { |
13 | | - Ok(PyHasher::new("sha384", HashWrapper::new::<Sha384>(args.string)).into_pyobject(vm)) |
| 13 | + #[pyfunction] |
| 14 | + fn sha384(args: HashArgs, vm: &VirtualMachine) -> PyResult { |
| 15 | + Ok(local_sha384(args).into_pyobject(vm)) |
14 | 16 | } |
15 | 17 |
|
16 | | - #[pyfunction(name = "sha512")] |
17 | | - fn sha512(args: HashArgs, vm: &VirtualMachine) -> PyResult<PyObjectRef> { |
18 | | - Ok(PyHasher::new("sha512", HashWrapper::new::<Sha512>(args.string)).into_pyobject(vm)) |
| 18 | + #[pyfunction] |
| 19 | + fn sha512(args: HashArgs, vm: &VirtualMachine) -> PyResult { |
| 20 | + Ok(local_sha512(args).into_pyobject(vm)) |
19 | 21 | } |
20 | 22 | } |
0 commit comments