Index: sys/opencrypto/crypto.c =================================================================== --- sys/opencrypto/crypto.c +++ sys/opencrypto/crypto.c @@ -432,8 +432,11 @@ * Use specified driver; verify it is capable. */ cap = crypto_checkdriver(crid); - if (cap != NULL && !driver_suitable(cap, cri)) - cap = NULL; + if (cap != NULL && !driver_suitable(cap, cri)) { + CRYPTDEB("driver missing capability"); + err = EOPNOTSUPP; + goto out; + } } else { /* * No requested driver; select based on crid flags. @@ -462,6 +465,7 @@ CRYPTDEB("no driver"); err = EINVAL; } +out: CRYPTO_DRIVER_UNLOCK(); return err; } Index: tests/sys/opencrypto/cryptotest.py =================================================================== --- tests/sys/opencrypto/cryptotest.py +++ tests/sys/opencrypto/cryptotest.py @@ -29,6 +29,7 @@ # $FreeBSD$ # +import errno import cryptodev import itertools import os @@ -283,8 +284,14 @@ if len(key) > blocksize: continue - c = Crypto(mac=alg, mackey=key, - crid=crid) + try: + c = Crypto(mac=alg, mackey=key, + crid=crid) + # Can't test hashes the driver does not support. + except EnvironmentError, e: + if e.errno != errno.EOPNOTSUPP: + raise + continue _, r = c.encrypt(msg, iv="")