From owner-p4-projects@FreeBSD.ORG Tue Dec 5 04:43:02 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0F5CC16A40F; Tue, 5 Dec 2006 04:43:02 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D10BC16A403 for ; Tue, 5 Dec 2006 04:43:01 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.FreeBSD.org (Postfix) with ESMTP id CBF7143C9D for ; Tue, 5 Dec 2006 04:42:24 +0000 (GMT) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id kB54h185050267 for ; Tue, 5 Dec 2006 04:43:01 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id kB54h1Cx050262 for perforce@freebsd.org; Tue, 5 Dec 2006 04:43:01 GMT (envelope-from sam@freebsd.org) Date: Tue, 5 Dec 2006 04:43:01 GMT Message-Id: <200612050443.kB54h1Cx050262@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 111107 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Dec 2006 04:43:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=111107 Change 111107 by sam@sam_ebb on 2006/12/05 04:42:46 move check of crypto_userasymcrypto from the core crypto code to the /dev/crypto ioctl handler where it belongs Affected files ... .. //depot/projects/crypto/sys/opencrypto/crypto.c#5 edit .. //depot/projects/crypto/sys/opencrypto/cryptodev.c#3 edit Differences ... ==== //depot/projects/crypto/sys/opencrypto/crypto.c#5 (text+ko) ==== @@ -1220,9 +1220,6 @@ { int hid, kalg, feat = 0; - if (!crypto_userasymcrypto) - goto out; - CRYPTO_DRIVER_LOCK(); for (hid = 0; hid < crypto_drivers_num; hid++) { if ((crypto_drivers[hid].cc_flags & CRYPTOCAP_F_SOFTWARE) && @@ -1235,7 +1232,6 @@ feat |= 1 << kalg; } CRYPTO_DRIVER_UNLOCK(); -out: *featp = feat; return (0); } ==== //depot/projects/crypto/sys/opencrypto/cryptodev.c#3 (text+ko) ==== @@ -325,7 +325,16 @@ error = cryptodev_key(kop); break; case CIOCASYMFEAT: - error = crypto_getfeat((int *)data); + if (!crypto_userasymcrypto) { + /* + * NB: if user asym crypto operations are + * not permitted return "no algorithms" + * so well-behaved applications will just + * fallback to doing them in software. + */ + *(int *)data = 0; + } else + error = crypto_getfeat((int *)data); break; case CIOCFINDDEV: error = cryptodev_find((struct crypt_find_op *)data);