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
use crate::crypto::pin::PinFormat;
use crate::crypto::mac::{MacAlgo, PaddingType};
pub struct Config {
pin_format: Option<PinFormat>,
pin_key: Option<String>,
mac_algo: Option<MacAlgo>,
mac_padding: Option<PaddingType>,
mac_key: Option<String>,
}
impl Config {
pub fn new() -> Config {
Config {
pin_format: None,
pin_key: None,
mac_algo: None,
mac_key: None,
mac_padding: None,
}
}
pub fn get_pin_fmt(&self) -> &Option<PinFormat> {
&self.pin_format
}
pub fn get_pin_key(&self) -> &Option<String> {
&self.pin_key
}
pub fn get_mac_key(&self) -> &Option<String> {
&self.mac_key
}
pub fn get_mac_algo(&self) -> &Option<MacAlgo> {
&self.mac_algo
}
pub fn get_mac_padding(&self) -> &Option<PaddingType> {
&self.mac_padding
}
pub fn with_pin(&mut self, fmt: PinFormat, key: String) -> &mut Config {
self.pin_format = Some(fmt);
self.pin_key = Some(key);
self
}
pub fn with_mac(&mut self, algo: MacAlgo, mac_padding: PaddingType, key: String) -> &mut Config {
self.mac_algo = Some(algo);
self.mac_key = Some(key);
self.mac_padding = Some(mac_padding);
self
}
}