Page MenuHomeFreeBSD

openssl: build the legacy provider the way upstream does
AcceptedPublic

Authored by gordon on Tue, Oct 6, 12:15 AM.
Tags
None
Referenced Files
F175512701: D60398.id.diff
Sun, Oct 11, 8:55 AM
Unknown Object (File)
Sat, Oct 10, 3:31 AM
Unknown Object (File)
Sat, Oct 10, 3:17 AM
Unknown Object (File)
Fri, Oct 9, 9:52 PM
Unknown Object (File)
Fri, Oct 9, 7:25 AM
Unknown Object (File)
Fri, Oct 9, 2:21 AM
Unknown Object (File)
Tue, Oct 6, 3:13 PM
Unknown Object (File)
Tue, Oct 6, 1:57 PM
Subscribers

Details

Reviewers
ngie
markj
Group Reviewers
secteam
Summary
  • Build with libcrypto's compile flags: modules/Makefile.inc now includes libcrypto's Makefile.inc, which brings in Makefile.common (NDEBUG, the asm dispatch defines, OPENSSL_PIC, the directory defines). Before this change, assertions were enabled in legacy.so.
  • Use upstream's per-architecture source list: the provider's own CPU capability code (cpuid asm and armcap.c/ppccap.c, or mem_clr.c without asm), and the MD5, RC4 and DES asm where upstream uses it. The provider no longer uses libcrypto's exported RC4, SHA1 and CRYPTO_*128 functions.
  • Drop the objects that upstream's linker leaves out of legacy.so (fcrypt_b.c, md5_one.c, md5_sha1.c, provider_err.c and ciphercommon_{ccm,gcm}*.c / ciphercommon_hw.c). Without them, params_idx.c is not needed either.
  • Add a version script, a copy of upstream's providers/legacy.ld, so that only OSSL_provider_init is exported. On arm64, 209 symbols were exported before.

Tested on arm64: legacy.so builds, and its imports match upstream's
legacy.so except for the stack protector symbols. It loads with
LD_BIND_NOW=1. openssl(1) output with -provider legacy matches
upstream's for RC4, DES-EDE3-CBC, BF-CBC, CAST5-CBC, SEED-CBC and MD5,
with OPENSSL_armcap unset, 0 and 1. For the other architectures, the
source lists were compared with upstream's configuration for each one,
but nothing was built.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Did you run the smoke test under /usr/tests/secure/lib/libcrypto/ to confirm that the provider loads after this change?

secure/lib/libcrypto/modules/legacy/Makefile
25

Why was needed?

markj added a subscriber: markj.
markj added inline comments.
secure/lib/libcrypto/modules/legacy/Makefile
25

Presumably because that file uses some crypto instructions, e.g., aese, sha1h.

This revision is now accepted and ready to land.Tue, Oct 6, 2:07 PM
secure/lib/libcrypto/modules/legacy/Makefile
25

Presumably because that file uses some crypto instructions, e.g., aese, sha1h.

I understand why it might be that way, but it seems duplicative because the generated ASM file (sys/crypto/openssl/aarch64/arm64cpuid.S) specifies the target already [1]:

1 /* Do not modify. This file is auto-generated from arm64cpuid.pl. */
2 #include "arm_arch.h"
3 
4 .text
5 .arch   armv8-a+crypto

I was asking @gordon because LLMs have a tendency to introduce a ton of churn/inject a ton of unnecessary noise in changes, since they have the context frame (mind) of goldfish.

@gordon: does this build without the ACFLAGS?

  1. https://support.arm.com/documentation/dui0774/j/armclang-Integrated-Assembler/AArch64-Target-selection-directives
secure/lib/libcrypto/modules/legacy/Makefile
25

Sorry, I haven't had a chance to dig into this. I will cross verify the compilation settings for this file between upstream when I get some time.