Skip to content

Commit 82cb8cb

Browse files
author
Daniel Zagaynov
committed
tests: turn on tests for sm3_yescrypt
1 parent 9a0c11e commit 82cb8cb

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

tests/test_checksalt.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ def test_sunmd5crypt(self):
127127
def test_sm3crypt(self):
128128
self._test_checksalt("$sm3$")
129129

130+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
131+
"sm3_yescrypt is not supported by the current libcrypt build")
132+
def test_sm3_yescrypt(self):
133+
self._test_checksalt("$sm3y$")
134+
130135
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
131136
"sha1crypt is not supported by the current libcrypt build")
132137
def test_sha1crypt(self):
@@ -214,6 +219,11 @@ def test_sunmd5crypt(self):
214219
def test_sm3crypt(self):
215220
self._test_checksalt("$sm3$", pyxcrypt.crypt_checksalt, pyxcrypt.crypt_gensalt, pyxcrypt.crypt)
216221

222+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
223+
"sm3_yescrypt is not supported by the current libcrypt build")
224+
def test_sm3_yescrypt(self):
225+
self._test_checksalt("$sm3y$", pyxcrypt.crypt_checksalt, pyxcrypt.crypt_gensalt, pyxcrypt.crypt)
226+
217227
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
218228
"sha1crypt is not supported by the current libcrypt build")
219229
def test_sha1crypt(self):

tests/test_crypt.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ def test_sunmd5crypt(self):
7878
def test_sm3crypt(self):
7979
self._test_crypt("$sm3$")
8080

81+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
82+
"sm3_yescrypt is not supported by the current libcrypt build")
83+
def test_sm3_yescrypt(self):
84+
self._test_crypt("$sm3y$")
85+
8186
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
8287
"sha1crypt is not supported by the current libcrypt build")
8388
def test_sha1crypt(self):
@@ -163,6 +168,11 @@ def test_sunmd5crypt(self):
163168
def test_sm3crypt(self):
164169
self._test_crypt("$sm3$", pyxcrypt.crypt)
165170

171+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
172+
"sm3_yescrypt is not supported by the current libcrypt build")
173+
def test_sm3_yescrypt(self):
174+
self._test_crypt("$sm3y$", pyxcrypt.crypt)
175+
166176
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
167177
"sha1crypt is not supported by the current libcrypt build")
168178
def test_sha1crypt(self):

tests/test_gensalt.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Test_GenSalt(unittest.TestCase):
7979
"$md5,rounds=4294911250$3HtkHq/x$",
8080
"$md5,rounds=4294942764$p.5e9AQf$"]
8181
}
82-
# Rounds and expected output for sunmd5
82+
# Rounds and expected output for sm3crypt
8383
sm3_rounds_expected = {0: ["$sm3$MJHnaAkegEVYHsFK",
8484
"$sm3$PKXc3hCOSyMqdaEQ",
8585
"$sm3$ZAFlICwYRETzIzIj",
@@ -97,6 +97,23 @@ class Test_GenSalt(unittest.TestCase):
9797
"$sm3$rounds=999999999$ZAFlICwYRETzIzIj",
9898
"$sm3$rounds=999999999$UqGBkVu01rurVZqg"]
9999
}
100+
# Rounds and expected output for sm3_yescrypt
101+
sm3_yescrypt_rounds_expected = {0: [
102+
"$sm3y$j9T$MJHnaAkegEVYHsFKkmfzJ1",
103+
"$sm3y$j9T$PKXc3hCOSyMqdaEQArI62/",
104+
"$sm3y$j9T$ZAFlICwYRETzIzIjEIC86.",
105+
"$sm3y$j9T$UqGBkVu01rurVZqgNchTB0"],
106+
1: [
107+
"$sm3y$j75$MJHnaAkegEVYHsFKkmfzJ1",
108+
"$sm3y$j75$PKXc3hCOSyMqdaEQArI62/",
109+
"$sm3y$j75$ZAFlICwYRETzIzIjEIC86.",
110+
"$sm3y$j75$UqGBkVu01rurVZqgNchTB0"],
111+
11: [
112+
"$sm3y$jFT$MJHnaAkegEVYHsFKkmfzJ1",
113+
"$sm3y$jFT$PKXc3hCOSyMqdaEQArI62/",
114+
"$sm3y$jFT$ZAFlICwYRETzIzIjEIC86.",
115+
"$sm3y$jFT$UqGBkVu01rurVZqgNchTB0"]
116+
}
100117
# Rounds and expected output for sha1crypt
101118
sha1_rounds_expected = {0: ["$sha1$248488$ggu.H673kaZ5$",
102119
"$sha1$248421$SWqudaxXA5L0$",
@@ -271,6 +288,11 @@ def test_sunmd5crypt(self):
271288
def test_sm3crypt(self):
272289
self._test_prefix(self.sm3_rounds_expected, "$sm3$")
273290

291+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
292+
"sm3_yescrypt is not supported by the current libcrypt build")
293+
def test_sm3_yescrypt(self):
294+
self._test_prefix(self.sm3_yescrypt_rounds_expected, "$sm3y$")
295+
274296
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
275297
"sha1crypt is not supported by the current libcrypt build")
276298
def test_sha1crypt(self):
@@ -349,6 +371,11 @@ def test_sunmd5crypt(self):
349371
def test_sm3crypt(self):
350372
self._test_prefix(self.sm3_rounds_expected, "sm3crypt", pyxcrypt.crypt_gensalt)
351373

374+
@unittest.skipIf("sm3_yescrypt" not in pyxcrypt.get_provided_prefixes(),
375+
"sm3_yescrypt is not supported by the current libcrypt build")
376+
def test_sm3_yescrypt(self):
377+
self._test_prefix(self.sm3_yescrypt_rounds_expected, "sm3_yescrypt", pyxcrypt.crypt_gensalt)
378+
352379
@unittest.skipIf("sha1crypt" not in pyxcrypt.get_provided_prefixes(),
353380
"sha1crypt is not supported by the current libcrypt build")
354381
def test_sha1crypt(self):

0 commit comments

Comments
 (0)