aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto/sha2
Commit message (Collapse)AuthorAgeFilesLines
* crypto: Update sha256 and sha512 ifuncs to use passed HWCAP flagsSarah Walker2026-01-132-13/+4
| | | | | | Reviewed by: andrew Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D54600
* libmd: re-apply masking of _Transform namesKyle Evans2024-09-303-0/+12
| | | | | | | | | | | | Visibility can get complicated when, e.g., ifuncs are involved. In particular, SHA256/SHA512 on aarch64 use ifuncs for their _Transform implementations, which then exposes global symbols of the same name that break things trying to statically link both libcrypto and libmd. Revert this part of the _Transform removal to fix the pkg-static build on aarch64. Fixes: 81de655acd2 ("libmd: stop exporting Transform() symbols")
* libmd: stop exporting _version symbolsKyle Evans2024-09-305-24/+0
| | | | | | | | | These are reportedly likely to be specific to SSLeay's implementation and likely not needed here. At the very least they shouldn't be used by consumers, so let's kick them out now while we're already prepared for a libmd soversion bump. Requested by: delphij, fuz
* libmd: stop exporting Transform() symbolsKyle Evans2024-09-305-16/+0
| | | | | | | | | | They're not documented in libmd and we don't have any consumers. It's problematic to keep them exported, as we don't currently export their implementations. Make them all private. PR: 280784 (exp-run) Reviewed by: fuz Differential Revision: https://reviews.freebsd.org/D34503
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-272-2/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-164-8/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-165-10/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* sha512_224: Fix SHA512_224_Final() on little-endian machines.Sebastian Huber2023-02-061-5/+8
| | | | | | | PR: 266863 MFC after: 1 week Reviewed by: allanjude, cperciva, des Differential Revision: https://reviews.freebsd.org/D38372
* Add accelerated arm64 sha512 to libmdAndrew Turner2021-12-133-0/+223
| | | | | | | | | | | As with sha256 add support for accelerated sha512 support to libmd on arm64. This depends on clang 13+ to build as this is the first release with the needed intrinsics. Gcc should also support them, however from a currently unknown release. Reviewed by: cem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33373
* libmd: Only define SHA256_Transform_c when using the ARM64 ifunc.John Baldwin2021-12-081-6/+4
| | | | | | | | | | GCC 9 doesn't define a SHA256_Transform symbol when the stub just wraps SHA256_Transform_c resulting in an undefined symbol for _libmd_SHA256_Transform in libmd.so. Discussed with: andrew, jrtc27 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D31945
* Use arm64 sha256 intrinsics in libmdAndrew Turner2021-08-113-1/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When running on a CPU that supports the arm64 sha256 intrinsics use them to improve perfromance of sha256 calculations. With this changethe following improvement has been seen on an Apple M1 with FreeBS running under Parallels, with similar results on a Neoverse-N1 r3p1. x sha256.orig + sha256.arm64 +--------------------------------------------------------------------+ |++ x x| |+++ xxx| ||A |A|| +--------------------------------------------------------------------+ N Min Max Median Avg Stddev x 5 3.41 3.5 3.46 3.458 0.042661458 + 5 0.47 0.54 0.5 0.504 0.027018512 Difference at 95.0% confidence -2.954 +/- 0.0520768 -85.4251% +/- 0.826831% (Student's t, pooled s = 0.0357071) Reviewed by: cem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31284
* libmd: Always erase context in _Final method, and when doingXin LI2018-07-202-5/+5
| | | | | | | | | | | | | it, consistently use explicit_bzero(). Update manual pages to match the behavior. Reviewed by: pfg, allanjude, jmg MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D16316 Notes: svn path=/head/; revision=336539
* Implement SHA2-224 submode of SHA2-256Conrad Meyer2018-07-092-0/+154
| | | | | | | | Like SHA2-384:SHA2-512, SHA2-224 is simply a truncated SHA2-256 with a different initial vector. Add to round out the complete basic SHA2 family. Notes: svn path=/head/; revision=336123
* Fix C++ includability of crypto headers with static array sizesAlan Somers2016-10-184-5/+10
| | | | | | | | | | | | | | | | | | | | C99 allows array function parameters to use the static keyword for their sizes. This tells the compiler that the parameter will have at least the specified size, and calling code will fail to compile if that guarantee is not met. However, this syntax is not legal in C++. This commit reverts r300824, which worked around the problem for sys/sys/md5.h only, and introduces a new macro: min_size(). min_size(x) can be used in headers as a static array size, but will still compile in C++ mode. Reviewed by: cem, ed MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D8277 Notes: svn path=/head/; revision=307584
* libmd: introduce functions that operate on an fd instead of filenameEd Maste2016-10-174-0/+40
| | | | | | | | | | Reviewed by: allanjude, cem MFC after: 2 months Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8264 Notes: svn path=/head/; revision=307521
* Retune SHA2 code for improved performance on CPUs with more ILP andColin Percival2016-05-292-190/+198
| | | | | | | | | | | | | | | | | | a preference for memory load instructions over large code footprints with embedded immediate variables. On amd64 CPUs from 2007-2008 there is not a significant change, but amd64 CPUs from 2009-2010 get roughly 10% more throughput with this code; amd64 CPUs from 2011-2012 get roughly 15% more throughput; and AMD64 CPUs from 2013-2015 get 20-25% more throughput. The Raspberry Pi 2 increases its throughput by 6-8%. Sponsored by: Tarsnap Backup Inc. Performance tested by: allanjude MFC after: 3 weeks Notes: svn path=/head/; revision=300966
* Implement SHA-512 truncated (224 and 256 bits)Allan Jude2016-05-282-0/+223
| | | | | | | | | | | | | | | | | | | | | | This implements SHA-512/256, which generates a 256 bit hash by calculating the SHA-512 then truncating the result. A different initial value is used, making the result different from the first 256 bits of the SHA-512 of the same input. SHA-512 is ~50% faster than SHA-256 on 64bit platforms, so the result is a faster 256 bit hash. The main goal of this implementation is to enable support for this faster hashing algorithm in ZFS. The feature was introduced into ZFS in r289422, but is disconnected because SHA-512/256 support was missing. A further commit will enable it in ZFS. This is the follow on to r292782 Reviewed by: cem Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D6061 Notes: svn path=/head/; revision=300903
* crypto routines: Hint minimum buffer sizes to the compilerConrad Meyer2016-05-265-10/+10
| | | | | | | | | | | | | | Use the C99 'static' keyword to hint to the compiler IVs and output digest sizes. The keyword informs the compiler of the minimum valid size for a given array. Obviously not every pointer can be validated (i.e., the compiler can produce false negative but not false positive reports). No functional change. No ABI change. Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=300773
* Replace sys/crypto/sha2/sha2.c with lib/libmd/sha512c.cAllan Jude2015-12-276-800/+581
| | | | | | | | | | | | | | | | | | | | | cperciva's libmd implementation is 5-30% faster The same was done for SHA256 previously in r263218 cperciva's implementation was lacking SHA-384 which I implemented, validated against OpenSSL and the NIST documentation Extend sbin/md5 to create sha384(1) Chase dependancies on sys/crypto/sha2/sha2.{c,h} and replace them with sha512{c.c,.h} Reviewed by: cperciva, des, delphij Approved by: secteam, bapt (mentor) MFC after: 2 weeks Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D3929 Notes: svn path=/head/; revision=292782
* Complete the move that was started w/ r263218.. For some reason IJohn-Mark Gurney2015-07-112-0/+47
| | | | | | | | | | didn't delete the files, so that means we need to bring the changes in r282726 to the correct files.. make tinderbox completed with this patch... Notes: svn path=/head/; revision=285366
* replace the kernel's version w/ cperciva's implementation... In allJohn-Mark Gurney2014-03-164-404/+15
| | | | | | | | | | | | | | | | | | | | my tests, it is faster ~20%, even on an old IXP425 533MHz it is ~45% faster... This is partly due to loop unrolling, so the code size does significantly increase... I do plan on committing a version that rolls up the loops again for smaller code size for embedded systems where size is more important than absolute performance (it'll save ~6k code)... The kernel implementation is now shared w/ userland's libcrypt and libmd... We drop support for sha256 from sha2.c, so now sha2.c only contains sha384 and sha512... Reviewed by: secteam@ Notes: svn path=/head/; revision=263218
* copy these files from lib/libmd in preperation for moving these filesJohn-Mark Gurney2014-03-162-0/+347
| | | | | | | into the kernel... Notes: svn path=/head/; revision=263215
* Sync with KAME.Xin LI2013-07-092-5/+4
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=253119
* Allow assert() to operate correctly when building userland code.Robert Millan2013-07-091-1/+3
| | | | Notes: svn path=/head/; revision=253090
* 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
* Initialize T1 to silent gcc warning.Kevin Lo2006-10-221-1/+1
| | | | | | | Approved by: cognet Notes: svn path=/head/; revision=163602
* 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
* Correctly bzero the entire context, not just the first sizeof(void *) bytes.Poul-Henning Kamp2003-09-081-6/+6
| | | | | | | Found by: Juergen Buchmueller <pullmoll@stop1984.com> Notes: svn path=/head/; revision=119890
* Use __FBSDID().David E. O'Brien2003-06-101-2/+2
| | | | Notes: svn path=/head/; revision=116174
* Make this compilable from userland as well.Poul-Henning Kamp2002-11-011-0/+4
| | | | Notes: svn path=/head/; revision=106287
* Fix some really pedantic GCC warnings.Mark Murray2002-07-151-5/+5
| | | | Notes: svn path=/head/; revision=100081
* Remove __P.Alfred Perlstein2002-03-201-17/+17
| | | | Notes: svn path=/head/; revision=92756
* off by one error in Aaron Gifford's code. KAME PR 393.Hajimu UMEMOTO2002-02-261-3/+3
| | | | | | | | | PR: kern/34242 Submitted by: Aaron D. Gifford <agifford@infowest.com> MFC after: 1 week Notes: svn path=/head/; revision=91313
* less warningHajimu UMEMOTO2001-06-161-2/+2
| | | | | | | warning: cast discards qualifiers from pointer target type Notes: svn path=/head/; revision=78358
* Sync with recent KAME.Hajimu UMEMOTO2001-06-112-0/+1189
This work was based on kame-20010528-freebsd43-snap.tgz and some critical problem after the snap was out were fixed. There are many many changes since last KAME merge. TODO: - The definitions of SADB_* in sys/net/pfkeyv2.h are still different from RFC2407/IANA assignment because of binary compatibility issue. It should be fixed under 5-CURRENT. - ip6po_m member of struct ip6_pktopts is no longer used. But, it is still there because of binary compatibility issue. It should be removed under 5-CURRENT. Reviewed by: itojun Obtained from: KAME MFC after: 3 weeks Notes: svn path=/head/; revision=78064