aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 16:40:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 16:40:17 -0400
commitbbce2ad2d711c12d93145a7bbdf086e73f414bcd (patch)
tree35432a39f68f4c5df44ed38037cbf05adadb923e /drivers/usb/misc
parent0f776dc377f6c87f4e4d4a5f63602f33fb93b31e (diff)
parent0f95e2ffc58f5d32a90eb1051d17aeebc21cf91d (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto updates from Herbert Xu: "Here is the crypto update for 4.8: API: - first part of skcipher low-level conversions - add KPP (Key-agreement Protocol Primitives) interface. Algorithms: - fix IPsec/cryptd reordering issues that affects aesni - RSA no longer does explicit leading zero removal - add SHA3 - add DH - add ECDH - improve DRBG performance by not doing CTR by hand Drivers: - add x86 AVX2 multibuffer SHA256/512 - add POWER8 optimised crc32c - add xts support to vmx - add DH support to qat - add RSA support to caam - add Layerscape support to caam - add SEC1 AEAD support to talitos - improve performance by chaining requests in marvell/cesa - add support for Araneus Alea I USB RNG - add support for Broadcom BCM5301 RNG - add support for Amlogic Meson RNG - add support Broadcom NSP SoC RNG" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (180 commits) crypto: vmx - Fix aes_p8_xts_decrypt build failure crypto: vmx - Ignore generated files crypto: vmx - Adding support for XTS crypto: vmx - Adding asm subroutines for XTS crypto: skcipher - add comment for skcipher_alg->base crypto: testmgr - Print akcipher algorithm name crypto: marvell - Fix wrong flag used for GFP in mv_cesa_dma_add_iv_op crypto: nx - off by one bug in nx_of_update_msc() crypto: rsa-pkcs1pad - fix rsa-pkcs1pad request struct crypto: scatterwalk - Inline start/map/done crypto: scatterwalk - Remove unnecessary BUG in scatterwalk_start crypto: scatterwalk - Remove unnecessary advance in scatterwalk_pagedone crypto: scatterwalk - Fix test in scatterwalk_done crypto: api - Optimise away crypto_yield when hard preemption is on crypto: scatterwalk - add no-copy support to copychunks crypto: scatterwalk - Remove scatterwalk_bytes_sglen crypto: omap - Stop using crypto scatterwalk_bytes_sglen crypto: skcipher - Remove top-level givcipher interface crypto: user - Remove crypto_lookup_skcipher call crypto: cts - Convert to skcipher ...
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/Kconfig11
-rw-r--r--drivers/usb/misc/chaoskey.c21
2 files changed, 25 insertions, 7 deletions
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index e9e5ae521fa6..6e705971d637 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -260,11 +260,12 @@ config USB_CHAOSKEY
260 tristate "ChaosKey random number generator driver support" 260 tristate "ChaosKey random number generator driver support"
261 depends on HW_RANDOM 261 depends on HW_RANDOM
262 help 262 help
263 Say Y here if you want to connect an AltusMetrum ChaosKey to 263 Say Y here if you want to connect an AltusMetrum ChaosKey or
264 your computer's USB port. The ChaosKey is a hardware random 264 Araneus Alea I to your computer's USB port. These devices
265 number generator which hooks into the kernel entropy pool to 265 are hardware random number generators which hook into the
266 ensure a large supply of entropy for /dev/random and 266 kernel entropy pool to ensure a large supply of entropy for
267 /dev/urandom and also provides direct access via /dev/chaoskeyX 267 /dev/random and /dev/urandom and also provides direct access
268 via /dev/chaoskeyX
268 269
269 To compile this driver as a module, choose M here: the 270 To compile this driver as a module, choose M here: the
270 module will be called chaoskey. 271 module will be called chaoskey.
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index 76350e4ee807..6ddd08a32777 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -55,9 +55,13 @@ MODULE_LICENSE("GPL");
55#define CHAOSKEY_VENDOR_ID 0x1d50 /* OpenMoko */ 55#define CHAOSKEY_VENDOR_ID 0x1d50 /* OpenMoko */
56#define CHAOSKEY_PRODUCT_ID 0x60c6 /* ChaosKey */ 56#define CHAOSKEY_PRODUCT_ID 0x60c6 /* ChaosKey */
57 57
58#define ALEA_VENDOR_ID 0x12d8 /* Araneus */
59#define ALEA_PRODUCT_ID 0x0001 /* Alea I */
60
58#define CHAOSKEY_BUF_LEN 64 /* max size of USB full speed packet */ 61#define CHAOSKEY_BUF_LEN 64 /* max size of USB full speed packet */
59 62
60#define NAK_TIMEOUT (HZ) /* stall/wait timeout for device */ 63#define NAK_TIMEOUT (HZ) /* normal stall/wait timeout */
64#define ALEA_FIRST_TIMEOUT (HZ*3) /* first stall/wait timeout for Alea */
61 65
62#ifdef CONFIG_USB_DYNAMIC_MINORS 66#ifdef CONFIG_USB_DYNAMIC_MINORS
63#define USB_CHAOSKEY_MINOR_BASE 0 67#define USB_CHAOSKEY_MINOR_BASE 0
@@ -69,6 +73,7 @@ MODULE_LICENSE("GPL");
69 73
70static const struct usb_device_id chaoskey_table[] = { 74static const struct usb_device_id chaoskey_table[] = {
71 { USB_DEVICE(CHAOSKEY_VENDOR_ID, CHAOSKEY_PRODUCT_ID) }, 75 { USB_DEVICE(CHAOSKEY_VENDOR_ID, CHAOSKEY_PRODUCT_ID) },
76 { USB_DEVICE(ALEA_VENDOR_ID, ALEA_PRODUCT_ID) },
72 { }, 77 { },
73}; 78};
74MODULE_DEVICE_TABLE(usb, chaoskey_table); 79MODULE_DEVICE_TABLE(usb, chaoskey_table);
@@ -84,6 +89,7 @@ struct chaoskey {
84 int open; /* open count */ 89 int open; /* open count */
85 bool present; /* device not disconnected */ 90 bool present; /* device not disconnected */
86 bool reading; /* ongoing IO */ 91 bool reading; /* ongoing IO */
92 bool reads_started; /* track first read for Alea */
87 int size; /* size of buf */ 93 int size; /* size of buf */
88 int valid; /* bytes of buf read */ 94 int valid; /* bytes of buf read */
89 int used; /* bytes of buf consumed */ 95 int used; /* bytes of buf consumed */
@@ -188,6 +194,9 @@ static int chaoskey_probe(struct usb_interface *interface,
188 194
189 dev->in_ep = in_ep; 195 dev->in_ep = in_ep;
190 196
197 if (udev->descriptor.idVendor != ALEA_VENDOR_ID)
198 dev->reads_started = 1;
199
191 dev->size = size; 200 dev->size = size;
192 dev->present = 1; 201 dev->present = 1;
193 202
@@ -357,6 +366,7 @@ static int _chaoskey_fill(struct chaoskey *dev)
357{ 366{
358 DEFINE_WAIT(wait); 367 DEFINE_WAIT(wait);
359 int result; 368 int result;
369 bool started;
360 370
361 usb_dbg(dev->interface, "fill"); 371 usb_dbg(dev->interface, "fill");
362 372
@@ -389,10 +399,17 @@ static int _chaoskey_fill(struct chaoskey *dev)
389 goto out; 399 goto out;
390 } 400 }
391 401
402 /* The first read on the Alea takes a little under 2 seconds.
403 * Reads after the first read take only a few microseconds
404 * though. Presumably the entropy-generating circuit needs
405 * time to ramp up. So, we wait longer on the first read.
406 */
407 started = dev->reads_started;
408 dev->reads_started = true;
392 result = wait_event_interruptible_timeout( 409 result = wait_event_interruptible_timeout(
393 dev->wait_q, 410 dev->wait_q,
394 !dev->reading, 411 !dev->reading,
395 NAK_TIMEOUT); 412 (started ? NAK_TIMEOUT : ALEA_FIRST_TIMEOUT) );
396 413
397 if (result < 0) 414 if (result < 0)
398 goto out; 415 goto out;