crypto(9): Use a more specific error code when a capable driver is not found
When crypto_newsession() is given a request for an unsupported capability, raise a more specific error than EINVAL. This allows cryptotest.py to skip some HMAC tests that a driver does not support. Reviewed by: jhb, rlibby Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D12451
This commit is contained in:
parent
996a93432a
commit
a317fb03c2
@ -460,7 +460,7 @@ crypto_newsession(u_int64_t *sid, struct cryptoini *cri, int crid)
|
||||
CRYPTDEB("dev newsession failed");
|
||||
} else {
|
||||
CRYPTDEB("no driver");
|
||||
err = EINVAL;
|
||||
err = EOPNOTSUPP;
|
||||
}
|
||||
CRYPTO_DRIVER_UNLOCK();
|
||||
return err;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import errno
|
||||
import cryptodev
|
||||
import itertools
|
||||
import os
|
||||
@ -284,8 +285,14 @@ def GenTestCase(cname):
|
||||
if len(key) > blocksize:
|
||||
continue
|
||||
|
||||
c = Crypto(mac=alg, mackey=key,
|
||||
crid=crid)
|
||||
try:
|
||||
c = Crypto(mac=alg, mackey=key,
|
||||
crid=crid)
|
||||
except EnvironmentError, e:
|
||||
# Can't test hashes the driver does not support.
|
||||
if e.errno != errno.EOPNOTSUPP:
|
||||
raise
|
||||
continue
|
||||
|
||||
_, r = c.encrypt(msg, iv="")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user