aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto
Commit message (Collapse)AuthorAgeFilesLines
* Revert previous commit...Kevin Lo2012-10-101-1/+1
| | | | | | | Pointyhat to: kevlo (myself) Notes: svn path=/head/; revision=241394
* Prefer NULL over 0 for pointersKevin Lo2012-10-091-1/+1
| | | | Notes: svn path=/head/; revision=241370
* Add support for the extended FPU states on amd64, both for nativeKonstantin Belousov2012-01-217-14/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 64bit and 32bit ABIs. As a side-effect, it enables AVX on capable CPUs. In particular: - Query the CPU support for XSAVE, list of the supported extensions and the required size of FPU save area. The hw.use_xsave tunable is provided for disabling XSAVE, and hw.xsave_mask may be used to select the enabled extensions. - Remove the FPU save area from PCB and dynamically allocate the (run-time sized) user save area on the top of the kernel stack, right above the PCB. Reorganize the thread0 PCB initialization to postpone it after BSP is queried for save area size. - The dumppcb, stoppcbs and susppcbs now do not carry the FPU state as well. FPU state is only useful for suspend, where it is saved in dynamically allocated suspfpusave area. - Use XSAVE and XRSTOR to save/restore FPU state, if supported and enabled. - Define new mcontext_t flag _MC_HASFPXSTATE, indicating that mcontext_t has a valid pointer to out-of-struct extended FPU state. Signal handlers are supplied with stack-allocated fpu state. The sigreturn(2) and setcontext(2) syscall honour the flag, allowing the signal handlers to inspect and manipilate extended state in the interrupted context. - The getcontext(2) never returns extended state, since there is no place in the fixed-sized mcontext_t to place variable-sized save area. And, since mcontext_t is embedded into ucontext_t, makes it impossible to fix in a reasonable way. Instead of extending getcontext(2) syscall, provide a sysarch(2) facility to query extended FPU state. - Add ptrace(2) support for getting and setting extended state; while there, implement missed PT_I386_{GET,SET}XMMREGS for 32bit binaries. - Change fpu_kern KPI to not expose struct fpu_kern_ctx layout to consumers, making it opaque. Internally, struct fpu_kern_ctx now contains a space for the extended state. Convert in-kernel consumers of fpu_kern KPI both on i386 and amd64. First version of the support for AVX was submitted by Tim Bird <tim.bird am sony com> on behalf of Sony. This version was written from scratch. Tested by: pho (previous version), Yamagi Burmeister <lists yamagi org> MFC after: 1 month Notes: svn path=/head/; revision=230426
* Update Copyright.Pawel Jakub Dawidek2011-10-271-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=226839
* Improve AES-NI performance for AES-XTS:Pawel Jakub Dawidek2011-10-271-26/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Operate on uint64_t types when doing XORing, etc. instead of uint8_t. - Don't bzero() temporary block for every AES block. Do it once for entire data block. - AES-NI is available only on little endian architectures. Simplify code that takes block number from IV. Benchmarks: Memory-backed md(4) device, software AES-XTS, 4kB sector: # dd if=/dev/md0.eli bs=1m 59.61MB/s Memory-backed md(4) device, old AES-NI AES-XTS, 4kB sector: # dd if=/dev/md0.eli bs=1m 97.29MB/s Memory-backed md(4) device, new AES-NI AES-XTS, 4kB sector: # dd if=/dev/md0.eli bs=1m 221.26MB/s 127% performance improvement between old and new code. Harddisk, raw speed: # dd if=/dev/ada0 bs=1m 137.63MB/s Harddisk, software AES-XTS, 4kB sector: # dd if=/dev/ada0.eli bs=1m 47.83MB/s (34% of raw disk speed) Harddisk, old AES-NI AES-XTS, 4kB sector: # dd if=/dev/ada0.eli bs=1m 68.33MB/s (49% of raw disk speed) Harddisk, new AES-NI AES-XTS, 4kB sector: # dd if=/dev/ada0.eli bs=1m 108.35MB/s (78% of raw disk speed) 58% performance improvement between old and new code. As a side-note, GELI with AES-NI using AES-CBC can achive native disk speed. MFC after: 3 days Notes: svn path=/head/; revision=226837
* Fix a bug in the result of manual assembly.Konstantin Belousov2011-03-022-2/+2
| | | | | | | | | Reported by: Stefan Grundmann <sg2342 googlemail com> PR: kern/155118 MFC after: 3 days Notes: svn path=/head/; revision=219178
* Make private functions static.Rebecca Cran2011-02-211-8/+8
| | | | | | | | | | PR: kern/43611 Submitted by: Matt Emmerton <matt at gsicomp.on.ca> Reviewed by: kib MFC after: 3 days Notes: svn path=/head/; revision=218918
* Remove DEBUG sections.Konstantin Belousov2010-11-271-24/+0
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=215942
* MFaesni r215427:Konstantin Belousov2010-11-263-9/+31
| | | | | | | | | | | Only save FPU context when not executing in the context of the crypto thread. Tested by: Mike Tancsa MFC after: 1 week Notes: svn path=/head/; revision=215864
* Only save FPU context when not executing in the context of the cryptoKonstantin Belousov2010-11-171-8/+22
| | | | | | | | | thread. Tested by: Mike Tancsa Notes: svn path=/head/; revision=215427
* Change two missed instances of 'retq' in aeskeys_i386.S to 'retl', whichDimitry Andric2010-10-131-2/+2
| | | | | | | | | makes it possible to assemble this file with gas from newer binutils. Reviewed by: kib Notes: svn path=/head/; revision=213797
* Fix two copy&paste bugs.Pawel Jakub Dawidek2010-09-251-2/+2
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=213166
* Add support for CRYPTO_AES_XTS.Pawel Jakub Dawidek2010-09-233-24/+151
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=213069
* Add support for CRD_F_KEY_EXPLICIT flag.Pawel Jakub Dawidek2010-09-231-16/+32
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=213066
* Simplify code a bit.Pawel Jakub Dawidek2010-09-232-10/+5
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=213064
* Crypto(4) driver for AESNI.Konstantin Belousov2010-07-237-0/+1464
| | | | | | | | | | | | The aeskeys_{amd64,i386}.S content was mostly obtained from OpenBSD, no objections to the license from core. Hardware provided by: Sentex Communications Tested by: fabient, pho (previous versions) MFC after: 1 month Notes: svn path=/head/; revision=210409
* Use the fpu_kern_enter() interface to properly separate usermode FPUKonstantin Belousov2010-06-054-3/+34
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=208834
* Changed to M_NOWAIT when reallocing psc_buf in padlock_sha_update(),VANHULLEBUS Yvan2009-05-271-1/+3
| | | | | | | | | | | as we already hold the non sleepable crypto_driver_mutex. Approved by: gnn(mentor) Obtained from: NETASQ MFC after: 2 weeks Notes: svn path=/head/; revision=192883
* identify routine takes driver_t *, not device_t *.Warner Losh2009-02-051-1/+1
| | | | Notes: svn path=/head/; revision=188171
* Connect padlock(4) to amd64 build for VIA Nano processors.Jung-uk Kim2009-01-122-3/+3
| | | | Notes: svn path=/head/; revision=187112
* Avoid 256 integer divisions per rc4_init() call. Replace it with usingAlexander Motin2008-12-161-3/+5
| | | | | | | | | | | separate index variable. It gives more then double rc4_init() performance increase on tested i386 P4. It also gives about 15% speedup to PPTP VPN with stateless MPPE encryption (by ng_mppc) which calls rc4_init() for every packet. Notes: svn path=/head/; revision=186179
* Fix a potential NULL-pointer dereference in padlock(4).Philip Paeps2008-11-171-1/+5
| | | | | | | | Spotted by: Coverity (via pjd) MFC after: 1 week Notes: svn path=/head/; revision=185026
* Simplify session selection/allocation.Pawel Jakub Dawidek2008-08-091-10/+5
| | | | Notes: svn path=/head/; revision=181478
* - Fix freeing session on newsession failure.Pawel Jakub Dawidek2008-08-091-9/+24
| | | | | | | - Update copyright years. Notes: svn path=/head/; revision=181477
* Implify sessions freeing loop.Pawel Jakub Dawidek2008-08-091-2/+1
| | | | Notes: svn path=/head/; revision=181476
* We don't have to drop a lock around malloc(M_NOWAIT).Pawel Jakub Dawidek2008-08-091-4/+4
| | | | Notes: svn path=/head/; revision=181475
* When freeing session, restore its ID after zeroing memory.Pawel Jakub Dawidek2008-08-091-0/+1
| | | | | | | Bug tracked down by: Patrick Lamaiziere <patfbsd@davenulle.org> Notes: svn path=/head/; revision=181474
* Sessions in-use are at the end of the queue, so use TAILQ_FOREACH_REVERSE()Pawel Jakub Dawidek2008-08-091-3/+5
| | | | | | | | | when looking for them. Idea from: Patrick Lamaiziere <patfbsd@davenulle.org> Notes: svn path=/head/; revision=181473
* Convert lock that protects sessions list from a mutex to a rwlock.Pawel Jakub Dawidek2008-07-201-16/+16
| | | | | | | Now we can use read lock in fast path (padlock_process()). Notes: svn path=/head/; revision=180626
* Make test00 compilable again.Maxim Sobolev2008-01-152-1/+3
| | | | Notes: svn path=/head/; revision=175360
* Commit the change from FAST_IPSEC to IPSEC. The FAST_IPSECGeorge V. Neville-Neil2007-07-031-1/+1
| | | | | | | | | | | option is now deprecated, as well as the KAME IPsec code. What was FAST_IPSEC is now IPSEC. Approved by: re Sponsored by: Secure Computing Notes: svn path=/head/; revision=171167
* Integrate the Camellia Block Cipher. For more information see RFC 4132George V. Neville-Neil2007-05-093-0/+1459
| | | | | | | | | | and its bibliography. Submitted by: Tomoyuki Okazaki <okazaki at kick dot gr dot jp> MFC after: 1 month Notes: svn path=/head/; revision=169425
* Overhaul driver/subsystem api's:Sam Leffler2007-03-211-74/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=167755
* Initialize T1 to silent gcc warning.Kevin Lo2006-10-221-1/+1
| | | | | | | Approved by: cognet Notes: svn path=/head/; revision=163602
* Less magic.Pawel Jakub Dawidek2006-09-151-2/+3
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=162316
* GCC 3.4.6 gets confused on this file and produces bogus warning.Alexander Kabaev2006-08-261-1/+1
| | | | | | | Shut it up. Notes: svn path=/head/; revision=161661
* Remove trailing spaces.Pawel Jakub Dawidek2006-07-281-1/+1
| | | | Notes: svn path=/head/; revision=160785
* Use existing roundup2() macro.Pawel Jakub Dawidek2006-07-281-1/+1
| | | | | | | Suggested by: njl Notes: svn path=/head/; revision=160784
* Remove redundant check committed by accident.Pawel Jakub Dawidek2006-07-251-2/+0
| | | | Notes: svn path=/head/; revision=160677
* Avoid memory allocations when the given address is already 16 bytes aligned.Pawel Jakub Dawidek2006-07-251-6/+51
| | | | | | | | | | | | | | | | | Such an address can be used directly in padlock's AES. This improves speed of geli(8) significantly: # sysctl kern.geom.zero.clear=0 # geli onetime -s 4096 gzero # dd if=/dev/gzero.eli of=/dev/null bs=1m count=1000 Before: 113MB/s After: 203MB/s BTW. If sector size is set to 128kB, I can read at 276MB/s :) Notes: svn path=/head/; revision=160676
* Modify PADLOCK_ALIGN() macro, so when the given address is already 16 bytesPawel Jakub Dawidek2006-07-251-1/+1
| | | | | | | aligned, it will be used directly, not 'address + 16'. Notes: svn path=/head/; revision=160675
* Style fixes.Pawel Jakub Dawidek2006-07-254-10/+10
| | | | Notes: svn path=/head/; revision=160674
* Implement support for HMAC/SHA1 and HMAC/SHA256 acceleration found inPawel Jakub Dawidek2006-07-224-335/+766
| | | | | | | | | | | | | | new VIA CPUs. For older CPUs HMAC/SHA1 and HMAC/SHA256 (and others) will still be done in software. Move symmetric cryptography (currently only AES-CBC 128/192/256) to padlock_cipher.c file. Move HMAC cryptography to padlock_hash.c file. Hardware from: Centaur Technologies Notes: svn path=/head/; revision=160582
* Correct few bzero()s.Pawel Jakub Dawidek2006-07-221-3/+3
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=160573
* Set ses_ictx and ses_octx to NULL after freeing them, so we won't freePawel Jakub Dawidek2006-07-221-0/+2
| | | | | | | | | | | | them twice. This is possible for example in situation when session is used in authentication context, then freed and then used in encryption context and freed - in encryption context ses_ictx and ses_octx are not touched at newsession time, but padlock_freesession could still try to free them when they are not NULL. Notes: svn path=/head/; revision=160568
* Use the already stored VIA RNG probe informationMichael Reifenberger2006-07-131-16/+5
| | | | | | | | | | | instead of probing again. Adjust style(9) somewhat in probe.c Reviewed by: pjd MFC after: 1 week Notes: svn path=/head/; revision=160325
* Fix gratuitous compiler warning.Pawel Jakub Dawidek2006-06-081-1/+2
| | | | | | | Reported by: Rong-en Fan <grafan@gmail.com> Notes: svn path=/head/; revision=159405
* - Pretend to accelerate various HMAC algorithms, so padlock(4) can be usedPawel Jakub Dawidek2006-06-051-91/+266
| | | | | | | | | | | with fast_ipsec(4) and geli(8) authentication (comming soon). If consumer requests only for HMAC algorithm (without encryption), return EINVAL. - Add support for the CRD_F_KEY_EXPLICIT flag, for both encryption and authentication. Notes: svn path=/head/; revision=159279
* padlock(4) doesn't support explicitly provided keys yet.Pawel Jakub Dawidek2006-04-201-0/+4
| | | | | | | Return an error instead of encrypting/decrypting data with a wrong key. Notes: svn path=/head/; revision=157899
* On padlock initialization, allocate memory with M_WAITOK.Pawel Jakub Dawidek2006-04-121-5/+1
| | | | Notes: svn path=/head/; revision=157684