From owner-svn-src-head@freebsd.org Tue Sep 26 01:31:51 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1861BE29503; Tue, 26 Sep 2017 01:31:51 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DA3FF7098C; Tue, 26 Sep 2017 01:31:50 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8Q1VnoE066047; Tue, 26 Sep 2017 01:31:49 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8Q1VnJd066045; Tue, 26 Sep 2017 01:31:49 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201709260131.v8Q1VnJd066045@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 26 Sep 2017 01:31:49 +0000 (UTC) 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 X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: sys/opencrypto tests/sys/opencrypto X-SVN-Commit-Revision: 323999 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Sep 2017 01:31:51 -0000 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="")