sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.4k stars 474 forks source link

On the new cracking function of hill cryptography in classical cryptography #34250

Open 780f3e8f-2784-497d-9bdd-5606d752ca47 opened 2 years ago

780f3e8f-2784-497d-9bdd-5606d752ca47 commented 2 years ago

Hill encryption can be quickly cracked by known plaintext attacks. MK = C --> K = M-1 C.

However, this kind of algorithm is missing in sage.crypto.classic.hillcryptosystem, although other classical algorithms are accompanied by cracking methods. https://crypto.stackexchange.com/questions/66933/an-unbreakable-hill-cipher/66938#66938

def KPA(self, M, C): return self.inverse_key(M) * C

Component: cryptography

Keywords: HillCryptosystem

Author: WU XIANGFAN

Issue created by migration from https://trac.sagemath.org/ticket/34250

DaveWitteMorris commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,10 +1,10 @@
 Hill encryption can be quickly cracked by known plaintext attacks.
- MK=C  -->K=M^{-1}C.
+ MK = C --> K = M<sup>-1</sup> C.

 However, this kind of algorithm is missing in sage.crypto.classic.hillcryptosystem, although other classical algorithms are accompanied by cracking methods.
 https://crypto.stackexchange.com/questions/66933/an-unbreakable-hill-cipher/66938#66938

-def KPA(self,M,C):
-   return self.inverse_key(M)*C
+def KPA(self, M, C):
+   return self.inverse_key(M) * C
DaveWitteMorris commented 2 years ago
comment:1

It would be good to add such a method, but it is not just inverting a matrix. The Hill Cryptosystem is a private-key method, so the encryption matrix M would not be an input to this method. The input might be a plaintext message and the corresponding ciphertext, where the plaintext is long enough for the inverse to be calculated by linear algebra.