More test suite improvement. Add experimental KDF DO tests.
This commit is contained in:
21
tests/constants_for_test.py
Normal file
21
tests/constants_for_test.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
PW1_TEST0=b"another user pass phrase"
|
||||||
|
PW1_TEST1=b"PASSPHRASE SHOULD BE LONG"
|
||||||
|
PW1_TEST2=b"new user pass phrase"
|
||||||
|
PW1_TEST3=b"next user pass phrase"
|
||||||
|
PW1_TEST4=b"another user pass phrase"
|
||||||
|
PW3_TEST0=b"admin pass phrase"
|
||||||
|
PW3_TEST1=b"another admin pass phrase"
|
||||||
|
|
||||||
|
RESETCODE_TEST=b"example reset code 000"
|
||||||
|
|
||||||
|
PLAIN_TEXT0=b"This is a test message."
|
||||||
|
PLAIN_TEXT1=b"RSA decryption is as easy as pie."
|
||||||
|
PLAIN_TEXT2=b"This is another test message.\nMultiple lines.\n"
|
||||||
|
|
||||||
|
KDF_FULL=b"\x81\x01\x03\x82\x01\x08\x83\x04\x00\xC8\x00\x00\x84\x08\xC5\x1F\xB7\xF9\xEE\xF3\xD3\xE8\x85\x08\x75\x1A\x2A\x70\xC0\x7C\xB1\x81\x86\x08\xE6\xB2\x4E\x0C\xEE\x92\xAB\x93\x87\x20\xA2\x08\x89\x16\x09\xD3\xE4\x3D\x48\xAC\x5B\xAA\xBD\xE9\xF1\xB8\xD2\xFC\xD8\x3C\x5F\x35\xCB\xEB\xDA\xFB\x75\x92\x88\xC6\x8B\x2D\x88\x20\xF1\x34\x00\xD2\x5F\x28\x57\xE6\x66\xAA\x9E\xBB\xE0\x7C\x57\x4B\x84\x8B\xD6\x52\x14\xE7\x31\x99\x1A\x3D\x2D\xAA\x3F\x8A\x7F\x03"
|
||||||
|
KDF_FULL_HASH_PW1=b"\xA2\x08\x89\x16\x09\xD3\xE4\x3D\x48\xAC\x5B\xAA\xBD\xE9\xF1\xB8\xD2\xFC\xD8\x3C\x5F\x35\xCB\xEB\xDA\xFB\x75\x92\x88\xC6\x8B\x2D"
|
||||||
|
KDF_FULL_HASH_PW3=b"\xF1\x34\x00\xD2\x5F\x28\x57\xE6\x66\xAA\x9E\xBB\xE0\x7C\x57\x4B\x84\x8B\xD6\x52\x14\xE7\x31\x99\x1A\x3D\x2D\xAA\x3F\x8A\x7F\x03"
|
||||||
|
|
||||||
|
KDF_SINGLE=b"\x81\x01\x03\x82\x01\x08\x83\x04\x00\xC8\x00\x00\x84\x08\x69\x9E\xDA\xAD\x5A\x72\x5F\x4C\x87\x20\x12\xDB\x16\x9A\x9D\x1A\x56\xCA\x2B\x9E\x96\x7F\xC4\xDA\xB8\xAE\x70\x41\x51\x8E\x3C\xEF\x49\x7E\xC2\x56\x60\x32\x2F\x4C\x03\x07\x88\x20\x1C\x93\x99\xC3\x6D\x49\x92\x27\x54\x39\x76\x7E\xA7\xB4\xEE\xE5\x16\xDA\x92\xC0\x0E\xF4\x74\xBD\x01\x28\x0F\x0C\x30\x45\x4B\xBB"
|
||||||
|
KDF_SINGLE_HASH_PW1=b"\x12\xDB\x16\x9A\x9D\x1A\x56\xCA\x2B\x9E\x96\x7F\xC4\xDA\xB8\xAE\x70\x41\x51\x8E\x3C\xEF\x49\x7E\xC2\x56\x60\x32\x2F\x4C\x03\x07"
|
||||||
|
KDF_SINGLE_HASH_PW3=b"\x1C\x93\x99\xC3\x6D\x49\x92\x27\x54\x39\x76\x7E\xA7\xB4\xEE\xE5\x16\xDA\x92\xC0\x0E\xF4\x74\xBD\x01\x28\x0F\x0C\x30\x45\x4B\xBB"
|
||||||
@@ -25,16 +25,7 @@ from re import match, DOTALL
|
|||||||
from util import *
|
from util import *
|
||||||
import rsa_keys
|
import rsa_keys
|
||||||
from card_const import *
|
from card_const import *
|
||||||
|
from constants_for_test import *
|
||||||
PW1_TEST0=b"another user pass phrase"
|
|
||||||
PW1_TEST1=b"PASSPHRASE SHOULD BE LONG"
|
|
||||||
PW1_TEST2=b"new user pass phrase"
|
|
||||||
PW1_TEST3=b"next user pass phrase"
|
|
||||||
PW1_TEST4=b"another user pass phrase"
|
|
||||||
PW3_TEST0=b"admin pass phrase"
|
|
||||||
PW3_TEST1=b"another admin pass phrase"
|
|
||||||
|
|
||||||
RESETCODE_TEST=b"example reset code 000"
|
|
||||||
|
|
||||||
def test_setup_pw3_0(card):
|
def test_setup_pw3_0(card):
|
||||||
r = card.cmd_change_reference_data(3, FACTORY_PASSPHRASE_PW3 + PW3_TEST0)
|
r = card.cmd_change_reference_data(3, FACTORY_PASSPHRASE_PW3 + PW3_TEST0)
|
||||||
@@ -242,10 +233,6 @@ def test_verify_pw3_2(card):
|
|||||||
v = card.cmd_verify(3, PW3_TEST0)
|
v = card.cmd_verify(3, PW3_TEST0)
|
||||||
assert v
|
assert v
|
||||||
|
|
||||||
PLAIN_TEXT0=b"This is a test message."
|
|
||||||
PLAIN_TEXT1=b"RSA decryption is as easy as pie."
|
|
||||||
PLAIN_TEXT2=b"This is another test message.\nMultiple lines.\n"
|
|
||||||
|
|
||||||
def test_sign_0(card):
|
def test_sign_0(card):
|
||||||
digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT0)
|
digestinfo = rsa_keys.compute_digestinfo(PLAIN_TEXT0)
|
||||||
r = card.cmd_pso(0x9e, 0x9a, digestinfo)
|
r = card.cmd_pso(0x9e, 0x9a, digestinfo)
|
||||||
|
|||||||
@@ -25,16 +25,7 @@ from re import match, DOTALL
|
|||||||
from util import *
|
from util import *
|
||||||
import rsa_keys
|
import rsa_keys
|
||||||
from card_const import *
|
from card_const import *
|
||||||
|
from constants_for_test import *
|
||||||
PW1_TEST0=b"another user pass phrase"
|
|
||||||
PW1_TEST1=b"PASSPHRASE SHOULD BE LONG"
|
|
||||||
PW1_TEST2=b"new user pass phrase"
|
|
||||||
PW1_TEST3=b"next user pass phrase"
|
|
||||||
PW1_TEST4=b"another user pass phrase"
|
|
||||||
PW3_TEST0=b"admin pass phrase"
|
|
||||||
PW3_TEST1=b"another admin pass phrase"
|
|
||||||
|
|
||||||
RESETCODE_TEST=b"example reset code 000"
|
|
||||||
|
|
||||||
def test_login_put(card):
|
def test_login_put(card):
|
||||||
r = card.cmd_put_data(0x00, 0x5e, b"")
|
r = card.cmd_put_data(0x00, 0x5e, b"")
|
||||||
|
|||||||
@@ -20,3 +20,33 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from card_const import *
|
||||||
|
from constants_for_test import *
|
||||||
|
|
||||||
|
def test_verify_pw3_0(card):
|
||||||
|
v = card.cmd_verify(3, FACTORY_PASSPHRASE_PW3)
|
||||||
|
assert v
|
||||||
|
|
||||||
|
def test_kdf_put_full(card):
|
||||||
|
r = card.cmd_put_data(0x00, 0xf9, KDF_FULL)
|
||||||
|
assert r
|
||||||
|
|
||||||
|
def test_verify_pw3_1(card):
|
||||||
|
v = card.cmd_verify(3, KDF_FULL_HASH_PW3)
|
||||||
|
assert v
|
||||||
|
|
||||||
|
def test_kdf_put_single(card):
|
||||||
|
r = card.cmd_put_data(0x00, 0xf9, KDF_SINGLE)
|
||||||
|
assert r
|
||||||
|
|
||||||
|
def test_verify_pw3_2(card):
|
||||||
|
v = card.cmd_verify(3, KDF_SINGLE_HASH_PW3)
|
||||||
|
assert v
|
||||||
|
|
||||||
|
def test_kdf_put_none(card):
|
||||||
|
r = card.cmd_put_data(0x00, 0xf9, b"")
|
||||||
|
assert r
|
||||||
|
|
||||||
|
def test_verify_pw3_3(card):
|
||||||
|
v = card.cmd_verify(3, FACTORY_PASSPHRASE_PW3)
|
||||||
|
assert v
|
||||||
|
|||||||
Reference in New Issue
Block a user