Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/opencrypto/cryptotest.py
Show All 40 Lines | |||||
katdir = '/usr/local/share/nist-kat' | katdir = '/usr/local/share/nist-kat' | ||||
def katg(base, glob): | def katg(base, glob): | ||||
assert os.path.exists(os.path.join(katdir, base)), "Please 'pkg install nist-kat'" | assert os.path.exists(os.path.join(katdir, base)), "Please 'pkg install nist-kat'" | ||||
return iglob(os.path.join(katdir, base, glob)) | return iglob(os.path.join(katdir, base, glob)) | ||||
aesmodules = [ 'cryptosoft0', 'aesni0', 'ccr0' ] | aesmodules = [ 'cryptosoft0', 'aesni0', 'ccr0' ] | ||||
desmodules = [ 'cryptosoft0', ] | desmodules = [ 'cryptosoft0', ] | ||||
shamodules = [ 'cryptosoft0', 'ccr0' ] | shamodules = [ 'cryptosoft0', 'ccr0', 'sha_sse0' ] | ||||
def GenTestCase(cname): | def GenTestCase(cname): | ||||
try: | try: | ||||
crid = cryptodev.Crypto.findcrid(cname) | crid = cryptodev.Crypto.findcrid(cname) | ||||
except IOError: | except IOError: | ||||
return None | return None | ||||
class GendCryptoTestCase(unittest.TestCase): | class GendCryptoTestCase(unittest.TestCase): | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | def runSHA1HMAC(self, fname): | ||||
self.assertEqual(r[:maclen], mac[:maclen], "Actual: " + \ | self.assertEqual(r[:maclen], mac[:maclen], "Actual: " + \ | ||||
repr(r[:maclen].encode("hex")) + " Expected: " + repr(data)) | repr(r[:maclen].encode("hex")) + " Expected: " + repr(data)) | ||||
return GendCryptoTestCase | return GendCryptoTestCase | ||||
cryptosoft = GenTestCase('cryptosoft0') | cryptosoft = GenTestCase('cryptosoft0') | ||||
aesni = GenTestCase('aesni0') | aesni = GenTestCase('aesni0') | ||||
ccr = GenTestCase('ccr0') | ccr = GenTestCase('ccr0') | ||||
sha_sse = GenTestCase('sha_sse0') | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
unittest.main() | unittest.main() |