提交 efe3cfe7 编写于 作者: M Megvii Engine Team

fix(lite): fix the encrypt key in lite

GitOrigin-RevId: 6021d3c89cd4ea0c43473c35006849fee604b2e3
上级 d4a080e1
...@@ -71,25 +71,3 @@ class TestGlobal(TestShuffleNet): ...@@ -71,25 +71,3 @@ class TestGlobal(TestShuffleNet):
network.load(model_path) network.load(model_path)
self.do_forward(network) self.do_forward(network)
def test_update_decryption_key(self):
wrong_key = [0] * 32
LiteGlobal.update_decryption_key("AES_default", wrong_key)
with self.assertRaises(RuntimeError):
config = LiteConfig()
config.bare_model_cryption_name = "AES_default".encode("utf-8")
network = LiteNetwork(config)
model_path = os.path.join(self.source_dir, "shufflenet_crypt_aes.mge")
network.load(model_path)
right_key = [i for i in range(32)]
LiteGlobal.update_decryption_key("AES_default", right_key)
config = LiteConfig()
config.bare_model_cryption_name = "AES_default".encode("utf-8")
network = LiteNetwork(config)
model_path = os.path.join(self.source_dir, "shufflenet_crypt_aes.mge")
network.load(model_path)
self.do_forward(network)
...@@ -41,10 +41,10 @@ public: ...@@ -41,10 +41,10 @@ public:
} }
static std::vector<uint8_t> get_decrypt_key() { static std::vector<uint8_t> get_decrypt_key() {
std::vector<uint8_t> key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, std::vector<uint8_t> key(32);
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}; 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
return key; return key;
} }
}; };
......
...@@ -11,6 +11,7 @@ fi ...@@ -11,6 +11,7 @@ fi
IV=`openssl rand -hex 16` IV=`openssl rand -hex 16`
Key=000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F Key=000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F
if [ $# == 3 ] ; then if [ $# == 3 ] ; then
Key=$3 Key=$3
fi fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册