Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Sep 2017 01:31:49 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323999 - in head: sys/opencrypto tests/sys/opencrypto
Message-ID:  <201709260131.v8Q1VnJd066045@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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="")
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709260131.v8Q1VnJd066045>