1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//! MacData-related types

use crate::digest_info::DigestInfo;
use der::{asn1::OctetString, Sequence, ValueOrd};

/// The `MacData` type is defined in [RFC 7292 Section 4].
///
/// ```text
/// MacData ::= SEQUENCE {
///     mac         DigestInfo,
///     macSalt     OCTET STRING,
///     iterations  INTEGER DEFAULT 1
///     -- Note: The default is for historical reasons and its
///     --       use is deprecated.
///}
/// ```
///
/// [RFC 7292 Section 4]: https://www.rfc-editor.org/rfc/rfc7292#section-4
#[derive(Clone, Debug, Eq, PartialEq, Sequence, ValueOrd)]
pub struct MacData {
    /// the MAC digest info
    pub mac: DigestInfo,

    /// the MAC salt
    pub mac_salt: OctetString,

    /// the number of iterations
    #[asn1(default = "default_one")]
    pub iterations: i32,
}

fn default_one() -> i32 {
    1
}