Changeset View
Changeset View
Standalone View
Standalone View
head/tests/sys/opencrypto/cryptotest.py
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | 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): | ||||
############### | ############### | ||||
##### AES ##### | ##### AES ##### | ||||
############### | ############### | ||||
@unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' % (cname)) | @unittest.skipIf(cname not in aesmodules, 'skipping AES-XTS on %s' % (cname)) | ||||
def test_xts(self): | def test_xts(self): | ||||
for i in katg('XTSTestVectors/format tweak value input - data unit seq no', '*.rsp'): | for i in katg('XTSTestVectors/format tweak value input - data unit seq no', '*.rsp'): | ||||
self.runXTS(i, cryptodev.CRYPTO_AES_XTS) | self.runXTS(i, cryptodev.CRYPTO_AES_XTS) | ||||
@unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' % (cname)) | @unittest.skipIf(cname not in aesmodules, 'skipping AES-CBC on %s' % (cname)) | ||||
def test_cbc(self): | def test_cbc(self): | ||||
for i in katg('KAT_AES', 'CBC[GKV]*.rsp'): | for i in katg('KAT_AES', 'CBC[GKV]*.rsp'): | ||||
self.runCBC(i) | self.runCBC(i) | ||||
@unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' % (cname)) | @unittest.skipIf(cname not in aesmodules, 'skipping AES-GCM on %s' % (cname)) | ||||
def test_gcm(self): | def test_gcm(self): | ||||
for i in katg('gcmtestvectors', 'gcmEncrypt*'): | for i in katg('gcmtestvectors', 'gcmEncrypt*'): | ||||
self.runGCM(i, 'ENCRYPT') | self.runGCM(i, 'ENCRYPT') | ||||
for i in katg('gcmtestvectors', 'gcmDecrypt*'): | for i in katg('gcmtestvectors', 'gcmDecrypt*'): | ||||
self.runGCM(i, 'DECRYPT') | self.runGCM(i, 'DECRYPT') | ||||
_gmacsizes = { 32: cryptodev.CRYPTO_AES_256_NIST_GMAC, | _gmacsizes = { 32: cryptodev.CRYPTO_AES_256_NIST_GMAC, | ||||
▲ Show 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | class GendCryptoTestCase(unittest.TestCase): | ||||
############### | ############### | ||||
@unittest.skipIf(cname not in shamodules, 'skipping SHA on %s' % str(cname)) | @unittest.skipIf(cname not in shamodules, 'skipping SHA on %s' % str(cname)) | ||||
def test_sha(self): | def test_sha(self): | ||||
# SHA not available in software | # SHA not available in software | ||||
pass | pass | ||||
#for i in iglob('SHA1*'): | #for i in iglob('SHA1*'): | ||||
# self.runSHA(i) | # self.runSHA(i) | ||||
@unittest.skipIf(cname not in shamodules, 'skipping SHA on %s' % str(cname)) | @unittest.skipIf(cname not in shamodules, 'skipping SHA-HMAC on %s' % str(cname)) | ||||
def test_sha1hmac(self): | def test_sha1hmac(self): | ||||
for i in katg('hmactestvectors', 'HMAC.rsp'): | for i in katg('hmactestvectors', 'HMAC.rsp'): | ||||
self.runSHA1HMAC(i) | self.runSHA1HMAC(i) | ||||
def runSHA1HMAC(self, fname): | def runSHA1HMAC(self, fname): | ||||
for hashlength, lines in cryptodev.KATParser(fname, | for hashlength, lines in cryptodev.KATParser(fname, | ||||
[ 'Count', 'Klen', 'Tlen', 'Key', 'Msg', 'Mac' ]): | [ 'Count', 'Klen', 'Tlen', 'Key', 'Msg', 'Mac' ]): | ||||
# E.g., hashlength will be "L=20" (bytes) | # E.g., hashlength will be "L=20" (bytes) | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |