summaryrefslogtreecommitdiffstats
path: root/sys/opencrypto
Commit message (Collapse)AuthorAgeFilesLines
* Let cryptosoft(4) add its pseudo-device with a specific unit number and itsmarius2010-11-141-2/+2
| | | | | | | | | | | probe method return BUS_PROBE_NOWILDCARD so it doesn't get attached to real devices hanging off of nexus(4) with no specific devclass set. Actually, the more desirable fix for this would be to get rid of the newbus interface of cryptosoft(4) altogether but apparently crypto(9) was written with support for cryptographic hardware in mind so that approach would require some KPI breaking changes which don't seem worth it. MFC after: 1 week
* Add support for AES-XTS.pjd2010-09-235-15/+203
| | | | | Obtained from: OpenBSD MFC after: 1 week
* Remove redundant space.pjd2010-09-231-1/+1
| | | | MFC after: 1 week
* Add an extra comment to the SDT probes definition. This allows us to getrpaulo2010-08-221-4/+4
| | | | | | | | | use '-' in probe names, matching the probe names in Solaris.[1] Add userland SDT probes definitions to sys/sdt.h. Sponsored by: The FreeBSD Foundation Discussed with: rwaston [1]
* Fix typo in comment.jhb2010-08-111-1/+1
|
* Add compat32 shims for opencrypto(4).kib2010-07-291-7/+266
| | | | | Reviewed by: bz MFC after: 3 weeks
* Use the fpu_kern_enter() interface to properly separate usermode FPUkib2010-06-051-0/+8
| | | | | | | | | | | | | | context from in-kernel execution of padlock instructions and to handle spurious FPUDNA exceptions that sometime are raised when doing padlock calculations. Globally mark crypto(9) kthread as using FPU. Reviewed by: pjd Hardware provided by: Sentex Communications Tested by: pho PR: amd64/135014 MFC after: 1 month
* Add comments trying to explain what bad things happen here, i.e.bz2010-01-091-1/+18
| | | | | | | | | | | how hashed MD5/SHA are implemented, abusing Final() for padding and sw_octx to transport the key from the beginning to the end. Enlightened about what was going on here by: cperciva Reviewed by: cperciva MFC After: 3 days X-MFC with: r187826 PR: kern/126468
* In case the compression result is the same size as the orignal version,bz2009-11-291-1/+1
| | | | | | | | | | | | the compression was useless as well. Make sure to not update the data and return, else we would waste resources when decompressing. This also avoids the copyback() changing data other consumers like xform_ipcomp.c would have ignored because of no win and sent out without noting that compression was used, resulting in invalid packets at the receiver. MFC after: 5 days
* Add SDT iter probes forgotten in r199885.bz2009-11-291-0/+6
| | | | MFC after: 5 days
* Change memory managment from a fixed size array to a list.bz2009-11-282-60/+73
| | | | | | | | | | | | | | | | This is needed to avoid running into out of buffer situations where we cannot alloc a new buffer because we hit the array size limit (ZBUF). Use a combined allocation for the struct and the actual data buffer to not increase the number of malloc calls. [1] Defer initialization of zbuf until we actually need it. Make sure the output buffer will be large enough in all cases. Details discussed with: kib [1] Reviewed by: kib [1] MFC after: 6 days
* Z_PARTIAL_FLUSH is marked deprecated. Z_SYNC_FLUSH is the suggestedbz2009-11-281-6/+10
| | | | | | | | | | replacement but only use it for inflate. For deflate use Z_FINISH as Z_SYNC_FLUSH adds a trailing marker in some cases that inflate(), despite the comment in zlib, does npt seem to cope well with, resulting in errors when uncompressing exactly fills the outbut buffer without a Z_STREAM_END and a successive call returns an error. MFC after: 6 days
* Add SDT probes for opencrypto:deflate:deflate_gobal:*.bz2009-11-281-7/+61
| | | | | | They are not nice but they were helpful. MFC after: 6 days
* Define an SDT provider for "opencrypto".bz2009-11-281-0/+4
| | | | MFC after: 6 days
* If crypto operation is finished with EAGAIN, don't repeat operation frompjd2009-09-041-8/+9
| | | | | | | | the return context, but from the original context. Before repeating operation clear DONE flag and error. Reviewed by: sam Obtained from: Wheel Sp. z o.o. (http://www.wheel.pl)
* Fix cryptodev UIO creation.raj2009-05-231-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Cryptodev uses UIO structure do get data from userspace and pass it to cryptographic engines. Initially UIO size is equal to size of data passed to engine, but if UIO is prepared for hash calculation an additional small space is created to hold result of operation. While creating space for the result, UIO I/O vector size is correctly extended, but uio_resid field in UIO structure is not modified. As bus_dma code uses uio_resid field to determine size of UIO DMA mapping, resulting mapping hasn't correct size. This leads to a crash if all the following conditions are met: 1. Hardware cryptographic accelerator writes result of hash operation using DMA. 2. Size of input data is less or equal than (n * PAGE_SIZE), 3. Size of input data plus size of hash result is grather than (n * PAGE_SIZE, where n is the same as in point 2. This patch fixes this problem by adding size of the extenstion to uio_resid field in UIO structure. Submitted by: Piotr Ziecik kosmo ! semihalf dot com Reviewed by: philip Obtained from: Semihalf
* Fix return type for detach routine (should be int)imp2009-02-051-2/+3
| | | | Fix first parameter for identify routine (should be driver_t *)
* While OpenBSD's crypto/ framework has sha1 and md5 implementations thatbz2009-01-281-1/+6
| | | | | | | | | can cope with a result buffer of NULL in the "Final" function, we cannot. Thus pass in a temporary buffer long enough for either md5 or sha1 results so that we do not panic. PR: bin/126468 MFC after: 1 week
* Don't hang if encrypting/decrypting using struct iovecs where one of thedfr2008-10-301-0/+4
| | | | iovecs ends on a crypto block boundary.
* Fix a number of style issues in the MALLOC / FREE commit. I've tried todes2008-10-231-7/+7
| | | | | be careful not to fix anything that was already broken; the NFSv4 code is particularly bad in this respect.
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).des2008-10-234-45/+42
| | | | MFC after: 3 months
* Make ftruncate a 'struct file' operation rather than a vnode operation.jhb2008-01-071-0/+14
| | | | | | | | | | | | | | This makes it possible to support ftruncate() on non-vnode file types in the future. - 'struct fileops' grows a 'fo_truncate' method to handle an ftruncate() on a given file descriptor. - ftruncate() moves to kern/sys_generic.c and now just fetches a file object and invokes fo_truncate(). - The vnode-specific portions of ftruncate() move to vn_truncate() in vfs_vnops.c which implements fo_truncate() for vnode file types. - Non-vnode file types return EINVAL in their fo_truncate() method. Submitted by: rwatson
* Remove explicit locking of struct file.jeff2007-12-301-6/+1
| | | | | | | | | | | | | - Introduce a finit() which is used to initailize the fields of struct file in such a way that the ops vector is only valid after the data, type, and flags are valid. - Protect f_flag and f_count with atomic operations. - Remove the global list of all files and associated accounting. - Rewrite the unp garbage collection such that it no longer requires the global list of all files and instead uses a list of all unp sockets. - Mark sockets in the accept queue so we don't incorrectly gc them. Tested by: kris, pho
* Rename the kthread_xxx (e.g. kthread_create()) callsjulian2007-10-201-3/+3
| | | | | | | | | | | to kproc_xxx as they actually make whole processes. Thos makes way for us to add REAL kthread_create() and friends that actually make theads. it turns out that most of these calls actually end up being moved back to the thread version when it's added. but we need to make this cosmetic change first. I'd LOVE to do this rename in 7.0 so that we can eventually MFC the new kthread_xxx() calls.
* Deny attempt to malloc unbounded amount of the memory.kib2007-10-081-3/+6
| | | | | | | | Convert malloc()/bzero() to malloc(M_ZERO). Obtained from: OpenBSD MFC after: 3 days Approved by: re (kensmith)
* Quiet warnings. These do not appear to be actually used uninitialized,peter2007-07-051-1/+1
| | | | | | | but gcc's optimizer isn't smart enough to see that. Pre-initializing seems harmless enough. Approved by: re (rwatson)
* Integrate the Camellia Block Cipher. For more information see RFC 4132gnn2007-05-095-1/+66
| | | | | | | and its bibliography. Submitted by: Tomoyuki Okazaki <okazaki at kick dot gr dot jp> MFC after: 1 month
* Replace custom file descriptor array sleep lock constructed using a mutexrwatson2007-04-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and flags with an sxlock. This leads to a significant and measurable performance improvement as a result of access to shared locking for frequent lookup operations, reduced general overhead, and reduced overhead in the event of contention. All of these are imported for threaded applications where simultaneous access to a shared file descriptor array occurs frequently. Kris has reported 2x-4x transaction rate improvements on 8-core MySQL benchmarks; smaller improvements can be expected for many workloads as a result of reduced overhead. - Generally eliminate the distinction between "fast" and regular acquisisition of the filedesc lock; the plan is that they will now all be fast. Change all locking instances to either shared or exclusive locks. - Correct a bug (pointed out by kib) in fdfree() where previously msleep() was called without the mutex held; sx_sleep() is now always called with the sxlock held exclusively. - Universally hold the struct file lock over changes to struct file, rather than the filedesc lock or no lock. Always update the f_ops field last. A further memory barrier is required here in the future (discussed with jhb). - Improve locking and reference management in linux_at(), which fails to properly acquire vnode references before using vnode pointers. Annotate improper use of vn_fullpath(), which will be replaced at a future date. In fcntl(), we conservatively acquire an exclusive lock, even though in some cases a shared lock may be sufficient, which should be revisited. The dropping of the filedesc lock in fdgrowtable() is no longer required as the sxlock can be held over the sleep operation; we should consider removing that (pointed out by attilio). Tested by: kris Discussed with: jhb, kris, attilio, jeff
* add missing file from last commit that overhauls crypto/driver api'ssam2007-03-211-0/+55
|
* Overhaul driver/subsystem api's:sam2007-03-216-491/+762
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o make all crypto drivers have a device_t; pseudo drivers like the s/w crypto driver synthesize one o change the api between the crypto subsystem and drivers to use kobj; cryptodev_if.m defines this api o use the fact that all crypto drivers now have a device_t to add support for specifying which of several potential devices to use when doing crypto operations o add new ioctls that allow user apps to select a specific crypto device to use (previous ioctls maintained for compatibility) o overhaul crypto subsystem code to eliminate lots of cruft and hide implementation details from drivers o bring in numerous fixes from Michale Richardson/hifn; mostly for 795x parts o add an optional mechanism for mmap'ing the hifn 795x public key h/w to user space for use by openssl (not enabled by default) o update crypto test tools to use new ioctl's and add cmd line options to specify a device to use for tests These changes will also enable much future work on improving the core crypto subsystem; including proper load balancing and interposing code between the core and drivers to dispatch small operations to the s/w driver as appropriate. These changes were instigated by the work of Michael Richardson. Reviewed by: pjd Approved by: re
* When DIAGNOSTIC is defined, verify if we don't free crypto requests frompjd2006-06-061-0/+21
| | | | the crypto queue or from the return queue.
* Use newly added functions to simplify the code.pjd2006-06-041-82/+54
|
* - Replace COPYDATA() and COPYBACK() macros with crypto_copydata() andpjd2006-06-042-27/+47
| | | | | | | crypto_copyback() functions. - Add crypto_apply() function. This will allow for more code simplification.
* Prefer hardware crypto over software crypto.pjd2006-06-041-38/+74
| | | | | | Before the change if a hardware crypto driver was loaded after the software crypto driver, calling crypto_newsession() with hard=0, will always choose software crypto.
* Use newly added defines instead of magic values.pjd2006-06-041-16/+16
|
* Move COPYDATA() and COPYBACK() macros to cryptodev.h, they will be usedpjd2006-06-042-27/+27
| | | | in padlock(4) as well.
* - Remove HMAC_BLOCK_LEN, it serves no purpose.pjd2006-06-041-1/+0
| | | | - Use defines of used algorithm instead of HMAC_BLOCK_LEN.
* - Use define of an algorithm with the biggest block length to describepjd2006-06-041-3/+1
| | | | | EALG_MAX_BLOCK_LEN instead of hardcoded value. - Kill an unused define.
* Rename HMAC_BLOCK_MAXLEN to HMAC_MAX_BLOCK_LEN to be consistent withpjd2006-06-042-6/+6
| | | | EALG_MAX_BLOCK_LEN.
* Rename AALG_MAX_RESULT_LEN to HASH_MAX_LEN to look more constent withpjd2006-06-042-4/+4
| | | | other defines.
* - Add defines with hash length for each hash algorithm.pjd2006-06-041-4/+24
| | | | | | - Add defines with block length for each HMAC algorithm. - Add AES_BLOCK_LEN define which is an alias for RIJNDAEL128_BLOCK_LEN. - Add NULL_BLOCK_LEN define.
* Kill an unused argument.pjd2006-06-041-5/+5
|
* Remove (now unused) crp_mac field.pjd2006-05-221-1/+0
|
* Fix usage of HMAC algorithms via /dev/crypto.pjd2006-05-221-10/+10
|
* Improve the code responsible for waking up the crypto_proc thread.pjd2006-05-221-14/+11
| | | | | | | | | | | | | Checking if the queues are empty is not enough for the crypto_proc thread (it is enough for the crypto_ret_thread), because drivers can be marked as blocked. In a situation where we have operations related to different crypto drivers in the queue, it is possible that one driver is marked as blocked. In this case, the queue will not be empty and we won't wakeup the crypto_proc thread to execute operations for the others drivers. Simply setting a global variable to 1 when we goes to sleep and setting it back to 0 when we wake up is sufficient. The variable is protected with the queue lock.
* Don't wakeup the crypto_ret_proc thread if it is running already.pjd2006-05-221-2/+3
| | | | | | Before the change if the thread was working on symmetric operation, we would send unnecessary wakeup after adding asymmetric operation (when asym queue was empty) and vice versa.
* Don't set cc_kqblocked twice and don't increment cryptostats.cs_kblockspjd2006-05-221-2/+0
| | | | | | twice if we call crypto_kinvoke() from crypto_proc thread. This change also removes unprotected access to cc_kqblocked field (CRYPTO_Q_LOCK() should be used for protection).
* Document how we synchronize access to the fields in the cryptocappjd2006-05-221-6/+13
| | | | structure.
* We must synchronize access to cc_qblocked, because there could be a racepjd2006-05-221-17/+4
| | | | | | | | | | | | | where crypto_invoke() returns ERESTART and before we set cc_qblocked to 1, crypto_unblock() is called and sets it to 0. This way we mark device as blocked forever. Fix it by not setting cc_qblocked in the fast path and by protecting crypto_invoke() in the crypto_proc thread with CRYPTO_Q_LOCK(). This won't slow things down, because there is no contention - we have only one crypto thread. Actually it can be slightly faster, because we save two atomic ops per crypto request. The fast code path remains lock-less.
* Silent Coverity Prevent report by asserting that cap != NULL.pjd2006-05-181-2/+4
| | | | Coverity ID: 1414
OpenPOWER on IntegriCloud