Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Nov 2014 00:41:42 GMT
From:      John-Mark Gurney <jmg@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 1202587 for review
Message-ID:  <201411070041.sA70fgwi015377@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help

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`



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