Compare commits

..

No commits in common. "6f6f3dc8d3e3cdfa42af1165e0bce3baaf7495ff" and "b084107e9dbedfc6f5011c2bfed312440998d9dd" have entirely different histories.

2 changed files with 8 additions and 4 deletions

View file

@ -37,7 +37,6 @@ _default:
git init .
git checkout -B gh-pages
touch .nojekyll
echo "lprs.4rs.nl" > CNAME
git add .
git commit -m "Deploy the book to github pages"

View file

@ -19,7 +19,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
use base32::Alphabet as Base32Alphabet;
use clap::ValueEnum;
use rand::{thread_rng, RngCore};
use rand::{rngs::StdRng, Rng, SeedableRng};
use serde::{Deserialize, Serialize};
use crate::{LprsError, LprsResult};
@ -78,8 +78,13 @@ pub fn totp_now(secret_base32: &str, hash_function: &TotpHash) -> LprsResult<(St
///
/// Note: The IV will be add it to the end of the ciphertext (Last 16 bytes)
pub(crate) fn encrypt(master_password: &[u8; 32], data: &[u8]) -> Vec<u8> {
let mut iv = [0u8; 16];
thread_rng().fill_bytes(&mut iv);
let iv: [u8; 16] = StdRng::seed_from_u64(
SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("SystemTime before UNIX EPOCH!")
.as_secs(),
)
.gen();
let mut ciphertext =
Aes256CbcEnc::new(master_password.into(), &iv.into()).encrypt_padded_vec_mut::<Pkcs7>(data);