Line data Source code
1 : pub mod binary;
2 : pub mod data_directory;
3 : pub mod debug;
4 : pub mod delay_import;
5 : pub mod export;
6 : pub mod headers;
7 : pub mod import;
8 : pub mod load_configuration;
9 : pub mod relocation;
10 : pub mod resources;
11 : pub mod rich_header;
12 : pub mod section;
13 : pub mod signature;
14 : pub mod tls;
15 : pub mod code_integrity;
16 :
17 : #[doc(inline)]
18 : pub use binary::Binary;
19 : #[doc(inline)]
20 : pub use data_directory::DataDirectory;
21 : #[doc(inline)]
22 : pub use delay_import::DelayImport;
23 : #[doc(inline)]
24 : pub use export::Export;
25 : #[doc(inline)]
26 : pub use headers::{DosHeader, Header, OptionalHeader};
27 : #[doc(inline)]
28 : pub use relocation::Relocation;
29 : #[doc(inline)]
30 : pub use resources::Manager as ResourcesManager;
31 : #[doc(inline)]
32 : pub use resources::Node as ResourceNode;
33 : #[doc(inline)]
34 : pub use rich_header::{RichEntry, RichHeader};
35 : #[doc(inline)]
36 : pub use section::Section;
37 : #[doc(inline)]
38 : pub use tls::TLS;
39 : #[doc(inline)]
40 : pub use import::Import;
41 : #[doc(inline)]
42 : pub use signature::Signature;
43 :
44 : #[allow(non_camel_case_types)]
45 512 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
46 : pub enum Algorithms {
47 : SHA_512,
48 : SHA_384,
49 : SHA_256,
50 : SHA_1,
51 : MD5,
52 : MD4,
53 : MD2,
54 : RSA,
55 : EC,
56 : MD5_RSA,
57 : SHA1_DSA,
58 : SHA1_RSA,
59 : SHA_256_RSA,
60 : SHA_384_RSA,
61 : SHA_512_RSA,
62 : SHA1_ECDSA,
63 : SHA_256_ECDSA,
64 : SHA_384_ECDSA,
65 : SHA_512_ECDSA,
66 : UNKNOWN(u32),
67 : }
68 :
69 :
70 : impl From<u32> for Algorithms {
71 512 : fn from(value: u32) -> Self {
72 512 : match value {
73 0 : 0x00000001 => Algorithms::SHA_512,
74 0 : 0x00000002 => Algorithms::SHA_384,
75 208 : 0x00000003 => Algorithms::SHA_256,
76 128 : 0x00000004 => Algorithms::SHA_1,
77 24 : 0x00000005 => Algorithms::MD5,
78 0 : 0x00000006 => Algorithms::MD4,
79 0 : 0x00000007 => Algorithms::MD2,
80 136 : 0x00000008 => Algorithms::RSA,
81 0 : 0x00000009 => Algorithms::EC,
82 0 : 0x0000000a => Algorithms::MD5_RSA,
83 0 : 0x0000000b => Algorithms::SHA1_DSA,
84 0 : 0x0000000c => Algorithms::SHA1_RSA,
85 16 : 0x0000000d => Algorithms::SHA_256_RSA,
86 0 : 0x0000000e => Algorithms::SHA_384_RSA,
87 0 : 0x0000000f => Algorithms::SHA_512_RSA,
88 0 : 0x00000010 => Algorithms::SHA1_ECDSA,
89 0 : 0x00000011 => Algorithms::SHA_256_ECDSA,
90 0 : 0x00000012 => Algorithms::SHA_384_ECDSA,
91 0 : 0x00000013 => Algorithms::SHA_512_ECDSA,
92 0 : _ => Algorithms::UNKNOWN(value),
93 :
94 : }
95 512 : }
96 : }
97 :
98 : impl From<Algorithms> for u32 {
99 64 : fn from(value: Algorithms) -> u32 {
100 64 : match value {
101 0 : Algorithms::SHA_512 => 0x00000001,
102 0 : Algorithms::SHA_384 => 0x00000002,
103 64 : Algorithms::SHA_256 => 0x00000003,
104 0 : Algorithms::SHA_1 => 0x00000004,
105 0 : Algorithms::MD5 => 0x00000005,
106 0 : Algorithms::MD4 => 0x00000006,
107 0 : Algorithms::MD2 => 0x00000007,
108 0 : Algorithms::RSA => 0x00000008,
109 0 : Algorithms::EC => 0x00000009,
110 0 : Algorithms::MD5_RSA => 0x0000000a,
111 0 : Algorithms::SHA1_DSA => 0x0000000b,
112 0 : Algorithms::SHA1_RSA => 0x0000000c,
113 0 : Algorithms::SHA_256_RSA => 0x0000000d,
114 0 : Algorithms::SHA_384_RSA => 0x0000000e,
115 0 : Algorithms::SHA_512_RSA => 0x0000000f,
116 0 : Algorithms::SHA1_ECDSA => 0x00000010,
117 0 : Algorithms::SHA_256_ECDSA => 0x00000011,
118 0 : Algorithms::SHA_384_ECDSA => 0x00000012,
119 0 : Algorithms::SHA_512_ECDSA => 0x00000013,
120 0 : Algorithms::UNKNOWN(_) => 0,
121 :
122 : }
123 64 : }
124 : }
|