Added a regression test for strings generated by the old protect_string() implementation
This commit is contained in:
Submodule npa/src/opensc updated: 622b71970f...db60f8da59
@@ -25,6 +25,12 @@ class TestCryptoUtils(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.teststring = "DEADBEEFistatsyksdvhwohfwoehcowc8hw8rogfq8whv75tsgohsav8wress"
|
||||
self.testpass = "SomeRandomPassphrase"
|
||||
# The following string was generated using the proteced string method and
|
||||
# is used as regression test.
|
||||
# The data generated by protect_string should actually consist of
|
||||
# printable characters only but that would break backwards
|
||||
# compatibility with the (buggy) legacy implementation
|
||||
self.protectedTestString = "2470356b322424504f63775949487224ffa330e33b2d76b82e91a4c88ff722414d3522bcbdb8a4a45cd7c61963b52825e1361354d5b5efbcfeabfb66fa3f97dfecd5e57617b8e0172017785f4001e9653366363763323639363965313261386363623738326435326639653563633339".decode('hex')
|
||||
|
||||
def test_padding(self):
|
||||
padded = append_padding(16, self.teststring)
|
||||
@@ -36,6 +42,9 @@ class TestCryptoUtils(unittest.TestCase):
|
||||
unprotectedString = read_protected_string(protectedString, self.testpass)
|
||||
self.assertEqual(self.teststring, unprotectedString)
|
||||
|
||||
def test_unprotect_string(self):
|
||||
unprotectedString = read_protected_string(self.protectedTestString, self.testpass)
|
||||
self.assertEqual(unprotectedString, self.teststring)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user