Skip to content

Commit 6d39144

Browse files
author
Matthias Koeppe
committed
sage.crypto.block_cipher: Modularization fix
1 parent 614be8a commit 6d39144

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/sage/crypto/block_cipher/des.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
from sage.rings.integer_ring import ZZ
7979
from sage.modules.free_module_element import vector
8080
from sage.rings.finite_rings.finite_field_constructor import GF
81-
from sage.modules.vector_mod2_dense import Vector_mod2_dense
81+
from sage.structure.element import Vector
8282
from sage.rings.integer import Integer
8383
from sage.crypto.sboxes import DES_S1_1, DES_S1_2, DES_S1_3, DES_S1_4
8484
from sage.crypto.sboxes import DES_S2_1, DES_S2_2, DES_S2_3, DES_S2_4
@@ -512,7 +512,7 @@ def encrypt(self, plaintext, key):
512512
sage: des.encrypt(P, K56) == C
513513
True
514514
"""
515-
if isinstance(plaintext, (list, tuple, Vector_mod2_dense)):
515+
if isinstance(plaintext, (list, tuple, Vector)):
516516
inputType = 'vector'
517517
elif isinstance(plaintext, (Integer, int)):
518518
inputType = 'integer'
@@ -569,7 +569,7 @@ def decrypt(self, ciphertext, key):
569569
sage: des.decrypt(C, K56).hex() == P
570570
True
571571
"""
572-
if isinstance(ciphertext, (list, tuple, Vector_mod2_dense)):
572+
if isinstance(ciphertext, (list, tuple, Vector)):
573573
inputType = 'vector'
574574
elif isinstance(ciphertext, (Integer, int)):
575575
inputType = 'integer'
@@ -869,7 +869,7 @@ def __call__(self, key):
869869
pass a ``masterKey`` value on initialisation. Otherwise you can
870870
omit ``masterKey`` and pass a key when you call the object.
871871
"""
872-
if isinstance(key, (list, tuple, Vector_mod2_dense)):
872+
if isinstance(key, (list, tuple, Vector)):
873873
inputType = 'vector'
874874
elif isinstance(key, (Integer, int)):
875875
inputType = 'integer'

src/sage/crypto/block_cipher/present.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@
6262
from sage.structure.sage_object import SageObject
6363
from sage.rings.integer_ring import ZZ
6464
from sage.rings.integer import Integer
65-
from sage.misc.lazy_import import lazy_import
6665
from sage.modules.free_module_element import vector
6766
from sage.rings.finite_rings.finite_field_constructor import GF
67+
from sage.structure.element import Vector
6868
from sage.crypto.sboxes import PRESENT as PRESENTSBOX
6969

70-
lazy_import('sage.modules.vector_mod2_dense', 'Vector_mod2_dense')
71-
7270

7371
def _smallscale_present_linearlayer(nsboxes=16):
7472
"""
@@ -420,7 +418,7 @@ def encrypt(self, plaintext, key):
420418
\leq 32` and current STATE `b_{63} \dots b_0`, addRoundkey consists of
421419
the operation for `0 \leq j \leq 63`, `b_j = b_j \oplus \kappa^i_j`.
422420
"""
423-
if isinstance(plaintext, (list, tuple, Vector_mod2_dense)):
421+
if isinstance(plaintext, (list, tuple, Vector)):
424422
inputType = 'vector'
425423
elif isinstance(plaintext, (Integer, int)):
426424
inputType = 'integer'
@@ -476,7 +474,7 @@ def decrypt(self, ciphertext, key):
476474
sage: present.decrypt(c4, k4) == p4
477475
True
478476
"""
479-
if isinstance(ciphertext, (list, tuple, Vector_mod2_dense)):
477+
if isinstance(ciphertext, (list, tuple, Vector)):
480478
inputType = 'vector'
481479
elif isinstance(ciphertext, (Integer, int)):
482480
inputType = 'integer'
@@ -776,7 +774,7 @@ def __call__(self, K):
776774
pass a ``master_key`` value on initialisation. Otherwise you can
777775
omit ``master_key`` and pass a key when you call the object.
778776
"""
779-
if isinstance(K, (list, tuple, Vector_mod2_dense)):
777+
if isinstance(K, (list, tuple, Vector)):
780778
inputType = 'vector'
781779
elif isinstance(K, (Integer, int)):
782780
inputType = 'integer'

0 commit comments

Comments
 (0)