MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / testAes

Method testAes

plugins/CryptMessage/Test/TestCrypt.py:93–117  ·  view source on GitHub ↗
(self, ui_websocket)

Source from the content-addressed store, hash-verified

91 assert ui_websocket.ws.getResult() == "hello"
92
93 def testAes(self, ui_websocket):
94 ui_websocket.actionAesEncrypt(0, "hello")
95 key, iv, encrypted = ui_websocket.ws.getResult()
96
97 assert len(key) == 44
98 assert len(iv) == 24
99 assert len(encrypted) == 24
100
101 # Single decrypt
102 ui_websocket.actionAesDecrypt(0, iv, encrypted, key)
103 assert ui_websocket.ws.getResult() == "hello"
104
105 # Batch decrypt
106 ui_websocket.actionAesEncrypt(0, "hello")
107 key2, iv2, encrypted2 = ui_websocket.ws.getResult()
108
109 assert [key, iv, encrypted] != [key2, iv2, encrypted2]
110
111 # 2 correct key
112 ui_websocket.actionAesDecrypt(0, [[iv, encrypted], [iv, encrypted], [iv, "baad"], [iv2, encrypted2]], [key])
113 assert ui_websocket.ws.getResult() == ["hello", "hello", None, None]
114
115 # 3 key
116 ui_websocket.actionAesDecrypt(0, [[iv, encrypted], [iv, encrypted], [iv, "baad"], [iv2, encrypted2]], [key, key2])
117 assert ui_websocket.ws.getResult() == ["hello", "hello", None, "hello"]
118
119 def testAesUtf8(self, ui_websocket):
120 ui_websocket.actionAesEncrypt(0, self.utf8_text)

Callers

nothing calls this directly

Calls 3

actionAesEncryptMethod · 0.80
getResultMethod · 0.80
actionAesDecryptMethod · 0.80

Tested by

no test coverage detected