tb [Fri, 29 Mar 2024 06:41:58 +0000 (06:41 +0000)]
Implement
Ed25519 signatures for CMS (RFC 8419)
This adds support for Edwards curve digital signature algorithms in the
cryptographic message syntax, as specified in RFC 8419. Only
Ed25519 is
supported since that is the only EdDSA algorithm that LibreSSL supports
(this is unlikely to change ever, but, as they say - never is a very
long time).
This has the usual curly interactions between EVP and CMS with poorly
documented interfaces and lots of confusing magic return values and
controls. This improves upon existing control handlers by documenting
what is being done and why. Unlike other (draft) implementations we
also happen to use the correct hashing algorithm.
There are no plans to implement RFC 8418.
joint work with job at p2k23
ok jsing
jsing [Fri, 29 Mar 2024 06:03:20 +0000 (06:03 +0000)]
Move aes_core.c to the primary Makefile.
This is now built on all platforms.
jsing [Fri, 29 Mar 2024 05:23:50 +0000 (05:23 +0000)]
Consolidate idea into a single C file.
jsing [Fri, 29 Mar 2024 05:03:48 +0000 (05:03 +0000)]
Remove unused n2ln, l2nn, n2l and l2n macros.
tb [Fri, 29 Mar 2024 04:50:11 +0000 (04:50 +0000)]
Make X509_VERIFY_PARAM_set1_policies() less bad
If any OBJ_dup() fails along the way, a partially copied policy stack
would remain on the params object. This makes no sense. Implement and
use an sk_ASN1_OBJECT_deep_copy(), that copies the full stack or else
returns NULL.
Remove unnecessary NULL check and streamline some other logic.
ok jsing
tb [Fri, 29 Mar 2024 04:45:15 +0000 (04:45 +0000)]
Clean up X509_VERIFY_PARAM_add0_policy()
Streamline some checks and use more idiomatic sk_push() error check
ok jsing
jsing [Fri, 29 Mar 2024 04:39:54 +0000 (04:39 +0000)]
Always use C functions for AES_set_{encrypt,decrypt}_key().
Always include aes_core.c and provide AES_set_{encrypt,decrypt}_key() via C
functions, which then either use a C implementation or call the assembly
implementation.
ok tb@
tb [Fri, 29 Mar 2024 04:35:42 +0000 (04:35 +0000)]
Retire mime_debug()
discussed with jsing
tb [Fri, 29 Mar 2024 03:23:01 +0000 (03:23 +0000)]
Improve error checking in i2d_ASN1_bio_stream()
The streaming BIO API is full of missing error checks. This diff reverts
the logic so that the single call to ASN1_item_i2d_bio() is error checked
(it has the usual 1/0 return values), unindents the bulk of the code and
propagates the SMIME_crlf_copy() return value (alos 1/0) to be the actual
error.
ok jsing
jsing [Fri, 29 Mar 2024 02:41:49 +0000 (02:41 +0000)]
Consolidate whirlpool into a single C file.
Buy a vowel at the same time, since we're no longer limited to 8.3 file
names.
Discussed with tb@
jsing [Fri, 29 Mar 2024 02:38:45 +0000 (02:38 +0000)]
Remove now unused assembly implementations of whirlpool.
joshua [Fri, 29 Mar 2024 02:37:20 +0000 (02:37 +0000)]
Hide symbols in Blowfish
ok jsing tb
jsg [Fri, 29 Mar 2024 02:36:49 +0000 (02:36 +0000)]
Elkhart Lake needs the 0V quirk
fixes accessing eMMC on a machine with Celeron J6413
from and tested by Sven Falempin
jsing [Fri, 29 Mar 2024 02:33:44 +0000 (02:33 +0000)]
Move wp_block.c to the primary Makefile.
This is now built on all platforms.
tb [Fri, 29 Mar 2024 02:31:22 +0000 (02:31 +0000)]
Sync EVP_MD_meth removal with what landed upstream
discussed with djm
jsing [Fri, 29 Mar 2024 02:30:25 +0000 (02:30 +0000)]
Remove CMS special now that we do not depend on pem.h being included first.
jsing [Fri, 29 Mar 2024 02:28:50 +0000 (02:28 +0000)]
Stop playing #ifdef HEADER_PEM_H games in cms.h.
Rather than making prototypes appear and disappear depending on whether
or not you've included pem.h before cms.h, just include pem.h from cms.h
itself.
ok joshua@ tb@
jsing [Fri, 29 Mar 2024 02:22:18 +0000 (02:22 +0000)]
Stop using pem2.h.
Somewhere in the past 25 years, the circular dependency between err and pem
went away. Stop pulling in pem2.h and just use pem.h directly (pem2.h can
probably be removed at some point, but that remains for another day).
ok joshua@ tb@
joshua [Fri, 29 Mar 2024 01:47:29 +0000 (01:47 +0000)]
Hide symbols in DES
ok jsing beck
jsing [Fri, 29 Mar 2024 01:27:42 +0000 (01:27 +0000)]
Rename AES_cbc_encrypt to aes_cbc_encrypt_internal for the SEH handlers.
Should fix windows build.
jsing [Fri, 29 Mar 2024 01:24:07 +0000 (01:24 +0000)]
Stop building whirlpool assembly on amd64 and i386.
This is a legacy algorithm and the assembly is only marginally faster than
the C code.
Discussed with beck@ and tb@
millert [Fri, 29 Mar 2024 01:16:30 +0000 (01:16 +0000)]
Back out tzset(3) change, it is not effective.
millert [Fri, 29 Mar 2024 01:01:00 +0000 (01:01 +0000)]
Call tzset() in main() so we don't need to check TZ repeatedly.
This has the greatest impact on makewhatis, which used to make
thousands of calls to issetugid(2) via localtime(3) and strftime(3).
Inspired by a different diff from miod@. OK miod@
tb [Fri, 29 Mar 2024 00:25:32 +0000 (00:25 +0000)]
Fix indent
jsing [Fri, 29 Mar 2024 00:16:22 +0000 (00:16 +0000)]
Apply style(9) hammer.
The code is still a horrific mess, but at least the braces are in the right
place...
joshua [Thu, 28 Mar 2024 23:54:15 +0000 (23:54 +0000)]
Hide symbols in RIPEMD
ok beck jsing
jsg [Thu, 28 Mar 2024 23:38:54 +0000 (23:38 +0000)]
Alder Lake-N eMMC needs the 0V quirk
fixes accessing eMMC on MeLE Quieter 4C
from and tested by Colin Didier
jsing [Thu, 28 Mar 2024 12:52:58 +0000 (12:52 +0000)]
Merge aes_cbc.c into aes.c now that aes_cbc.c is used on all platforms.
jsing [Thu, 28 Mar 2024 12:28:48 +0000 (12:28 +0000)]
Make AES_cbc_encrypt() always be a C function.
Rename the assembly generated functions from AES_cbc_encrypt() to
aes_cbc_encrypt_internal(). Always include aes_cbc.c and change it
to use defines that are similar to those used in BN.
ok tb@
jsing [Thu, 28 Mar 2024 12:11:26 +0000 (12:11 +0000)]
Use static inline for rc4_set_key_internal().
jsing [Thu, 28 Mar 2024 12:09:09 +0000 (12:09 +0000)]
Remove unused SM3_Transform()
Along with the misnamed SM3_transform() prototype.
jsing [Thu, 28 Mar 2024 12:04:38 +0000 (12:04 +0000)]
Rename SM3_block_data_order() and make static.
jsing [Thu, 28 Mar 2024 11:23:35 +0000 (11:23 +0000)]
Remove md32_common.h since it is now (finally) unused.
jsing [Thu, 28 Mar 2024 11:22:58 +0000 (11:22 +0000)]
Rework loads and stores for sm3.
Replace loads with crypto_load_be32toh() or be32toh(). Use
crypto_store_htobe32() or htobe32() for stores.
ok tb@
jsing [Thu, 28 Mar 2024 11:21:12 +0000 (11:21 +0000)]
Remove .init section that calls OPENSSL_cpuid_setup on i386.
OPENSSL_cpuid_setup() is already called from OPENSSL_crypto_init(), hence
we do not need or want automatic initialisation on library load.
jsing [Thu, 28 Mar 2024 11:16:32 +0000 (11:16 +0000)]
Remove .init section that calls OPENSSL_cpuid_setup on amd64.
OPENSSL_cpuid_setup() is already called from OPENSSL_crypto_init(), hence
we do not need or want automatic initialisation on library load.
ok tb@
jsing [Thu, 28 Mar 2024 10:45:30 +0000 (10:45 +0000)]
Rework loads and stores in ripemd.
Replace loads with crypto_load_le32toh() or le32toh(). Use
crypto_store_htole32() or htole32() for stores.
ok joshua@ tb@
tb [Thu, 28 Mar 2024 08:38:18 +0000 (08:38 +0000)]
Remove OPENSSL_UNISTD define
jsing [Thu, 28 Mar 2024 08:37:03 +0000 (08:37 +0000)]
Expand ROTATE macro to crypto_rol_u32().
jsing [Thu, 28 Mar 2024 08:36:13 +0000 (08:36 +0000)]
Include stdint.h since we use uint*_t types.
jsing [Thu, 28 Mar 2024 08:33:14 +0000 (08:33 +0000)]
Inline initial hash values.
jsing [Thu, 28 Mar 2024 08:31:11 +0000 (08:31 +0000)]
Remove no unnecessary do { } while (0);
jsing [Thu, 28 Mar 2024 08:30:25 +0000 (08:30 +0000)]
Inline HASH_MAKE_STRING.
No change to generated assembly.
jsing [Thu, 28 Mar 2024 08:26:42 +0000 (08:26 +0000)]
Expand HASH_* defines.
No change in generated assembly.
joshua [Thu, 28 Mar 2024 08:18:13 +0000 (08:18 +0000)]
Hide symbols in RC4
ok jsing tb beck
jsing [Thu, 28 Mar 2024 08:13:11 +0000 (08:13 +0000)]
Reorder functions.
No functional change.
jsing [Thu, 28 Mar 2024 08:04:27 +0000 (08:04 +0000)]
Tidy includes.
jsing [Thu, 28 Mar 2024 08:01:01 +0000 (08:01 +0000)]
Inline functions from md32_common.h.
No change in generated assembly.
jsing [Thu, 28 Mar 2024 08:00:07 +0000 (08:00 +0000)]
Load in the top of the loop, as we do for other hash implementations.
jsing [Thu, 28 Mar 2024 07:29:41 +0000 (07:29 +0000)]
Remove now unnecessary do { } while (0);
jsing [Thu, 28 Mar 2024 07:28:48 +0000 (07:28 +0000)]
Inline HASH_MAKE_STRING.
No change in generated assembly.
jsing [Thu, 28 Mar 2024 07:13:02 +0000 (07:13 +0000)]
Expand ROTATE macro to crypto_rol_u32().
jsing [Thu, 28 Mar 2024 07:06:12 +0000 (07:06 +0000)]
Demacro sha1.
Replace macros with static inline functions and use names that follow
the spec more closely. Unlike SHA256/SHA512, the functions and constants do
not align with the number of words loaded, which means we cannot easily loop
and just end up just unrolling everything.
ok joshua@ tb@
jsing [Thu, 28 Mar 2024 07:04:21 +0000 (07:04 +0000)]
Inline initial hash values.
jsing [Thu, 28 Mar 2024 07:03:25 +0000 (07:03 +0000)]
Clean up various defines and prototypes.
No assembly implementations remain, hence we can clean the mess up and
replace it with a single static void function.
joshua [Thu, 28 Mar 2024 06:55:02 +0000 (06:55 +0000)]
Use TLS_ERROR_INVALID_ARGUMENT for "too large" and "too small" errors
ok beck tb
beck [Thu, 28 Mar 2024 06:48:25 +0000 (06:48 +0000)]
Nuke more gost
beck [Thu, 28 Mar 2024 06:45:36 +0000 (06:45 +0000)]
Nuke more leftover GOST tendrils.
ok tb@
jsg [Thu, 28 Mar 2024 05:41:40 +0000 (05:41 +0000)]
unstub guc functions
jsg [Thu, 28 Mar 2024 05:38:36 +0000 (05:38 +0000)]
add more iosys_map interfaces used by inteldrm guc code
based in part on FreeBSD changes
jsing [Thu, 28 Mar 2024 05:21:20 +0000 (05:21 +0000)]
Tidy includes.
jsing [Thu, 28 Mar 2024 05:16:11 +0000 (05:16 +0000)]
Expand HASH_* defines.
No change to generated assembly.
jsing [Thu, 28 Mar 2024 05:00:27 +0000 (05:00 +0000)]
Reorder functions.
No functional change.
jsing [Thu, 28 Mar 2024 04:56:47 +0000 (04:56 +0000)]
Inline functions from md32_common.h for ripemd.
No change to generated assembly.
jsing [Thu, 28 Mar 2024 04:23:02 +0000 (04:23 +0000)]
Fix line wrapping.
jsg [Thu, 28 Mar 2024 02:36:38 +0000 (02:36 +0000)]
reduce diff to linux
deraadt [Thu, 28 Mar 2024 02:27:14 +0000 (02:27 +0000)]
sync
deraadt [Thu, 28 Mar 2024 02:23:31 +0000 (02:23 +0000)]
sys
deraadt [Thu, 28 Mar 2024 02:19:57 +0000 (02:19 +0000)]
Delete pinsyscall(2) [which was specific only to SYS_execve] now
that it has been replaced with pinsyscalls(2) [which tells the kernel
the location of all system calls in libc.so]
floated to various people before release, but it was prudent to wait.
jsing [Thu, 28 Mar 2024 02:09:28 +0000 (02:09 +0000)]
Remove fallback files that are now always included in the build.
joshua [Thu, 28 Mar 2024 02:08:24 +0000 (02:08 +0000)]
Use TLS_ERROR_OUT_OF_MEMORY error code for calloc errors in libtls
ok jsing
jsing [Thu, 28 Mar 2024 01:57:00 +0000 (01:57 +0000)]
Move rc4.c to primary Makefile.
This is now built on all platforms.
jsing [Thu, 28 Mar 2024 01:49:29 +0000 (01:49 +0000)]
Use C functions for RC4 public API.
Rather than having public API switch between C and assembly, always
use C functions as entry points, which then call an assembly
implementation (if available). This makes it significantly easier
to deal with symbol aliasing/namespaces and it also means we
benefit from vulnerability prevention provided by the C compiler.
Rename the assembly generated functions from RC4() to rc4_internal()
and RC4_set_key() to rc4_set_key_internal(). Always include rc4.c
and change it to use defines that are similar to those used in BN.
ok beck@ joshua@ tb@
beck [Thu, 28 Mar 2024 01:45:18 +0000 (01:45 +0000)]
Fix coverity complaints.
tb [Thu, 28 Mar 2024 01:42:02 +0000 (01:42 +0000)]
Check the return value of EVP_CIPHER_CTX_reset()
The function call can't actually fail, but all other calls check its
return value.
ok joshua jsing
jsing [Thu, 28 Mar 2024 01:41:16 +0000 (01:41 +0000)]
Move des sources to primary Makefile.
Now that all platforms use a C des implementation, move it to the primary
Makefile.
jsing [Thu, 28 Mar 2024 01:35:21 +0000 (01:35 +0000)]
Remove now unused des assembly.
jsing [Thu, 28 Mar 2024 01:34:04 +0000 (01:34 +0000)]
Stop building the assembly implementation of des on sparc64.
This one was hiding behind an m4 script.
Build tested by tb@
jsing [Thu, 28 Mar 2024 01:28:49 +0000 (01:28 +0000)]
Remove now unused ripemd i386 assembly.
jsing [Thu, 28 Mar 2024 01:14:31 +0000 (01:14 +0000)]
Stop building the assembly implementation of des and ripemd on i386.
This is the only architecture that has an assembly implementation for these
algorithms. There is little to gain from accelerating legacy algorithms on
a legacy architecture.
Discussed with beck@ and tb@
jsing [Thu, 28 Mar 2024 00:57:26 +0000 (00:57 +0000)]
Consolidate most of the AES modes into a single C file.
Discussed with tb@
tb [Thu, 28 Mar 2024 00:44:26 +0000 (00:44 +0000)]
PKCS#1.5 PBE: test and assign
beck [Thu, 28 Mar 2024 00:22:35 +0000 (00:22 +0000)]
Stop pandering to the loadbalancer industrial complex.
So we initially kept this hack around for f5 boxes that
should have been patched in 2014, and were not as of 2017.
The f5 article for the bug archived on their web site,
and any of these devices on the public internet will have
since been upgraded to deal with a host of record layer, TLS,
and other bugs, or they likely won't be talking to modern
stacks, since as of this point the software with the bug
would not have been updated in 10 years.
So just make this spec compliant and reject a supported groups
extension that should not have been sent by a server.
ok tb@ jsing@
beck [Wed, 27 Mar 2024 23:56:34 +0000 (23:56 +0000)]
fix leaks in the horrible ssl whackery necessary for this test.
ok tb@
kettenis [Wed, 27 Mar 2024 23:10:18 +0000 (23:10 +0000)]
The RISC-V architecture specification says that memory read/writes are
not ordered with respect to mmio read/writes. This appears to happen on
T-Head C920 cores as I'm seeing interrupts being enabled before the lock
is released in mtx_leave() despite program order releasing the lock
before enabling interrupts. This is fixed by adding the necessary fences
in more or less the same places where Linux uses them.
ok patrick@, jca@
kettenis [Wed, 27 Mar 2024 23:05:27 +0000 (23:05 +0000)]
Fix fdt_find_node(). We should make sure we match the full name when
matching path components (but we do allow matches with the @unit bit).
This fixes a problem on the Milk-V Pioneer where /soc/serial@123456
accidentally match a /socket0-clocks node and we would fail to find the
serial console.
ok miod@
mvs [Wed, 27 Mar 2024 22:47:53 +0000 (22:47 +0000)]
Introduce SB_OWNLOCK to mark sockets which `so_rcv' buffer modified
outside socket lock.
`sb_mtx' mutex(9) used for this case and it should not be released between
`so_rcv' usage check and corresponding sbwait() sleep. Otherwise wakeup()
could be lost sometimes.
ok bluhm
beck [Wed, 27 Mar 2024 22:27:09 +0000 (22:27 +0000)]
Fix up server processing of key shares.
Ensure that the client can not provide a duplicate key share
for any group, or send more key shares than groups they support.
Ensure that the key shares must be provided in the same order
as the client preference order specified in supported_groups.
Ensure we only will choose to use a key share that is for the
most preferred group by the client that we also support,
to avoid the client being downgraded by sending a less preferred
key share. If we do not end up with a key share for the most preferred
mutually supported group, will then do a hello retry request
selecting that group.
Add regress for this to regress/tlsext/tlsexttest.c
ok jsing@
miod [Wed, 27 Mar 2024 20:03:29 +0000 (20:03 +0000)]
When the syscall number has to be loaded from a pc-relative location,
abuse END macros to place the number at the end of the syscall wrapper
rather than in the middle of it, so that there is no need to branch
around it; this saves two instructions per syscall number >= 128.
While there, also tweak the error return (SET_ERRNO_AND_RETURN) to only
return a 64-bit value for lseek; this saves another instruction for
all other syscalls.
With input from guenther@; "Anything that makes the machine faster" deraadt@
kurt [Wed, 27 Mar 2024 15:41:40 +0000 (15:41 +0000)]
Initialize uvm_km_pages.mtx before use.
okay mpi@ miod@
kurt [Wed, 27 Mar 2024 15:40:50 +0000 (15:40 +0000)]
Initialize pmap_tramp.pm_mtx before use.
okay mpi@ miod@
patrick [Wed, 27 Mar 2024 15:15:00 +0000 (15:15 +0000)]
Support having bcmpcie(4) as both PCIe bus and simplebus to enable
use of the Raspberry Pi 5's RP1 I/O controller, which is connected
over PCIe. With this, the peripherals on the RP1 are enumerated and
attached as well.
ok kettenis@
millert [Wed, 27 Mar 2024 14:44:52 +0000 (14:44 +0000)]
printtime: use the Unix epoch if the file's timestamp is invalid
Fixes a crash in "ls -l" for files with bogus timestamp values.
OK miod@ denis@
jsing [Wed, 27 Mar 2024 12:59:12 +0000 (12:59 +0000)]
Remove unused rc4 parisc assembly.
This is already disabled since it is "about 35% slower than C code".
jsing [Wed, 27 Mar 2024 12:56:25 +0000 (12:56 +0000)]
Catch the blowfish that escaped.
jsing [Wed, 27 Mar 2024 12:54:42 +0000 (12:54 +0000)]
Consolidate rc4 code.
Discussed with tb@
jsing [Wed, 27 Mar 2024 12:42:30 +0000 (12:42 +0000)]
Remove assembly for stitched modes.
The stitched modes have been removed, so having assembly for them is of
little use.
jsing [Wed, 27 Mar 2024 12:14:35 +0000 (12:14 +0000)]
Remove empty rc4_local.h include.
Discussed with tb@
jsing [Wed, 27 Mar 2024 12:13:08 +0000 (12:13 +0000)]
Remove private_RC4_set_key() from the public rc4.h header.
This does not exist in libcrypto.
jsing [Wed, 27 Mar 2024 11:54:29 +0000 (11:54 +0000)]
Unifdef BF_PTR2.
This removes the unused Intel special version of BF_ENC().
ok tb@