domain/base/iana/digestalg.rs
1//! Delegation signer digest algorithm numbers.
2
3//------------ DigestAlgorithm -----------------------------------------------
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 DigestAlgorithm, u8;
17
18 /// Specifies that the SHA-1 hash function is used.
19 ///
20 /// Implementation of this function is currently mandatory.
21 (SHA1 => 1, "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, "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, "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, "SHA-384")
43}
44
45int_enum_str_decimal!(DigestAlgorithm, u8);
46int_enum_zonefile_fmt_decimal!(DigestAlgorithm, "digest type");
47
48//============ Tests =========================================================
49
50#[cfg(test)]
51mod test {
52 #[cfg(feature = "serde")]
53 #[test]
54 fn ser_de() {
55 use super::DigestAlgorithm;
56 use serde_test::{assert_tokens, Token};
57
58 assert_tokens(&DigestAlgorithm::SHA384, &[Token::U8(4)]);
59 assert_tokens(&DigestAlgorithm(100), &[Token::U8(100)]);
60 }
61}