#[non_exhaustive]pub struct AlgorithmParams {
pub cipher: Option<CipherAlgorithm>,
pub hash: Option<HashAlgorithm>,
pub key_bits: Option<u32>,
pub block_size: Option<u32>,
pub salt_size: Option<u32>,
pub spin_count: Option<u32>,
}Expand description
One parameter set, as the file declares it.
Every field is Option because every one of them is optional in at least one of the
two formats: agile writes all six on <p:encryptedKey> and five on <keyData>
(no spinCount), while standard encryption declares a cipher, a hash, a key length
and a salt size, and fixes the remaining two by spec — AES-ECB has no blockSize, and
[MS-OFFCRYPTO] §2.3.4.7 fixes the spin count at 50 000 rather than carrying it in the
file.
The numbers are reported unbounded and unvalidated — spin_count may be
u32::MAX, key_bits may be 7. Bounding them is decrypt’s job
(crate::limits); a classifier that refused to report a hostile value would leave
its caller unable to see what it was refusing.
§Examples
use msoffice_crypto::classify;
let class = classify(include_bytes!("../tests/fixtures/agile_encrypted.docx"));
let password = class.password_key.expect("agile files declare a password encryptor");
assert_eq!(password.spin_count, Some(100_000));
assert_eq!(password.key_bits, Some(256));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cipher: Option<CipherAlgorithm>cipherAlgorithm, or standard encryption’s AlgID + fAES.
hash: Option<HashAlgorithm>hashAlgorithm, or standard encryption’s AlgIDHash.
key_bits: Option<u32>keyBits, or standard encryption’s EncryptionHeader.KeySize.
block_size: Option<u32>blockSize — the cipher block / IV truncation length. Agile only: standard
encryption is AES-ECB and declares no block size field.
salt_size: Option<u32>saltSize, or standard encryption’s EncryptionVerifier.SaltSize.
spin_count: Option<u32>spinCount — the password KDF iteration count. Agile <p:encryptedKey> only:
<keyData> has no such attribute, and standard encryption fixes it at 50 000 by
spec rather than declaring it.