svn commit: r323999 - in head: sys/opencrypto tests/sys/opencrypto
Conrad Meyer
cem at FreeBSD.org
Tue Sep 26 01:31:51 UTC 2017
Author: cem
Date: Tue Sep 26 01:31:49 2017
New Revision: 323999
URL: https://svnweb.freebsd.org/changeset/base/323999
Log:
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
Modified:
head/sys/opencrypto/crypto.c
head/tests/sys/opencrypto/cryptotest.py
Modified: head/sys/opencrypto/crypto.c
==============================================================================
--- head/sys/opencrypto/crypto.c Mon Sep 25 23:50:10 2017 (r323998)
+++ head/sys/opencrypto/crypto.c Tue Sep 26 01:31:49 2017 (r323999)
@@ -460,7 +460,7 @@ crypto_newsession(u_int64_t *sid, struct cryptoini *cr
CRYPTDEB("dev newsession failed");
} else {
CRYPTDEB("no driver");
- err = EINVAL;
+ err = EOPNOTSUPP;
}
CRYPTO_DRIVER_UNLOCK();
return err;
Modified: head/tests/sys/opencrypto/cryptotest.py
==============================================================================
--- head/tests/sys/opencrypto/cryptotest.py Mon Sep 25 23:50:10 2017 (r323998)
+++ head/tests/sys/opencrypto/cryptotest.py Tue Sep 26 01:31:49 2017 (r323999)
@@ -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="")
More information about the svn-src-head
mailing list