From owner-p4-projects@FreeBSD.ORG Fri Nov 7 00:41:43 2014 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4371BA32; Fri, 7 Nov 2014 00:41:43 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 04237A30 for ; Fri, 7 Nov 2014 00:41:43 +0000 (UTC) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:1900:2254:2068::682: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 E505EA71 for ; Fri, 7 Nov 2014 00:41:42 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.9/8.14.9) with ESMTP id sA70fggi015380 for ; Fri, 7 Nov 2014 00:41:42 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.9/8.14.9/Submit) id sA70fgwi015377 for perforce@freebsd.org; Fri, 7 Nov 2014 00:41:42 GMT (envelope-from jmg@freebsd.org) Date: Fri, 7 Nov 2014 00:41:42 GMT Message-Id: <201411070041.sA70fgwi015377@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney Subject: PERFORCE change 1202587 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.18-1 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Nov 2014 00:41:43 -0000 http://p4web.freebsd.org/@@1202587?ac=10 Change 1202587 by jmg@jmg_carbon2 on 2014/11/07 00:40:50 add a method to map a device name to it's crid... This will allow us to specify which device to test... It'd be nice in the future to query and test all of the devices that are in the system, though as each one will support a different set of features, it'll be complicated to test and make sure we know they are correct.. Sponsored by: FreeBSD Foundation Sponsored by: Netgate Affected files ... .. //depot/projects/opencrypto/tests/sys/opencrypto/cryptodev.py#2 edit Differences ... ==== //depot/projects/opencrypto/tests/sys/opencrypto/cryptodev.py#2 (text+ko) ==== @@ -11,6 +11,12 @@ __all__ = [ 'Crypto', 'MismatchError', ] +class FindOp(dpkt.Packet): + __byte_order__ = '@' + __hdr__ = ( ('crid', 'i', 0), + ('name', '32s', 0), + ) + class SessionOp(dpkt.Packet): __byte_order__ = '@' __hdr__ = ( ('cipher', 'I', 0), @@ -89,7 +95,19 @@ _cryptodev = _getdev() class Crypto: - def __init__(self, cipher=0, key=None, mac=0, mackey=None): + @staticmethod + def findcrid(name): + fop = FindOp() + fop.crid = -1 + fop.name = name + s = array.array('B', fop.pack_hdr()) + ioctl(_cryptodev, CIOCFINDDEV, s, 1) + fop.unpack(s) + + return fop.crid + + def __init__(self, cipher=0, key=None, mac=0, mackey=None, + crid=CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE): self._ses = None ses = SessionOp2() ses.cipher = cipher @@ -327,7 +345,10 @@ return ''.join(s.split()).decode('hex') if __name__ == '__main__': - if False: + if True: + print Crypto.findcrid('aesni0') + + elif False: kp = KATParser('/usr/home/jmg/aesni.testing/format tweak value input - data unit seq no/XTSGenAES128.rsp', [ 'COUNT', 'DataUnitLen', 'Key', 'DataUnitSeqNumber', 'PT', 'CT' ]) for mode, ni in kp: print `i`, `ni`