domain/base/iana/
digestalg.rs

1//! Delegation signer digest algorithm numbers.
2
3//------------ DigestAlg -----------------------------------------------------
4
5int_enum! {
6    /// Delegation signer digest algorithm numbers.
7    ///
8    /// These numbers are used in the DS resource record to specify how the
9    /// key digest in the record has been generated.
10    ///
11    /// For the currently registered values see the [IANA registration].
12    /// This type is complete as of the registry update of 2012-04-13.
13    ///
14    /// [IANA registration]: https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml#ds-rr-types-1
15    =>
16    DigestAlg, u8;
17
18    /// Specifies that the SHA-1 hash function is used.
19    ///
20    /// Implementation of this function is currently mandatory.
21    (Sha1 => 1, b"SHA-1")
22
23    /// Specifies that the SHA-256 hash function is used.
24    ///
25    /// Implementation of this function is currently mandatory.
26    (Sha256 => 2, b"SHA-256")
27
28    /// Specifies that the GOST R 34.11-94 hash function is used.
29    ///
30    /// Use of this hash function is described in [RFC 5933]. Implementing
31    /// the function is optional.
32    ///
33    /// [RFC 5933]: https://tools.ietf.org/html/rfc5933
34    (Gost => 3, b"GOST R 34.11-94")
35
36    /// Specifies that the SHA-384 hash function is used.
37    ///
38    /// Use of this hash function is described in [RFC 6605]. Implementing
39    /// the function is optional.
40    ///
41    /// [RFC 6605]: https://tools.ietf.org/html/rfc6605
42    (Sha384 => 4, b"SHA-384")
43}
44
45int_enum_str_decimal!(DigestAlg, u8);
46
47//============ Tests =========================================================
48
49#[cfg(test)]
50mod test {
51    #[cfg(feature = "serde")]
52    #[test]
53    fn ser_de() {
54        use super::DigestAlg;
55        use serde_test::{assert_tokens, Token};
56
57        assert_tokens(&DigestAlg::Sha384, &[Token::U8(4)]);
58        assert_tokens(&DigestAlg::Int(100), &[Token::U8(100)]);
59    }
60}