From af230f55dfbff8b623b67e763a2b3f7c21f79b89 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 10 Feb 2024 00:37:53 -0500 Subject: [PATCH] keyfork-shard: limit size of encrypted payload, can fit at max a 256 bit shard --- crates/keyfork-shard/src/lib.rs | 4 ++-- crates/keyfork-shard/src/openpgp.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/keyfork-shard/src/lib.rs b/crates/keyfork-shard/src/lib.rs index 496d00c..5129ad7 100644 --- a/crates/keyfork-shard/src/lib.rs +++ b/crates/keyfork-shard/src/lib.rs @@ -41,7 +41,7 @@ pub struct InvalidData; /// 1 byte: Version /// 1 byte: Threshold /// Data: &[u8] -pub(crate) const HUNK_VERSION: u8 = 1; +pub(crate) const HUNK_VERSION: u8 = 2; pub(crate) const HUNK_OFFSET: usize = 2; const QRCODE_PROMPT: &str = "Press enter, then present QR code to camera."; @@ -129,7 +129,7 @@ pub fn remote_decrypt(w: &mut impl Write) -> Result<(), Box (pubkey, payload), _ => { let validator = MnemonicSetValidator { - word_lengths: [24, 48], + word_lengths: [24, 39], }; let [pubkey_mnemonic, payload_mnemonic] = pm.prompt_validated_wordlist( diff --git a/crates/keyfork-shard/src/openpgp.rs b/crates/keyfork-shard/src/openpgp.rs index 520c246..3d06b47 100644 --- a/crates/keyfork-shard/src/openpgp.rs +++ b/crates/keyfork-shard/src/openpgp.rs @@ -62,7 +62,7 @@ use super::{ }; // 256 bit share is 49 bytes + some amount of hunk bytes, gives us reasonable padding -const ENC_LEN: u8 = 4 * 16; +const ENC_LEN: u8 = 52; /// Errors encountered while performing operations using OpenPGP. #[derive(Debug, thiserror::Error)]