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 pub enum Command { 19 Prepare, 20 SetKey, 21 SetIV, 22 Cipher, 23 Unknown, 24 } 25 26 impl From<u32> for Command { 27 #[inline] from(value: u32) -> Command28 fn from(value: u32) -> Command { 29 match value { 30 0 => Command::Prepare, 31 1 => Command::SetKey, 32 2 => Command::SetIV, 33 3 => Command::Cipher, 34 _ => Command::Unknown, 35 } 36 } 37 } 38 39 pub enum Algo { 40 ECB, 41 CBC, 42 CTR, 43 Unknown, 44 } 45 46 impl From<u32> for Algo { 47 #[inline] from(value: u32) -> Algo48 fn from(value: u32) -> Algo { 49 match value { 50 0 => Algo::ECB, 51 1 => Algo::CBC, 52 2 => Algo::CTR, 53 _ => Algo::Unknown, 54 } 55 } 56 } 57 58 pub enum Mode { 59 Decode, 60 Encode, 61 Unknown, 62 } 63 64 impl From<u32> for Mode { 65 #[inline] from(value: u32) -> Mode66 fn from(value: u32) -> Mode { 67 match value { 68 0 => Mode::Decode, 69 1 => Mode::Encode, 70 _ => Mode::Unknown, 71 } 72 } 73 } 74 75 pub enum KeySize { 76 Bit128 = 16, 77 Bit256 = 32, 78 Unknown = 0, 79 } 80 81 impl From<u32> for KeySize { 82 #[inline] from(value: u32) -> KeySize83 fn from(value: u32) -> KeySize { 84 match value { 85 16 => KeySize::Bit128, 86 32 => KeySize::Bit256, 87 _ => KeySize::Unknown, 88 } 89 } 90 } 91 92 pub const UUID: &str = &include_str!(concat!(env!("OUT_DIR"), "/uuid.txt")); 93