1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #![no_std]
19 
20 pub enum Command {
21     Prepare,
22     SetKey,
23     SetIV,
24     Cipher,
25     Unknown,
26 }
27 
28 impl From<u32> for Command {
29     #[inline]
from(value: u32) -> Command30     fn from(value: u32) -> Command {
31         match value {
32             0 => Command::Prepare,
33             1 => Command::SetKey,
34             2 => Command::SetIV,
35             3 => Command::Cipher,
36             _ => Command::Unknown,
37         }
38     }
39 }
40 
41 pub enum Algo {
42     ECB,
43     CBC,
44     CTR,
45     Unknown,
46 }
47 
48 impl From<u32> for Algo {
49     #[inline]
from(value: u32) -> Algo50     fn from(value: u32) -> Algo {
51         match value {
52             0 => Algo::ECB,
53             1 => Algo::CBC,
54             2 => Algo::CTR,
55             _ => Algo::Unknown,
56         }
57     }
58 }
59 
60 pub enum Mode {
61     Decode,
62     Encode,
63     Unknown,
64 }
65 
66 impl From<u32> for Mode {
67     #[inline]
from(value: u32) -> Mode68     fn from(value: u32) -> Mode {
69         match value {
70             0 => Mode::Decode,
71             1 => Mode::Encode,
72             _ => Mode::Unknown,
73         }
74     }
75 }
76 
77 pub enum KeySize {
78     Bit128 = 16,
79     Bit256 = 32,
80     Unknown = 0,
81 }
82 
83 impl From<u32> for KeySize {
84     #[inline]
from(value: u32) -> KeySize85     fn from(value: u32) -> KeySize {
86         match value {
87             16 => KeySize::Bit128,
88             32 => KeySize::Bit256,
89             _ => KeySize::Unknown,
90         }
91     }
92 }
93 
94 pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt"));
95