2023-05-08 01:20:28 +02:00
|
|
|
#![warn(missing_docs)]
|
|
|
|
#![warn(clippy::missing_docs_in_private_items)]
|
|
|
|
//!
|
|
|
|
//! This is a mixed rust/python library that also offers an executable.
|
|
|
|
//! The intended usage is the solving of tasks for cryptology and maybe math, in the context of a
|
2023-05-08 01:30:28 +02:00
|
|
|
//! # various tools for use in cryptology contexts
|
2023-05-08 01:20:28 +02:00
|
|
|
//! university degree. I wrote this for cryptology at DHBW Mannheim.
|
|
|
|
//!
|
2023-05-08 01:30:28 +02:00
|
|
|
//! ## main function
|
|
|
|
//! This project contains an executable, see [main.rs](main.rs)
|
|
|
|
//!
|
|
|
|
//! ## lib module
|
|
|
|
//! This project contains is a library, see [lib.rs](lib.rs).
|
|
|
|
//! Note that this library offers Python bindings using [PyO3](pyo3.rs)
|
2023-05-08 01:20:28 +02:00
|
|
|
//! ___
|
|
|
|
//! Author: Christoph J. Scherr <software@cscherr.de>
|
|
|
|
//!
|
|
|
|
//! License: MIT
|
|
|
|
//!
|
|
|
|
//! Source: <https://git.cscherr.de/PlexSheep/plexcryptool/>
|
2023-04-25 18:09:04 +02:00
|
|
|
use pyo3::prelude::*;
|
|
|
|
|
|
|
|
mod binary;
|
2023-05-08 01:20:28 +02:00
|
|
|
mod math;
|
2023-04-25 18:09:04 +02:00
|
|
|
|
|
|
|
#[pymodule]
|
|
|
|
fn register_binary_module(py: Python, parent_module: &PyModule) -> PyResult<()> {
|
|
|
|
let binary_module = PyModule::new(py, "binary")?;
|
|
|
|
binary_module.add_function(wrap_pyfunction!(binary::rotl32, binary_module)?)?;
|
|
|
|
binary_module.add_function(wrap_pyfunction!(binary::rotr32, binary_module)?)?;
|
2023-05-10 13:03:01 +02:00
|
|
|
binary_module.add_function(wrap_pyfunction!(binary::xor, binary_module)?)?;
|
2023-04-25 18:09:04 +02:00
|
|
|
parent_module.add_submodule(binary_module)?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-05-02 15:17:17 +02:00
|
|
|
#[pymodule]
|
|
|
|
fn register_math_module(py: Python, parent_module: &PyModule) -> PyResult<()> {
|
|
|
|
let math_module = PyModule::new(py, "math")?;
|
2023-05-08 01:20:28 +02:00
|
|
|
math_module.add_function(wrap_pyfunction!(math::modexp::py_modular_exponentiation, math_module)?)?;
|
2023-05-02 15:17:17 +02:00
|
|
|
parent_module.add_submodule(math_module)?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2023-04-25 18:09:04 +02:00
|
|
|
/// A Python module implemented in Rust.
|
|
|
|
#[pymodule]
|
|
|
|
fn plexcryptool(py: Python, m: &PyModule) -> PyResult<()> {
|
|
|
|
register_binary_module(py, m)?;
|
2023-05-02 15:17:17 +02:00
|
|
|
register_math_module(py, m)?;
|
2023-04-25 18:09:04 +02:00
|
|
|
Ok(())
|
|
|
|
}
|