hemtt_signing/
lib.rs

1#![deny(clippy::all, clippy::nursery, missing_docs)]
2#![warn(clippy::pedantic)]
3
4//! HEMTT - Arma 3 Signing
5
6// Parts of the following code is derivative work of the code from the armake2 project by KoffeinFlummi,
7// which is licensed GPLv2. This code therefore is also licensed under the terms
8// of the GNU Public License, verison 2.
9
10// The original code can be found here:
11// https://github.com/KoffeinFlummi/armake2/blob/4b736afc8c615cf49a0d1adce8f6b9a8ae31d90f/src/sign.rs
12
13use std::io::Write;
14
15use rsa::BigUint;
16
17mod error;
18mod private;
19mod public;
20mod signature;
21
22pub use error::Error;
23pub use private::BIPrivateKey;
24pub use public::BIPublicKey;
25pub use signature::BISign;
26
27/// Writes a [`BigUint`] to the given output.
28///
29/// # Errors
30/// If the output fails to write.
31pub fn write_biguint<O: Write>(output: &mut O, bn: &BigUint, size: usize) -> Result<(), Error> {
32    let mut vec: Vec<u8> = bn.to_bytes_le();
33    vec.resize(size, 0);
34    output.write_all(&vec).map_err(std::convert::Into::into)
35}