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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::{Int32, KerberosString};
use red_asn1::{Asn1Object, OctetString};
use red_asn1_derive::Sequence;
#[derive(Sequence, Debug, Clone, PartialEq, Default)]
pub struct EtypeInfo2Entry {
#[seq_field(context_tag = 0)]
pub etype: Int32,
#[seq_field(context_tag = 1)]
pub salt: Option<KerberosString>,
#[seq_field(context_tag = 2)]
pub s2kparams: Option<OctetString>,
}
impl EtypeInfo2Entry {
pub fn new(etype: Int32, salt: Option<KerberosString>, s2kparams: Option<OctetString>) -> Self {
return Self {
etype,
salt,
s2kparams,
};
}
}
#[cfg(test)]
mod test {
use super::*;
use kerberos_constants::etypes::*;
#[test]
fn test_parse_etypeinfo2entry() {
let mut entry = EtypeInfo2Entry::default();
entry.etype = AES256_CTS_HMAC_SHA1_96;
entry.salt = Some(KerberosString::from("KINGDOM.HEARTSmickey"));
assert_eq!(
entry,
EtypeInfo2Entry::parse(&[
0x30, 0x1d, 0xa0, 0x03, 0x02, 0x01, 0x12, 0xa1, 0x16, 0x1b, 0x14, 0x4b, 0x49, 0x4e,
0x47, 0x44, 0x4f, 0x4d, 0x2e, 0x48, 0x45, 0x41, 0x52, 0x54, 0x53, 0x6d, 0x69, 0x63,
0x6b, 0x65, 0x79,
])
.unwrap()
.1
);
}
#[test]
fn test_build_etypeinfo2entry() {
let mut entry = EtypeInfo2Entry::default();
entry.etype = AES256_CTS_HMAC_SHA1_96;
entry.salt = Some(KerberosString::from("KINGDOM.HEARTSmickey"));
assert_eq!(
vec![
0x30, 0x1d, 0xa0, 0x03, 0x02, 0x01, 0x12, 0xa1, 0x16, 0x1b, 0x14, 0x4b, 0x49, 0x4e,
0x47, 0x44, 0x4f, 0x4d, 0x2e, 0x48, 0x45, 0x41, 0x52, 0x54, 0x53, 0x6d, 0x69, 0x63,
0x6b, 0x65, 0x79,
],
entry.build()
);
}
}