From 6278c437f5d5c192c02dcc06aa0f9cb4f7dd46cb Mon Sep 17 00:00:00 2001 From: purplerain Date: Thu, 28 Mar 2024 20:44:33 +0000 Subject: [PATCH] sync with OpenBSD -current --- etc/skel/dot.xsession | 3 + lib/libcrypto/Makefile | 4 +- lib/libcrypto/Symbols.namespace | 42 + lib/libcrypto/aes/aes.c | 27 +- lib/libcrypto/aes/asm/aes-586.pl | 9 +- lib/libcrypto/aes/asm/aes-x86_64.pl | 21 +- lib/libcrypto/arch/aarch64/Makefile.inc | 4 +- lib/libcrypto/arch/aarch64/opensslconf.h | 3 - lib/libcrypto/arch/alpha/Makefile.inc | 4 +- lib/libcrypto/arch/alpha/opensslconf.h | 3 - lib/libcrypto/arch/amd64/Makefile.inc | 6 +- lib/libcrypto/arch/amd64/opensslconf.h | 3 - lib/libcrypto/arch/arm/Makefile.inc | 1 - lib/libcrypto/arch/arm/opensslconf.h | 3 - lib/libcrypto/arch/hppa/Makefile.inc | 4 +- lib/libcrypto/arch/hppa/opensslconf.h | 3 - lib/libcrypto/arch/i386/Makefile.inc | 5 +- lib/libcrypto/arch/i386/opensslconf.h | 3 - lib/libcrypto/arch/m88k/opensslconf.h | 3 - lib/libcrypto/arch/mips64/Makefile.inc | 3 +- lib/libcrypto/arch/mips64/opensslconf.h | 3 - lib/libcrypto/arch/powerpc/Makefile.inc | 4 +- lib/libcrypto/arch/powerpc/opensslconf.h | 3 - lib/libcrypto/arch/powerpc64/Makefile.inc | 4 +- lib/libcrypto/arch/powerpc64/opensslconf.h | 3 - lib/libcrypto/arch/riscv64/Makefile.inc | 3 +- lib/libcrypto/arch/riscv64/opensslconf.h | 3 - lib/libcrypto/arch/sh/opensslconf.h | 3 - lib/libcrypto/arch/sparc64/Makefile.inc | 4 +- lib/libcrypto/arch/sparc64/opensslconf.h | 3 - lib/libcrypto/crypto_internal.h | 3 +- lib/libcrypto/des/cbc_cksm.c | 3 +- lib/libcrypto/des/cfb64ede.c | 4 +- lib/libcrypto/des/cfb64enc.c | 3 +- lib/libcrypto/des/cfb_enc.c | 3 +- lib/libcrypto/des/des_enc.c | 7 +- lib/libcrypto/des/ecb3_enc.c | 3 +- lib/libcrypto/des/ecb_enc.c | 3 +- lib/libcrypto/des/ede_cbcm_enc.c | 3 +- lib/libcrypto/des/enc_read.c | 3 +- lib/libcrypto/des/enc_writ.c | 3 +- lib/libcrypto/des/fcrypt.c | 4 +- lib/libcrypto/des/ncbc_enc.c | 7 +- lib/libcrypto/des/ofb64ede.c | 3 +- lib/libcrypto/des/ofb64enc.c | 3 +- lib/libcrypto/des/ofb_enc.c | 3 +- lib/libcrypto/des/pcbc_enc.c | 3 +- lib/libcrypto/des/qud_cksm.c | 3 +- lib/libcrypto/des/set_key.c | 10 +- lib/libcrypto/des/str2key.c | 4 +- lib/libcrypto/des/xcbc_enc.c | 3 +- lib/libcrypto/hidden/openssl/des.h | 64 + lib/libcrypto/hidden/openssl/rc4.h | 31 + lib/libcrypto/hidden/openssl/ripemd.h | 34 + lib/libcrypto/md32_common.h | 309 ---- lib/libcrypto/md4/md4.c | 20 +- lib/libcrypto/md5/md5.c | 20 +- lib/libcrypto/rc4/rc4.c | 6 +- lib/libcrypto/ripemd/ripemd.c | 287 ++-- lib/libcrypto/sha/sha1.c | 390 +++-- lib/libcrypto/sha/sha256.c | 10 +- lib/libcrypto/sm3/sm3.c | 246 ++- lib/libcrypto/whrlpool/wp_dgst.c | 245 ++- lib/libcrypto/x509/x509_vpm.c | 4 +- lib/libcrypto/x86_64cpuid.pl | 10 - lib/libcrypto/x86cpuid.pl | 4 - lib/libtls/tls_config.c | 11 +- lib/libtls/tls_signer.c | 6 +- regress/lib/libcrypto/Makefile | 3 +- regress/lib/libcrypto/gost/Makefile | 9 - regress/lib/libcrypto/gost/gost2814789t.c | 1486 ----------------- sys/dev/pci/drm/i915/gt/uc/intel_guc_ads.c | 65 +- .../pci/drm/i915/gt/uc/intel_guc_submission.c | 10 - sys/dev/pci/drm/include/linux/iosys-map.h | 58 + sys/dev/pci/sdhc_pci.c | 5 +- usr.bin/mandoc/main.c | 2 +- 76 files changed, 1108 insertions(+), 2495 deletions(-) create mode 100644 lib/libcrypto/hidden/openssl/des.h create mode 100644 lib/libcrypto/hidden/openssl/rc4.h create mode 100644 lib/libcrypto/hidden/openssl/ripemd.h delete mode 100644 lib/libcrypto/md32_common.h delete mode 100644 regress/lib/libcrypto/gost/Makefile delete mode 100644 regress/lib/libcrypto/gost/gost2814789t.c diff --git a/etc/skel/dot.xsession b/etc/skel/dot.xsession index ec516fc40..0154d5907 100644 --- a/etc/skel/dot.xsession +++ b/etc/skel/dot.xsession @@ -2,6 +2,9 @@ # # This file is for testing purposes only. +export LANG=en_US.UTF-8 +export LC_CTYPE=en_US.UTF-8 + xset b 0 0 0 if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 17aaab3a9..918454e7a 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.183 2024/03/28 02:09:28 jsing Exp $ +# $OpenBSD: Makefile,v 1.185 2024/03/28 12:52:58 jsing Exp $ LIB= crypto LIBREBUILD=y @@ -644,7 +644,6 @@ SRCS+= x_all.c ${LCRYPTO_SRC}/engine \ ${LCRYPTO_SRC}/err \ ${LCRYPTO_SRC}/evp \ - ${LCRYPTO_SRC}/gost \ ${LCRYPTO_SRC}/hkdf \ ${LCRYPTO_SRC}/hmac \ ${LCRYPTO_SRC}/idea \ @@ -790,7 +789,6 @@ obj_dat.h: obj_mac.h ${SSL_OBJECTS}/obj_dat.pl .else CFLAGS+=-DOPENSSL_NO_ASM SRCS+= aes_core.c -SRCS+= aes_cbc.c SRCS+= camellia.c SRCS+= cmll_cbc.c SRCS+= cmll_misc.c diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index adb4330f0..336989e98 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -2542,3 +2542,45 @@ _libre_ENGINE_ctrl_cmd _libre_ENGINE_ctrl_cmd_string _libre_ENGINE_load_private_key _libre_ENGINE_load_public_key +_libre_RC4_set_key +_libre_RC4 +_libre_RIPEMD160_Init +_libre_RIPEMD160_Update +_libre_RIPEMD160_Final +_libre_RIPEMD160 +_libre_RIPEMD160_Transform +_libre_DES_ecb3_encrypt +_libre_DES_cbc_cksum +_libre_DES_cbc_encrypt +_libre_DES_ncbc_encrypt +_libre_DES_xcbc_encrypt +_libre_DES_cfb_encrypt +_libre_DES_ecb_encrypt +_libre_DES_encrypt1 +_libre_DES_encrypt2 +_libre_DES_encrypt3 +_libre_DES_decrypt3 +_libre_DES_ede3_cbc_encrypt +_libre_DES_ede3_cbcm_encrypt +_libre_DES_ede3_cfb64_encrypt +_libre_DES_ede3_cfb_encrypt +_libre_DES_ede3_ofb64_encrypt +_libre_DES_enc_read +_libre_DES_enc_write +_libre_DES_fcrypt +_libre_DES_crypt +_libre_DES_ofb_encrypt +_libre_DES_pcbc_encrypt +_libre_DES_quad_cksum +_libre_DES_random_key +_libre_DES_set_odd_parity +_libre_DES_check_key_parity +_libre_DES_is_weak_key +_libre_DES_set_key +_libre_DES_key_sched +_libre_DES_set_key_checked +_libre_DES_set_key_unchecked +_libre_DES_string_to_key +_libre_DES_string_to_2keys +_libre_DES_cfb64_encrypt +_libre_DES_ofb64_encrypt diff --git a/lib/libcrypto/aes/aes.c b/lib/libcrypto/aes/aes.c index d3bf85947..9b25a21f4 100644 --- a/lib/libcrypto/aes/aes.c +++ b/lib/libcrypto/aes/aes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aes.c,v 1.1 2024/03/28 00:57:26 jsing Exp $ */ +/* $OpenBSD: aes.c,v 1.2 2024/03/28 12:52:58 jsing Exp $ */ /* ==================================================================== * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. * @@ -59,6 +59,31 @@ static const unsigned char aes_wrap_default_iv[] = { 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, }; +#ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL +void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, const int enc); + +#else +static inline void +aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, const int enc) +{ + if (enc) + CRYPTO_cbc128_encrypt(in, out, len, key, ivec, + (block128_f)AES_encrypt); + else + CRYPTO_cbc128_decrypt(in, out, len, key, ivec, + (block128_f)AES_decrypt); +} +#endif + +void +AES_cbc_encrypt(const unsigned char *in, unsigned char *out, + size_t len, const AES_KEY *key, unsigned char *ivec, const int enc) +{ + aes_cbc_encrypt_internal(in, out, len, key, ivec, enc); +} + /* * The input and output encrypted as though 128bit cfb mode is being * used. The extra state information to record how much of the diff --git a/lib/libcrypto/aes/asm/aes-586.pl b/lib/libcrypto/aes/asm/aes-586.pl index 45291724a..c7fd0cc78 100644 --- a/lib/libcrypto/aes/asm/aes-586.pl +++ b/lib/libcrypto/aes/asm/aes-586.pl @@ -2004,9 +2004,8 @@ sub declast() &mov (&DWP(12,$acc),$s3); &function_end("AES_decrypt"); -# void AES_cbc_encrypt (const void char *inp, unsigned char *out, -# size_t length, const AES_KEY *key, -# unsigned char *ivp,const int enc); +# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out, +# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc); { # stack frame layout # -4(%esp) # return address 0(%esp) @@ -2029,7 +2028,7 @@ my $ivec=&DWP(60,"esp"); # ivec[16] my $aes_key=&DWP(76,"esp"); # copy of aes_key my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds -&function_begin("AES_cbc_encrypt"); +&function_begin("aes_cbc_encrypt_internal"); &mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len &cmp ($s2,0); &je (&label("drop_out")); @@ -2617,7 +2616,7 @@ my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds &mov ("esp",$_esp); &popf (); -&function_end("AES_cbc_encrypt"); +&function_end("aes_cbc_encrypt_internal"); } #------------------------------------------------------------------# diff --git a/lib/libcrypto/aes/asm/aes-x86_64.pl b/lib/libcrypto/aes/asm/aes-x86_64.pl index 70ec2e34e..9f51bac24 100755 --- a/lib/libcrypto/aes/asm/aes-x86_64.pl +++ b/lib/libcrypto/aes/asm/aes-x86_64.pl @@ -1641,9 +1641,8 @@ $code.=<<___; .size AES_set_decrypt_key,.-AES_set_decrypt_key ___ -# void AES_cbc_encrypt (const void char *inp, unsigned char *out, -# size_t length, const AES_KEY *key, -# unsigned char *ivp,const int enc); +# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out, +# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc); { # stack frame layout # -8(%rsp) return address @@ -1660,15 +1659,15 @@ my $aes_key="80(%rsp)"; # copy of aes_key my $mark="80+240(%rsp)"; # copy of aes_key->rounds $code.=<<___; -.globl AES_cbc_encrypt -.type AES_cbc_encrypt,\@function,6 +.globl aes_cbc_encrypt_internal +.type aes_cbc_encrypt_internal,\@function,6 .align 16 .extern OPENSSL_ia32cap_P .hidden OPENSSL_ia32cap_P .globl asm_AES_cbc_encrypt .hidden asm_AES_cbc_encrypt asm_AES_cbc_encrypt: -AES_cbc_encrypt: +aes_cbc_encrypt_internal: _CET_ENDBR cmp \$0,%rdx # check length je .Lcbc_epilogue @@ -2118,7 +2117,7 @@ AES_cbc_encrypt: popfq .Lcbc_epilogue: ret -.size AES_cbc_encrypt,.-AES_cbc_encrypt +.size aes_cbc_encrypt_internal,.-aes_cbc_encrypt_internal ___ } @@ -2799,9 +2798,9 @@ cbc_se_handler: .rva .LSEH_end_AES_set_decrypt_key .rva .LSEH_info_AES_set_decrypt_key - .rva .LSEH_begin_AES_cbc_encrypt - .rva .LSEH_end_AES_cbc_encrypt - .rva .LSEH_info_AES_cbc_encrypt + .rva .LSEH_begin_aes_cbc_encrypt_internal + .rva .LSEH_end_aes_cbc_encrypt_internal + .rva .LSEH_info_aes_cbc_encrypt_internal .section .xdata .align 8 @@ -2821,7 +2820,7 @@ cbc_se_handler: .byte 9,0,0,0 .rva key_se_handler .rva .Ldec_key_prologue,.Ldec_key_epilogue # HandlerData[] -.LSEH_info_AES_cbc_encrypt: +.LSEH_info_aes_cbc_encrypt_internal: .byte 9,0,0,0 .rva cbc_se_handler ___ diff --git a/lib/libcrypto/arch/aarch64/Makefile.inc b/lib/libcrypto/arch/aarch64/Makefile.inc index d9ab7789b..6f57fa230 100644 --- a/lib/libcrypto/arch/aarch64/Makefile.inc +++ b/lib/libcrypto/arch/aarch64/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.9 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.10 2024/03/28 12:52:58 jsing Exp $ # aarch64-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c # bn # camellia SRCS+= camellia.c cmll_cbc.c cmll_misc.c diff --git a/lib/libcrypto/arch/aarch64/opensslconf.h b/lib/libcrypto/arch/aarch64/opensslconf.h index 204eb505a..d658f297a 100644 --- a/lib/libcrypto/arch/aarch64/opensslconf.h +++ b/lib/libcrypto/arch/aarch64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/alpha/Makefile.inc b/lib/libcrypto/arch/alpha/Makefile.inc index 2a3bf263b..ac8314563 100644 --- a/lib/libcrypto/arch/alpha/Makefile.inc +++ b/lib/libcrypto/arch/alpha/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.10 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.11 2024/03/28 12:52:58 jsing Exp $ # alpha-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c # bn SSLASM+= bn alpha-mont CFLAGS+= -DOPENSSL_BN_ASM_MONT diff --git a/lib/libcrypto/arch/alpha/opensslconf.h b/lib/libcrypto/arch/alpha/opensslconf.h index b9ca2ddf8..6db55ca8c 100644 --- a/lib/libcrypto/arch/alpha/opensslconf.h +++ b/lib/libcrypto/arch/alpha/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/amd64/Makefile.inc b/lib/libcrypto/arch/amd64/Makefile.inc index 40ba3c063..8ae28f16e 100644 --- a/lib/libcrypto/arch/amd64/Makefile.inc +++ b/lib/libcrypto/arch/amd64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.18 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.21 2024/03/29 01:24:07 jsing Exp $ # amd64-specific libcrypto build rules @@ -13,6 +13,7 @@ SSLASM+= aes bsaes-x86_64 CFLAGS+= -DVPAES_ASM SSLASM+= aes vpaes-x86_64 SSLASM+= aes aesni-x86_64 +CFLAGS+= -DHAVE_AES_CBC_ENCRYPT_INTERNAL # bn CFLAGS+= -DOPENSSL_IA32_SSE2 CFLAGS+= -DRSA_ASM @@ -66,8 +67,7 @@ sha512-x86_64.S: ${LCRYPTO_SRC}/sha/asm/sha512-x86_64.pl ${EXTRA_PL} cd ${LCRYPTO_SRC}/sha/asm ; \ /usr/bin/perl ./sha512-x86_64.pl ${.OBJDIR}/${.TARGET} # whrlpool -CFLAGS+= -DWHIRLPOOL_ASM -SSLASM+= whrlpool wp-x86_64 +SRCS+= wp_block.c .for dir f in ${SSLASM} SRCS+= ${f}.S diff --git a/lib/libcrypto/arch/amd64/opensslconf.h b/lib/libcrypto/arch/amd64/opensslconf.h index 4ea0426df..fe2b9336b 100644 --- a/lib/libcrypto/arch/amd64/opensslconf.h +++ b/lib/libcrypto/arch/amd64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/arm/Makefile.inc b/lib/libcrypto/arch/arm/Makefile.inc index e7631c99c..b0d125572 100644 --- a/lib/libcrypto/arch/arm/Makefile.inc +++ b/lib/libcrypto/arch/arm/Makefile.inc @@ -3,7 +3,6 @@ # arm-specific libcrypto build rules # aes -SRCS+= aes_cbc.c CFLAGS+= -DAES_ASM SSLASM+= aes aes-armv4 # bn diff --git a/lib/libcrypto/arch/arm/opensslconf.h b/lib/libcrypto/arch/arm/opensslconf.h index e9b744c0a..dd0bfe233 100644 --- a/lib/libcrypto/arch/arm/opensslconf.h +++ b/lib/libcrypto/arch/arm/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/hppa/Makefile.inc b/lib/libcrypto/arch/hppa/Makefile.inc index 7ef95002b..bbe4c9ac1 100644 --- a/lib/libcrypto/arch/hppa/Makefile.inc +++ b/lib/libcrypto/arch/hppa/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.19 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.20 2024/03/28 12:52:58 jsing Exp $ # hppa-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c CFLAGS+= -DAES_ASM SSLASM+= aes aes-parisc aes-parisc # bn diff --git a/lib/libcrypto/arch/hppa/opensslconf.h b/lib/libcrypto/arch/hppa/opensslconf.h index e9b744c0a..dd0bfe233 100644 --- a/lib/libcrypto/arch/hppa/opensslconf.h +++ b/lib/libcrypto/arch/hppa/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/i386/Makefile.inc b/lib/libcrypto/arch/i386/Makefile.inc index aedd1d768..9da377a3c 100644 --- a/lib/libcrypto/arch/i386/Makefile.inc +++ b/lib/libcrypto/arch/i386/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.15 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.18 2024/03/29 01:24:07 jsing Exp $ # i386-specific libcrypto build rules @@ -11,6 +11,7 @@ SSLASM+= aes aes-586 CFLAGS+= -DVPAES_ASM SSLASM+= aes vpaes-x86 SSLASM+= aes aesni-x86 +CFLAGS+= -DHAVE_AES_CBC_ENCRYPT_INTERNAL # bn CFLAGS+= -DOPENSSL_IA32_SSE2 SSLASM+= bn bn-586 @@ -38,8 +39,6 @@ CFLAGS+= -DSHA512_ASM SSLASM+= sha sha512-586 # whrlpool SRCS+= wp_block.c -CFLAGS+= -DWHIRLPOOL_ASM -SSLASM+= whrlpool wp-mmx .for dir f in ${SSLASM} SRCS+= ${f}.S diff --git a/lib/libcrypto/arch/i386/opensslconf.h b/lib/libcrypto/arch/i386/opensslconf.h index 96b526ae4..c31d7745a 100644 --- a/lib/libcrypto/arch/i386/opensslconf.h +++ b/lib/libcrypto/arch/i386/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/m88k/opensslconf.h b/lib/libcrypto/arch/m88k/opensslconf.h index e9b744c0a..dd0bfe233 100644 --- a/lib/libcrypto/arch/m88k/opensslconf.h +++ b/lib/libcrypto/arch/m88k/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/mips64/Makefile.inc b/lib/libcrypto/arch/mips64/Makefile.inc index e8f39de7d..d40bbdf00 100644 --- a/lib/libcrypto/arch/mips64/Makefile.inc +++ b/lib/libcrypto/arch/mips64/Makefile.inc @@ -1,9 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.11 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.12 2024/03/28 12:52:58 jsing Exp $ # mips64-specific libcrypto build rules # aes -SRCS+= aes_cbc.c CFLAGS+= -DAES_ASM SSLASM+= aes aes-mips aes-mips # bn diff --git a/lib/libcrypto/arch/mips64/opensslconf.h b/lib/libcrypto/arch/mips64/opensslconf.h index bcd2ecf38..c6a94d0dc 100644 --- a/lib/libcrypto/arch/mips64/opensslconf.h +++ b/lib/libcrypto/arch/mips64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/powerpc/Makefile.inc b/lib/libcrypto/arch/powerpc/Makefile.inc index 510b9a9c1..9e3a2f728 100644 --- a/lib/libcrypto/arch/powerpc/Makefile.inc +++ b/lib/libcrypto/arch/powerpc/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.8 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.9 2024/03/28 12:52:58 jsing Exp $ # powerpc-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c # slower than C code #CFLAGS+= -DAES_ASM #SSLASM+= aes aes-ppc aes-ppc diff --git a/lib/libcrypto/arch/powerpc/opensslconf.h b/lib/libcrypto/arch/powerpc/opensslconf.h index e9b744c0a..dd0bfe233 100644 --- a/lib/libcrypto/arch/powerpc/opensslconf.h +++ b/lib/libcrypto/arch/powerpc/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/powerpc64/Makefile.inc b/lib/libcrypto/arch/powerpc64/Makefile.inc index f7b10d193..ea466bb8a 100644 --- a/lib/libcrypto/arch/powerpc64/Makefile.inc +++ b/lib/libcrypto/arch/powerpc64/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.10 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.11 2024/03/28 12:52:58 jsing Exp $ # powerpc-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c # slower than C code #CFLAGS+= -DAES_ASM #SSLASM+= aes aes-ppc aes-ppc diff --git a/lib/libcrypto/arch/powerpc64/opensslconf.h b/lib/libcrypto/arch/powerpc64/opensslconf.h index 4ea0426df..fe2b9336b 100644 --- a/lib/libcrypto/arch/powerpc64/opensslconf.h +++ b/lib/libcrypto/arch/powerpc64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/riscv64/Makefile.inc b/lib/libcrypto/arch/riscv64/Makefile.inc index 909cc2182..0737d3ce1 100644 --- a/lib/libcrypto/arch/riscv64/Makefile.inc +++ b/lib/libcrypto/arch/riscv64/Makefile.inc @@ -1,10 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.6 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2024/03/28 12:52:58 jsing Exp $ # riscv64 libcrypto build rules # aes SRCS+= aes_core.c -SRCS+= aes_cbc.c # camellia SRCS+= camellia.c diff --git a/lib/libcrypto/arch/riscv64/opensslconf.h b/lib/libcrypto/arch/riscv64/opensslconf.h index 204eb505a..d658f297a 100644 --- a/lib/libcrypto/arch/riscv64/opensslconf.h +++ b/lib/libcrypto/arch/riscv64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/sh/opensslconf.h b/lib/libcrypto/arch/sh/opensslconf.h index e9b744c0a..dd0bfe233 100644 --- a/lib/libcrypto/arch/sh/opensslconf.h +++ b/lib/libcrypto/arch/sh/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/arch/sparc64/Makefile.inc b/lib/libcrypto/arch/sparc64/Makefile.inc index 3d047e4a4..e540fcbbb 100644 --- a/lib/libcrypto/arch/sparc64/Makefile.inc +++ b/lib/libcrypto/arch/sparc64/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.13 2024/03/28 01:57:00 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.14 2024/03/28 12:52:58 jsing Exp $ # sparc64-specific libcrypto build rules # aes -SRCS+= aes_core.c aes_cbc.c +SRCS+= aes_core.c CFLAGS+= -DAES_ASM SSLASM+= aes aes-sparcv9 aes-sparcv9 # bn diff --git a/lib/libcrypto/arch/sparc64/opensslconf.h b/lib/libcrypto/arch/sparc64/opensslconf.h index bcd2ecf38..c6a94d0dc 100644 --- a/lib/libcrypto/arch/sparc64/opensslconf.h +++ b/lib/libcrypto/arch/sparc64/opensslconf.h @@ -5,9 +5,6 @@ #define OPENSSLDIR "/etc/ssl" #endif -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD - #undef OPENSSL_EXPORT_VAR_AS_FUNCTION #if defined(HEADER_IDEA_H) && !defined(IDEA_INT) diff --git a/lib/libcrypto/crypto_internal.h b/lib/libcrypto/crypto_internal.h index 5e21535f3..924cf6db4 100644 --- a/lib/libcrypto/crypto_internal.h +++ b/lib/libcrypto/crypto_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_internal.h,v 1.8 2024/03/26 04:11:42 jsing Exp $ */ +/* $OpenBSD: crypto_internal.h,v 1.9 2024/03/28 08:36:13 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -17,6 +17,7 @@ #include #include +#include #include #ifndef HEADER_CRYPTO_INTERNAL_H diff --git a/lib/libcrypto/des/cbc_cksm.c b/lib/libcrypto/des/cbc_cksm.c index afa3f03d9..acb0bac11 100644 --- a/lib/libcrypto/des/cbc_cksm.c +++ b/lib/libcrypto/des/cbc_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cbc_cksm.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: cbc_cksm.c,v 1.11 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -103,3 +103,4 @@ DES_cbc_cksum(const unsigned char *in, DES_cblock *output, ((tout1 << 24L) & 0xFF000000); return (tout1); } +LCRYPTO_ALIAS(DES_cbc_cksum); diff --git a/lib/libcrypto/des/cfb64ede.c b/lib/libcrypto/des/cfb64ede.c index e91dbbfc4..69a6c2540 100644 --- a/lib/libcrypto/des/cfb64ede.c +++ b/lib/libcrypto/des/cfb64ede.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb64ede.c,v 1.12 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: cfb64ede.c,v 1.13 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -125,6 +125,7 @@ DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, v0 = v1 = ti[0] = ti[1] = c = cc = 0; *num = n; } +LCRYPTO_ALIAS(DES_ede3_cfb64_encrypt); /* This is compatible with the single key CFB-r for DES, even thought that's * not what EVP needs. @@ -238,3 +239,4 @@ DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, l2c(v1, iv); v0 = v1 = d0 = d1 = ti[0] = ti[1] = 0; } +LCRYPTO_ALIAS(DES_ede3_cfb_encrypt); diff --git a/lib/libcrypto/des/cfb64enc.c b/lib/libcrypto/des/cfb64enc.c index d7434b9db..d2d0dadf1 100644 --- a/lib/libcrypto/des/cfb64enc.c +++ b/lib/libcrypto/des/cfb64enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb64enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: cfb64enc.c,v 1.9 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -120,3 +120,4 @@ DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, v0 = v1 = ti[0] = ti[1] = c = cc = 0; *num = n; } +LCRYPTO_ALIAS(DES_cfb64_encrypt); diff --git a/lib/libcrypto/des/cfb_enc.c b/lib/libcrypto/des/cfb_enc.c index dac86751d..ae41c9d07 100644 --- a/lib/libcrypto/des/cfb_enc.c +++ b/lib/libcrypto/des/cfb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cfb_enc.c,v 1.16 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: cfb_enc.c,v 1.17 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -187,3 +187,4 @@ DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, l2c(v1, iv); v0 = v1 = d0 = d1 = ti[0] = ti[1] = 0; } +LCRYPTO_ALIAS(DES_cfb_encrypt); diff --git a/lib/libcrypto/des/des_enc.c b/lib/libcrypto/des/des_enc.c index 7319639c8..f332b9a43 100644 --- a/lib/libcrypto/des/des_enc.c +++ b/lib/libcrypto/des/des_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: des_enc.c,v 1.15 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: des_enc.c,v 1.16 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -150,6 +150,7 @@ DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc) data[1] = r; l = r = t = u = 0; } +LCRYPTO_ALIAS(DES_encrypt1); void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) @@ -233,6 +234,7 @@ DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) data[1] = ROTATE(r, 3) & 0xffffffffL; l = r = t = u = 0; } +LCRYPTO_ALIAS(DES_encrypt2); #endif /* OPENBSD_DES_ASM */ @@ -256,6 +258,7 @@ DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, data[0] = l; data[1] = r; } +LCRYPTO_ALIAS(DES_encrypt3); void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, @@ -277,6 +280,7 @@ DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, data[0] = l; data[1] = r; } +LCRYPTO_ALIAS(DES_decrypt3); #ifndef DES_DEFAULT_OPTIONS @@ -388,5 +392,6 @@ DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; tin[0] = tin[1] = 0; } +LCRYPTO_ALIAS(DES_ede3_cbc_encrypt); #endif /* DES_DEFAULT_OPTIONS */ diff --git a/lib/libcrypto/des/ecb3_enc.c b/lib/libcrypto/des/ecb3_enc.c index 129b5fafe..2aa63726e 100644 --- a/lib/libcrypto/des/ecb3_enc.c +++ b/lib/libcrypto/des/ecb3_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecb3_enc.c,v 1.9 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ecb3_enc.c,v 1.10 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -82,3 +82,4 @@ DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, l2c(l0, out); l2c(l1, out); } +LCRYPTO_ALIAS(DES_ecb3_encrypt); diff --git a/lib/libcrypto/des/ecb_enc.c b/lib/libcrypto/des/ecb_enc.c index 3599fb812..2491c4318 100644 --- a/lib/libcrypto/des/ecb_enc.c +++ b/lib/libcrypto/des/ecb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecb_enc.c,v 1.19 2023/07/31 05:04:06 tb Exp $ */ +/* $OpenBSD: ecb_enc.c,v 1.20 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -80,3 +80,4 @@ DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, l2c(l, out); l = ll[0] = ll[1] = 0; } +LCRYPTO_ALIAS(DES_ecb_encrypt); diff --git a/lib/libcrypto/des/ede_cbcm_enc.c b/lib/libcrypto/des/ede_cbcm_enc.c index eb6fd4f54..979600e54 100644 --- a/lib/libcrypto/des/ede_cbcm_enc.c +++ b/lib/libcrypto/des/ede_cbcm_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ede_cbcm_enc.c,v 1.9 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: ede_cbcm_enc.c,v 1.10 2024/03/29 01:47:29 joshua Exp $ */ /* Written by Ben Laurie for the OpenSSL * project 13 Feb 1999. */ @@ -186,4 +186,5 @@ DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; tin[0] = tin[1] = 0; } +LCRYPTO_ALIAS(DES_ede3_cbcm_encrypt); #endif diff --git a/lib/libcrypto/des/enc_read.c b/lib/libcrypto/des/enc_read.c index 8095f265c..d52489e72 100644 --- a/lib/libcrypto/des/enc_read.c +++ b/lib/libcrypto/des/enc_read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc_read.c,v 1.17 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: enc_read.c,v 1.18 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -220,3 +220,4 @@ DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, } return num; } +LCRYPTO_ALIAS(DES_enc_read); diff --git a/lib/libcrypto/des/enc_writ.c b/lib/libcrypto/des/enc_writ.c index 3def8a8d7..39c613936 100644 --- a/lib/libcrypto/des/enc_writ.c +++ b/lib/libcrypto/des/enc_writ.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc_writ.c,v 1.17 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: enc_writ.c,v 1.18 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -165,3 +165,4 @@ DES_enc_write(int fd, const void *_buf, int len, return (len); } +LCRYPTO_ALIAS(DES_enc_write); diff --git a/lib/libcrypto/des/fcrypt.c b/lib/libcrypto/des/fcrypt.c index b183ceef1..5bdf09b7e 100644 --- a/lib/libcrypto/des/fcrypt.c +++ b/lib/libcrypto/des/fcrypt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fcrypt.c,v 1.15 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: fcrypt.c,v 1.16 2024/03/29 01:47:29 joshua Exp $ */ #include @@ -58,6 +58,7 @@ DES_crypt(const char *buf, const char *salt) return (DES_fcrypt(buf, salt, buff)); } +LCRYPTO_ALIAS(DES_crypt); char * DES_fcrypt(const char *buf, const char *salt, char *ret) @@ -123,3 +124,4 @@ r=(r+7)/8; ret[13] = '\0'; return (ret); } +LCRYPTO_ALIAS(DES_fcrypt); diff --git a/lib/libcrypto/des/ncbc_enc.c b/lib/libcrypto/des/ncbc_enc.c index c4da94c48..1a49126b6 100644 --- a/lib/libcrypto/des/ncbc_enc.c +++ b/lib/libcrypto/des/ncbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncbc_enc.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: ncbc_enc.c,v 1.11 2024/03/29 01:47:29 joshua Exp $ */ /* * #included by: * cbc_enc.c (DES_cbc_encrypt) @@ -153,3 +153,8 @@ DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, tin0 = tin1 = tout0 = tout1 = xor0 = xor1 = 0; tin[0] = tin[1] = 0; } +#ifdef CBC_ENC_C__DONT_UPDATE_IV +LCRYPTO_ALIAS(DES_cbc_encrypt); +#else +LCRYPTO_ALIAS(DES_ncbc_encrypt); +#endif diff --git a/lib/libcrypto/des/ofb64ede.c b/lib/libcrypto/des/ofb64ede.c index 2922fc77f..949b22047 100644 --- a/lib/libcrypto/des/ofb64ede.c +++ b/lib/libcrypto/des/ofb64ede.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb64ede.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ofb64ede.c,v 1.9 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -110,3 +110,4 @@ DES_ede3_ofb64_encrypt(const unsigned char *in, v0 = v1 = ti[0] = ti[1] = 0; *num = n; } +LCRYPTO_ALIAS(DES_ede3_ofb64_encrypt); diff --git a/lib/libcrypto/des/ofb64enc.c b/lib/libcrypto/des/ofb64enc.c index c3b1b8af8..5e524dd9e 100644 --- a/lib/libcrypto/des/ofb64enc.c +++ b/lib/libcrypto/des/ofb64enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb64enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ofb64enc.c,v 1.9 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -107,3 +107,4 @@ DES_ofb64_encrypt(const unsigned char *in, t = v0 = v1 = ti[0] = ti[1] = 0; *num = n; } +LCRYPTO_ALIAS(DES_ofb64_encrypt); diff --git a/lib/libcrypto/des/ofb_enc.c b/lib/libcrypto/des/ofb_enc.c index 990b927eb..96dc25ee2 100644 --- a/lib/libcrypto/des/ofb_enc.c +++ b/lib/libcrypto/des/ofb_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofb_enc.c,v 1.8 2023/07/08 07:11:07 beck Exp $ */ +/* $OpenBSD: ofb_enc.c,v 1.9 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -131,3 +131,4 @@ DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, l2c(v1, iv); v0 = v1 = d0 = d1 = ti[0] = ti[1] = vv0 = vv1 = 0; } +LCRYPTO_ALIAS(DES_ofb_encrypt); diff --git a/lib/libcrypto/des/pcbc_enc.c b/lib/libcrypto/des/pcbc_enc.c index 3a420f013..defd628d4 100644 --- a/lib/libcrypto/des/pcbc_enc.c +++ b/lib/libcrypto/des/pcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcbc_enc.c,v 1.9 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: pcbc_enc.c,v 1.10 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -114,3 +114,4 @@ DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, tin[0] = tin[1] = 0; sin0 = sin1 = xor0 = xor1 = tout0 = tout1 = 0; } +LCRYPTO_ALIAS(DES_pcbc_encrypt); diff --git a/lib/libcrypto/des/qud_cksm.c b/lib/libcrypto/des/qud_cksm.c index ab2866826..4ded2a05b 100644 --- a/lib/libcrypto/des/qud_cksm.c +++ b/lib/libcrypto/des/qud_cksm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qud_cksm.c,v 1.10 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: qud_cksm.c,v 1.11 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -123,3 +123,4 @@ DES_quad_cksum(const unsigned char *input, DES_cblock output[], } return (z0); } +LCRYPTO_ALIAS(DES_quad_cksum); diff --git a/lib/libcrypto/des/set_key.c b/lib/libcrypto/des/set_key.c index 8ae40a81c..0e7aab688 100644 --- a/lib/libcrypto/des/set_key.c +++ b/lib/libcrypto/des/set_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: set_key.c,v 1.26 2023/12/20 06:30:04 tb Exp $ */ +/* $OpenBSD: set_key.c,v 1.27 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -91,6 +91,7 @@ DES_set_odd_parity(DES_cblock *key) for (i = 0; i < DES_KEY_SZ; i++) (*key)[i] = odd_parity[(*key)[i]]; } +LCRYPTO_ALIAS(DES_set_odd_parity); int DES_check_key_parity(const_DES_cblock *key) @@ -103,6 +104,7 @@ DES_check_key_parity(const_DES_cblock *key) } return (1); } +LCRYPTO_ALIAS(DES_check_key_parity); /* Weak and semi weak keys as taken from * %A D.W. Davies @@ -145,6 +147,7 @@ DES_is_weak_key(const_DES_cblock *key) return 1; return 0; } +LCRYPTO_ALIAS(DES_is_weak_key); /* NOW DEFINED IN des_local.h * See ecb_encrypt.c for a pseudo description of these macros. @@ -314,6 +317,7 @@ DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) return 0; } } +LCRYPTO_ALIAS(DES_set_key); /* return 0 if key parity is odd (correct), * return -1 if key parity error, @@ -329,6 +333,7 @@ DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) DES_set_key_unchecked(key, schedule); return 0; } +LCRYPTO_ALIAS(DES_set_key_checked); void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) @@ -388,12 +393,14 @@ DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule) *(k++) = ROTATE(t2, 26) & 0xffffffffL; } } +LCRYPTO_ALIAS(DES_set_key_unchecked); int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule) { return (DES_set_key(key, schedule)); } +LCRYPTO_ALIAS(DES_key_sched); int DES_random_key(DES_cblock *ret) @@ -404,3 +411,4 @@ DES_random_key(DES_cblock *ret) } while (DES_is_weak_key(ret)); return (1); } +LCRYPTO_ALIAS(DES_random_key); diff --git a/lib/libcrypto/des/str2key.c b/lib/libcrypto/des/str2key.c index dd17a441b..cc5bc91b4 100644 --- a/lib/libcrypto/des/str2key.c +++ b/lib/libcrypto/des/str2key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: str2key.c,v 1.13 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: str2key.c,v 1.14 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -97,6 +97,7 @@ DES_string_to_key(const char *str, DES_cblock *key) explicit_bzero(&ks, sizeof(ks)); DES_set_odd_parity(key); } +LCRYPTO_ALIAS(DES_string_to_key); void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) @@ -164,3 +165,4 @@ DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) DES_set_odd_parity(key1); DES_set_odd_parity(key2); } +LCRYPTO_ALIAS(DES_string_to_2keys); diff --git a/lib/libcrypto/des/xcbc_enc.c b/lib/libcrypto/des/xcbc_enc.c index 87f348a9a..90607cad3 100644 --- a/lib/libcrypto/des/xcbc_enc.c +++ b/lib/libcrypto/des/xcbc_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xcbc_enc.c,v 1.12 2023/07/08 07:34:34 jsing Exp $ */ +/* $OpenBSD: xcbc_enc.c,v 1.13 2024/03/29 01:47:29 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -151,3 +151,4 @@ DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, inW0 = inW1 = outW0 = outW1 = 0; tin[0] = tin[1] = 0; } +LCRYPTO_ALIAS(DES_xcbc_encrypt); diff --git a/lib/libcrypto/hidden/openssl/des.h b/lib/libcrypto/hidden/openssl/des.h new file mode 100644 index 000000000..9f6ea9c10 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/des.h @@ -0,0 +1,64 @@ +/* $OpenBSD: des.h,v 1.1 2024/03/29 01:47:29 joshua Exp $ */ +/* + * Copyright (c) 2024 Joshua Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_DES_H +#define _LIBCRYPTO_DES_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/des.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(DES_ecb3_encrypt); +LCRYPTO_USED(DES_cbc_cksum); +LCRYPTO_USED(DES_cbc_encrypt); +LCRYPTO_USED(DES_ncbc_encrypt); +LCRYPTO_USED(DES_xcbc_encrypt); +LCRYPTO_USED(DES_cfb_encrypt); +LCRYPTO_USED(DES_ecb_encrypt); +LCRYPTO_USED(DES_encrypt1); +LCRYPTO_USED(DES_encrypt2); +LCRYPTO_USED(DES_encrypt3); +LCRYPTO_USED(DES_decrypt3); +LCRYPTO_USED(DES_ede3_cbc_encrypt); +LCRYPTO_USED(DES_ede3_cbcm_encrypt); +LCRYPTO_USED(DES_ede3_cfb64_encrypt); +LCRYPTO_USED(DES_ede3_cfb_encrypt); +LCRYPTO_USED(DES_ede3_ofb64_encrypt); +LCRYPTO_USED(DES_enc_read); +LCRYPTO_USED(DES_enc_write); +LCRYPTO_USED(DES_fcrypt); +LCRYPTO_USED(DES_crypt); +LCRYPTO_USED(DES_ofb_encrypt); +LCRYPTO_USED(DES_pcbc_encrypt); +LCRYPTO_USED(DES_quad_cksum); +LCRYPTO_USED(DES_random_key); +LCRYPTO_USED(DES_set_odd_parity); +LCRYPTO_USED(DES_check_key_parity); +LCRYPTO_USED(DES_is_weak_key); +LCRYPTO_USED(DES_set_key); +LCRYPTO_USED(DES_key_sched); +LCRYPTO_USED(DES_set_key_checked); +LCRYPTO_USED(DES_set_key_unchecked); +LCRYPTO_USED(DES_string_to_key); +LCRYPTO_USED(DES_string_to_2keys); +LCRYPTO_USED(DES_cfb64_encrypt); +LCRYPTO_USED(DES_ofb64_encrypt); + +#endif /* _LIBCRYPTO_DES_H */ diff --git a/lib/libcrypto/hidden/openssl/rc4.h b/lib/libcrypto/hidden/openssl/rc4.h new file mode 100644 index 000000000..16a7ff7e1 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/rc4.h @@ -0,0 +1,31 @@ +/* $OpenBSD: rc4.h,v 1.1 2024/03/28 08:18:13 joshua Exp $ */ +/* + * Copyright (c) 2024 Joshua Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_RC4_H +#define _LIBCRYPTO_RC4_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/rc4.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(RC4_set_key); +LCRYPTO_USED(RC4); + +#endif /* _LIBCRYPTO_RC4_H */ diff --git a/lib/libcrypto/hidden/openssl/ripemd.h b/lib/libcrypto/hidden/openssl/ripemd.h new file mode 100644 index 000000000..1fd4a0a46 --- /dev/null +++ b/lib/libcrypto/hidden/openssl/ripemd.h @@ -0,0 +1,34 @@ +/* $OpenBSD: ripemd.h,v 1.1 2024/03/28 23:54:15 joshua Exp $ */ +/* + * Copyright (c) 2024 Joshua Sing + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBCRYPTO_RIPEMD_H +#define _LIBCRYPTO_RIPEMD_H + +#ifndef _MSC_VER +#include_next +#else +#include "../include/openssl/ripemd.h" +#endif +#include "crypto_namespace.h" + +LCRYPTO_USED(RIPEMD160_Init); +LCRYPTO_USED(RIPEMD160_Update); +LCRYPTO_USED(RIPEMD160_Final); +LCRYPTO_USED(RIPEMD160); +LCRYPTO_USED(RIPEMD160_Transform); + +#endif /* _LIBCRYPTO_RIPEMD_H */ diff --git a/lib/libcrypto/md32_common.h b/lib/libcrypto/md32_common.h deleted file mode 100644 index f61c49f03..000000000 --- a/lib/libcrypto/md32_common.h +++ /dev/null @@ -1,309 +0,0 @@ -/* $OpenBSD: md32_common.h,v 1.26 2023/08/10 07:15:23 jsing Exp $ */ -/* ==================================================================== - * Copyright (c) 1999-2007 The OpenSSL Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - * ==================================================================== - * - */ - -/* - * This is a generic 32 bit "collector" for message digest algorithms. - * Whenever needed it collects input character stream into chunks of - * 32 bit values and invokes a block function that performs actual hash - * calculations. - * - * Porting guide. - * - * Obligatory macros: - * - * DATA_ORDER_IS_BIG_ENDIAN or DATA_ORDER_IS_LITTLE_ENDIAN - * this macro defines byte order of input stream. - * HASH_CBLOCK - * size of a unit chunk HASH_BLOCK operates on. - * HASH_LONG - * has to be at least 32 bit wide. - * HASH_CTX - * context structure that at least contains following - * members: - * typedef struct { - * ... - * HASH_LONG Nl,Nh; - * either { - * HASH_LONG data[HASH_LBLOCK]; - * unsigned char data[HASH_CBLOCK]; - * }; - * unsigned int num; - * ... - * } HASH_CTX; - * data[] vector is expected to be zeroed upon first call to - * HASH_UPDATE. - * HASH_UPDATE - * name of "Update" function, implemented here. - * HASH_TRANSFORM - * name of "Transform" function, implemented here. - * HASH_FINAL - * name of "Final" function, implemented here. - * HASH_BLOCK_DATA_ORDER - * name of "block" function capable of treating *unaligned* input - * message in original (data) byte order, implemented externally. - * HASH_MAKE_STRING - * macro convering context variables to an ASCII hash string. - * - * MD5 example: - * - * #define DATA_ORDER_IS_LITTLE_ENDIAN - * - * #define HASH_LONG MD5_LONG - * #define HASH_CTX MD5_CTX - * #define HASH_CBLOCK MD5_CBLOCK - * #define HASH_UPDATE MD5_Update - * #define HASH_TRANSFORM MD5_Transform - * #define HASH_FINAL MD5_Final - * #define HASH_BLOCK_DATA_ORDER md5_block_data_order - * - * - */ - -#include - -#include - -#include "crypto_internal.h" - -#if !defined(DATA_ORDER_IS_BIG_ENDIAN) && !defined(DATA_ORDER_IS_LITTLE_ENDIAN) -#error "DATA_ORDER must be defined!" -#endif - -#ifndef HASH_CBLOCK -#error "HASH_CBLOCK must be defined!" -#endif -#ifndef HASH_LONG -#error "HASH_LONG must be defined!" -#endif -#ifndef HASH_CTX -#error "HASH_CTX must be defined!" -#endif - -#if !defined(HASH_UPDATE) && !defined(HASH_NO_UPDATE) -#error "HASH_UPDATE must be defined!" -#endif -#if !defined(HASH_TRANSFORM) && !defined(HASH_NO_TRANSFORM) -#error "HASH_TRANSFORM must be defined!" -#endif -#if !defined(HASH_FINAL) && !defined(HASH_NO_FINAL) -#error "HASH_FINAL or HASH_NO_FINAL must be defined!" -#endif - -#ifndef HASH_BLOCK_DATA_ORDER -#error "HASH_BLOCK_DATA_ORDER must be defined!" -#endif - -#define ROTATE(a, n) crypto_rol_u32(a, n) - -#if defined(DATA_ORDER_IS_BIG_ENDIAN) - -#if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) -# if (defined(__i386) || defined(__i386__) || \ - defined(__x86_64) || defined(__x86_64__)) - /* - * This gives ~30-40% performance improvement in SHA-256 compiled - * with gcc [on P4]. Well, first macro to be frank. We can pull - * this trick on x86* platforms only, because these CPUs can fetch - * unaligned data without raising an exception. - */ -# define HOST_c2l(c,l) ({ unsigned int r=*((const unsigned int *)(c)); \ - asm ("bswapl %0":"=r"(r):"0"(r)); \ - (c)+=4; (l)=r; }) -# define HOST_l2c(l,c) ({ unsigned int r=(l); \ - asm ("bswapl %0":"=r"(r):"0"(r)); \ - *((unsigned int *)(c))=r; (c)+=4; }) -# endif -#endif - -#ifndef HOST_c2l -#define HOST_c2l(c,l) do {l =(((unsigned long)(*((c)++)))<<24); \ - l|=(((unsigned long)(*((c)++)))<<16); \ - l|=(((unsigned long)(*((c)++)))<< 8); \ - l|=(((unsigned long)(*((c)++))) ); \ - } while (0) -#endif -#ifndef HOST_l2c -#define HOST_l2c(l,c) do {*((c)++)=(unsigned char)(((l)>>24)&0xff); \ - *((c)++)=(unsigned char)(((l)>>16)&0xff); \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff); \ - *((c)++)=(unsigned char)(((l) )&0xff); \ - } while (0) -#endif - -#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) - -#if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__) -# define HOST_c2l(c,l) ((l)=*((const unsigned int *)(c)), (c)+=4) -# define HOST_l2c(l,c) (*((unsigned int *)(c))=(l), (c)+=4) -#endif - -#ifndef HOST_c2l -#define HOST_c2l(c,l) do {l =(((unsigned long)(*((c)++))) ); \ - l|=(((unsigned long)(*((c)++)))<< 8); \ - l|=(((unsigned long)(*((c)++)))<<16); \ - l|=(((unsigned long)(*((c)++)))<<24); \ - } while (0) -#endif -#ifndef HOST_l2c -#define HOST_l2c(l,c) do {*((c)++)=(unsigned char)(((l) )&0xff); \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff); \ - *((c)++)=(unsigned char)(((l)>>16)&0xff); \ - *((c)++)=(unsigned char)(((l)>>24)&0xff); \ - } while (0) -#endif - -#endif - -/* - * Time for some action:-) - */ - -#ifndef HASH_NO_UPDATE -int -HASH_UPDATE(HASH_CTX *c, const void *data_, size_t len) -{ - const unsigned char *data = data_; - unsigned char *p; - HASH_LONG l; - size_t n; - - if (len == 0) - return 1; - - l = (c->Nl + (((HASH_LONG)len) << 3))&0xffffffffUL; - /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to - * Wei Dai for pointing it out. */ - if (l < c->Nl) /* overflow */ - c->Nh++; - c->Nh+=(HASH_LONG)(len>>29); /* might cause compiler warning on 16-bit */ - c->Nl = l; - - n = c->num; - if (n != 0) { - p = (unsigned char *)c->data; - - if (len >= HASH_CBLOCK || len + n >= HASH_CBLOCK) { - memcpy (p + n, data, HASH_CBLOCK - n); - HASH_BLOCK_DATA_ORDER (c, p, 1); - n = HASH_CBLOCK - n; - data += n; - len -= n; - c->num = 0; - memset (p,0,HASH_CBLOCK); /* keep it zeroed */ - } else { - memcpy (p + n, data, len); - c->num += (unsigned int)len; - return 1; - } - } - - n = len/HASH_CBLOCK; - if (n > 0) { - HASH_BLOCK_DATA_ORDER (c, data, n); - n *= HASH_CBLOCK; - data += n; - len -= n; - } - - if (len != 0) { - p = (unsigned char *)c->data; - c->num = (unsigned int)len; - memcpy (p, data, len); - } - return 1; -} -#endif - -#ifndef HASH_NO_TRANSFORM -void HASH_TRANSFORM (HASH_CTX *c, const unsigned char *data) -{ - HASH_BLOCK_DATA_ORDER (c, data, 1); -} -#endif - -#ifndef HASH_NO_FINAL -int HASH_FINAL (unsigned char *md, HASH_CTX *c) -{ - unsigned char *p = (unsigned char *)c->data; - size_t n = c->num; - - p[n] = 0x80; /* there is always room for one */ - n++; - - if (n > (HASH_CBLOCK - 8)) { - memset (p + n, 0, HASH_CBLOCK - n); - n = 0; - HASH_BLOCK_DATA_ORDER (c, p, 1); - } - memset (p + n, 0, HASH_CBLOCK - 8 - n); - - p += HASH_CBLOCK - 8; -#if defined(DATA_ORDER_IS_BIG_ENDIAN) - HOST_l2c(c->Nh, p); - HOST_l2c(c->Nl, p); -#elif defined(DATA_ORDER_IS_LITTLE_ENDIAN) - HOST_l2c(c->Nl, p); - HOST_l2c(c->Nh, p); -#endif - p -= HASH_CBLOCK; - HASH_BLOCK_DATA_ORDER (c, p, 1); - c->num = 0; - memset (p, 0, HASH_CBLOCK); - -#ifndef HASH_MAKE_STRING -#error "HASH_MAKE_STRING must be defined!" -#else - HASH_MAKE_STRING(c, md); -#endif - - return 1; -} -#endif diff --git a/lib/libcrypto/md4/md4.c b/lib/libcrypto/md4/md4.c index f25595c15..42c5b2142 100644 --- a/lib/libcrypto/md4/md4.c +++ b/lib/libcrypto/md4/md4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md4.c,v 1.16 2024/03/27 06:15:18 jsing Exp $ */ +/* $OpenBSD: md4.c,v 1.17 2024/03/28 08:00:07 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -118,12 +118,12 @@ md4_block_data_order(MD4_CTX *c, const void *_in, size_t num) unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; - A = c->A; - B = c->B; - C = c->C; - D = c->D; - while (num-- > 0) { + A = c->A; + B = c->B; + C = c->C; + D = c->D; + if ((uintptr_t)in % 4 == 0) { /* Input is 32 bit aligned. */ in32 = (const MD4_LONG *)in; @@ -217,10 +217,10 @@ md4_block_data_order(MD4_CTX *c, const void *_in, size_t num) md4_round3(&C, D, A, B, X7, 11); md4_round3(&B, C, D, A, X15, 15); - A = c->A += A; - B = c->B += B; - C = c->C += C; - D = c->D += D; + c->A += A; + c->B += B; + c->C += C; + c->D += D; } } diff --git a/lib/libcrypto/md5/md5.c b/lib/libcrypto/md5/md5.c index 6b1afb444..35d1ac914 100644 --- a/lib/libcrypto/md5/md5.c +++ b/lib/libcrypto/md5/md5.c @@ -1,4 +1,4 @@ -/* $OpenBSD: md5.c,v 1.21 2024/03/26 05:55:15 jsing Exp $ */ +/* $OpenBSD: md5.c,v 1.22 2024/03/28 08:00:08 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -137,12 +137,12 @@ md5_block_data_order(MD5_CTX *c, const void *_in, size_t num) MD5_LONG X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; - A = c->A; - B = c->B; - C = c->C; - D = c->D; - while (num-- > 0) { + A = c->A; + B = c->B; + C = c->C; + D = c->D; + if ((uintptr_t)in % 4 == 0) { /* Input is 32 bit aligned. */ in32 = (const MD5_LONG *)in; @@ -251,10 +251,10 @@ md5_block_data_order(MD5_CTX *c, const void *_in, size_t num) md5_round4(&C, D, A, B, X2, 0x2ad7d2bbL, 15); md5_round4(&B, C, D, A, X9, 0xeb86d391L, 21); - A = c->A += A; - B = c->B += B; - C = c->C += C; - D = c->D += D; + c->A += A; + c->B += B; + c->C += C; + c->D += D; } } #endif diff --git a/lib/libcrypto/rc4/rc4.c b/lib/libcrypto/rc4/rc4.c index 8ff8191a5..203fee499 100644 --- a/lib/libcrypto/rc4/rc4.c +++ b/lib/libcrypto/rc4/rc4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rc4.c,v 1.9 2024/03/28 01:49:29 jsing Exp $ */ +/* $OpenBSD: rc4.c,v 1.11 2024/03/28 12:11:26 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -262,7 +262,7 @@ rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata, void rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data); #else -static void +static inline void rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data) { RC4_INT tmp; @@ -299,9 +299,11 @@ RC4(RC4_KEY *key, size_t len, const unsigned char *indata, { rc4_internal(key, len, indata, outdata); } +LCRYPTO_ALIAS(RC4); void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) { rc4_set_key_internal(key, len, data); } +LCRYPTO_ALIAS(RC4_set_key); diff --git a/lib/libcrypto/ripemd/ripemd.c b/lib/libcrypto/ripemd/ripemd.c index 344d9f668..b2d798c49 100644 --- a/lib/libcrypto/ripemd/ripemd.c +++ b/lib/libcrypto/ripemd/ripemd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ripemd.c,v 1.7 2023/08/10 12:27:35 jsing Exp $ */ +/* $OpenBSD: ripemd.c,v 1.18 2024/03/28 23:54:15 joshua Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -57,50 +57,18 @@ */ #include -#include -#include - #include #include + #include + +#include #include -/* - * DO EXAMINE COMMENTS IN crypto/md5/md5_locl.h & crypto/md5/md5_dgst.c - * FOR EXPLANATIONS ON FOLLOWING "CODE." - * - */ -#ifdef RMD160_ASM -# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__) -# define ripemd160_block_data_order ripemd160_block_asm_data_order -# endif -#endif +#include "crypto_internal.h" -__BEGIN_HIDDEN_DECLS - -void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p, size_t num); - -__END_HIDDEN_DECLS - -#define DATA_ORDER_IS_LITTLE_ENDIAN - -#define HASH_LONG RIPEMD160_LONG -#define HASH_CTX RIPEMD160_CTX -#define HASH_CBLOCK RIPEMD160_CBLOCK -#define HASH_UPDATE RIPEMD160_Update -#define HASH_TRANSFORM RIPEMD160_Transform -#define HASH_FINAL RIPEMD160_Final -#define HASH_MAKE_STRING(c,s) do { \ - unsigned long ll; \ - ll=(c)->A; HOST_l2c(ll,(s)); \ - ll=(c)->B; HOST_l2c(ll,(s)); \ - ll=(c)->C; HOST_l2c(ll,(s)); \ - ll=(c)->D; HOST_l2c(ll,(s)); \ - ll=(c)->E; HOST_l2c(ll,(s)); \ - } while (0) -#define HASH_BLOCK_DATA_ORDER ripemd160_block_data_order - -#include "md32_common.h" +/* Ensure that SHA_LONG and uint32_t are equivalent sizes. */ +CTASSERT(sizeof(RIPEMD160_LONG) == sizeof(uint32_t)); #if 0 #define F1(x,y,z) ((x)^(y)^(z)) @@ -119,12 +87,6 @@ __END_HIDDEN_DECLS #define F5(x,y,z) (((~(z)) | (y)) ^ (x)) #endif -#define RIPEMD160_A 0x67452301L -#define RIPEMD160_B 0xEFCDAB89L -#define RIPEMD160_C 0x98BADCFEL -#define RIPEMD160_D 0x10325476L -#define RIPEMD160_E 0xC3D2E1F0L - #define KL0 0x00000000L #define KL1 0x5A827999L #define KL2 0x6ED9EBA1L @@ -139,112 +101,100 @@ __END_HIDDEN_DECLS #define RIP1(a,b,c,d,e,w,s) { \ a+=F1(b,c,d)+w; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } + a=crypto_rol_u32(a,s)+e; \ + c=crypto_rol_u32(c,10); } #define RIP2(a,b,c,d,e,w,s,K) { \ a+=F2(b,c,d)+w+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } + a=crypto_rol_u32(a,s)+e; \ + c=crypto_rol_u32(c,10); } #define RIP3(a,b,c,d,e,w,s,K) { \ a+=F3(b,c,d)+w+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } + a=crypto_rol_u32(a,s)+e; \ + c=crypto_rol_u32(c,10); } #define RIP4(a,b,c,d,e,w,s,K) { \ a+=F4(b,c,d)+w+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } + a=crypto_rol_u32(a,s)+e; \ + c=crypto_rol_u32(c,10); } #define RIP5(a,b,c,d,e,w,s,K) { \ a+=F5(b,c,d)+w+K; \ - a=ROTATE(a,s)+e; \ - c=ROTATE(c,10); } + a=crypto_rol_u32(a,s)+e; \ + c=crypto_rol_u32(c,10); } -# ifdef RMD160_ASM -void ripemd160_block_x86(RIPEMD160_CTX *c, unsigned long *p, size_t num); -# define ripemd160_block ripemd160_block_x86 -# else -void ripemd160_block(RIPEMD160_CTX *c, unsigned long *p, size_t num); -# endif - -int -RIPEMD160_Init(RIPEMD160_CTX *c) +static void +ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *_in, size_t num) { - memset (c, 0, sizeof(*c)); - c->A = RIPEMD160_A; - c->B = RIPEMD160_B; - c->C = RIPEMD160_C; - c->D = RIPEMD160_D; - c->E = RIPEMD160_E; - return 1; -} - -#ifndef ripemd160_block_data_order -void -ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) -{ - const unsigned char *data = p; + const uint8_t *in = _in; + const RIPEMD160_LONG *in32; unsigned int A, B, C, D, E; - unsigned int a, b, c, d, e, l; + unsigned int a, b, c, d, e; unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; for (; num--; ) { - A = ctx->A; B = ctx->B; C = ctx->C; D = ctx->D; E = ctx->E; - HOST_c2l(data, l); - X0 = l; - HOST_c2l(data, l); - X1 = l; + if ((uintptr_t)in % 4 == 0) { + /* Input is 32 bit aligned. */ + in32 = (const RIPEMD160_LONG *)in; + X0 = le32toh(in32[0]); + X1 = le32toh(in32[1]); + X2 = le32toh(in32[2]); + X3 = le32toh(in32[3]); + X4 = le32toh(in32[4]); + X5 = le32toh(in32[5]); + X6 = le32toh(in32[6]); + X7 = le32toh(in32[7]); + X8 = le32toh(in32[8]); + X9 = le32toh(in32[9]); + X10 = le32toh(in32[10]); + X11 = le32toh(in32[11]); + X12 = le32toh(in32[12]); + X13 = le32toh(in32[13]); + X14 = le32toh(in32[14]); + X15 = le32toh(in32[15]); + } else { + /* Input is not 32 bit aligned. */ + X0 = crypto_load_le32toh(&in[0 * 4]); + X1 = crypto_load_le32toh(&in[1 * 4]); + X2 = crypto_load_le32toh(&in[2 * 4]); + X3 = crypto_load_le32toh(&in[3 * 4]); + X4 = crypto_load_le32toh(&in[4 * 4]); + X5 = crypto_load_le32toh(&in[5 * 4]); + X6 = crypto_load_le32toh(&in[6 * 4]); + X7 = crypto_load_le32toh(&in[7 * 4]); + X8 = crypto_load_le32toh(&in[8 * 4]); + X9 = crypto_load_le32toh(&in[9 * 4]); + X10 = crypto_load_le32toh(&in[10 * 4]); + X11 = crypto_load_le32toh(&in[11 * 4]); + X12 = crypto_load_le32toh(&in[12 * 4]); + X13 = crypto_load_le32toh(&in[13 * 4]); + X14 = crypto_load_le32toh(&in[14 * 4]); + X15 = crypto_load_le32toh(&in[15 * 4]); + } + in += RIPEMD160_CBLOCK; + RIP1(A, B, C, D, E, X0, 11); - HOST_c2l(data, l); - X2 = l; RIP1(E, A, B, C, D, X1, 14); - HOST_c2l(data, l); - X3 = l; RIP1(D, E, A, B, C, X2, 15); - HOST_c2l(data, l); - X4 = l; RIP1(C, D, E, A, B, X3, 12); - HOST_c2l(data, l); - X5 = l; RIP1(B, C, D, E, A, X4, 5); - HOST_c2l(data, l); - X6 = l; RIP1(A, B, C, D, E, X5, 8); - HOST_c2l(data, l); - X7 = l; RIP1(E, A, B, C, D, X6, 7); - HOST_c2l(data, l); - X8 = l; RIP1(D, E, A, B, C, X7, 9); - HOST_c2l(data, l); - X9 = l; RIP1(C, D, E, A, B, X8, 11); - HOST_c2l(data, l); - X10 = l; RIP1(B, C, D, E, A, X9, 13); - HOST_c2l(data, l); - X11 = l; RIP1(A, B, C, D, E, X10, 14); - HOST_c2l(data, l); - X12 = l; RIP1(E, A, B, C, D, X11, 15); - HOST_c2l(data, l); - X13 = l; RIP1(D, E, A, B, C, X12, 6); - HOST_c2l(data, l); - X14 = l; RIP1(C, D, E, A, B, X13, 7); - HOST_c2l(data, l); - X15 = l; RIP1(B, C, D, E, A, X14, 9); RIP1(A, B, C, D, E, X15, 8); @@ -419,10 +369,118 @@ ripemd160_block_data_order(RIPEMD160_CTX *ctx, const void *p, size_t num) ctx->D = ctx->E + a + B; ctx->E = ctx->A + b + C; ctx->A = D; - } } -#endif + +int +RIPEMD160_Init(RIPEMD160_CTX *c) +{ + memset(c, 0, sizeof(*c)); + + c->A = 0x67452301UL; + c->B = 0xEFCDAB89UL; + c->C = 0x98BADCFEUL; + c->D = 0x10325476UL; + c->E = 0xC3D2E1F0UL; + + return 1; +} +LCRYPTO_ALIAS(RIPEMD160_Init); + +int +RIPEMD160_Update(RIPEMD160_CTX *c, const void *data_, size_t len) +{ + const unsigned char *data = data_; + unsigned char *p; + RIPEMD160_LONG l; + size_t n; + + if (len == 0) + return 1; + + l = (c->Nl + (((RIPEMD160_LONG)len) << 3))&0xffffffffUL; + /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to + * Wei Dai for pointing it out. */ + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh+=(RIPEMD160_LONG)(len>>29); /* might cause compiler warning on 16-bit */ + c->Nl = l; + + n = c->num; + if (n != 0) { + p = (unsigned char *)c->data; + + if (len >= RIPEMD160_CBLOCK || len + n >= RIPEMD160_CBLOCK) { + memcpy(p + n, data, RIPEMD160_CBLOCK - n); + ripemd160_block_data_order(c, p, 1); + n = RIPEMD160_CBLOCK - n; + data += n; + len -= n; + c->num = 0; + memset(p, 0, RIPEMD160_CBLOCK); /* keep it zeroed */ + } else { + memcpy(p + n, data, len); + c->num += (unsigned int)len; + return 1; + } + } + + n = len/RIPEMD160_CBLOCK; + if (n > 0) { + ripemd160_block_data_order(c, data, n); + n *= RIPEMD160_CBLOCK; + data += n; + len -= n; + } + + if (len != 0) { + p = (unsigned char *)c->data; + c->num = (unsigned int)len; + memcpy(p, data, len); + } + return 1; +} +LCRYPTO_ALIAS(RIPEMD160_Update); + +void +RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *data) +{ + ripemd160_block_data_order(c, data, 1); +} +LCRYPTO_ALIAS(RIPEMD160_Transform); + +int +RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c) +{ + unsigned char *p = (unsigned char *)c->data; + size_t n = c->num; + + p[n] = 0x80; /* there is always room for one */ + n++; + + if (n > (RIPEMD160_CBLOCK - 8)) { + memset(p + n, 0, RIPEMD160_CBLOCK - n); + n = 0; + ripemd160_block_data_order(c, p, 1); + } + + memset(p + n, 0, RIPEMD160_CBLOCK - 8 - n); + c->data[RIPEMD160_LBLOCK - 2] = htole32(c->Nl); + c->data[RIPEMD160_LBLOCK - 1] = htole32(c->Nh); + + ripemd160_block_data_order(c, p, 1); + c->num = 0; + memset(p, 0, RIPEMD160_CBLOCK); + + crypto_store_htole32(&md[0 * 4], c->A); + crypto_store_htole32(&md[1 * 4], c->B); + crypto_store_htole32(&md[2 * 4], c->C); + crypto_store_htole32(&md[3 * 4], c->D); + crypto_store_htole32(&md[4 * 4], c->E); + + return 1; +} +LCRYPTO_ALIAS(RIPEMD160_Final); unsigned char * RIPEMD160(const unsigned char *d, size_t n, @@ -440,3 +498,4 @@ RIPEMD160(const unsigned char *d, size_t n, explicit_bzero(&c, sizeof(c)); return (md); } +LCRYPTO_ALIAS(RIPEMD160); diff --git a/lib/libcrypto/sha/sha1.c b/lib/libcrypto/sha/sha1.c index 8bcc5e043..32007d5d5 100644 --- a/lib/libcrypto/sha/sha1.c +++ b/lib/libcrypto/sha/sha1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha1.c,v 1.13 2024/03/26 12:54:22 jsing Exp $ */ +/* $OpenBSD: sha1.c,v 1.14 2024/03/28 07:06:12 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,92 +71,114 @@ /* Ensure that SHA_LONG and uint32_t are equivalent sizes. */ CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t)); -#define DATA_ORDER_IS_BIG_ENDIAN - -#define HASH_LONG SHA_LONG -#define HASH_CTX SHA_CTX -#define HASH_CBLOCK SHA_CBLOCK - -#define HASH_BLOCK_DATA_ORDER sha1_block_data_order -#define Xupdate(a, ix, ia, ib, ic, id) ( (a)=(ia^ib^ic^id), \ - ix=(a)=ROTATE((a),1) \ - ) +#ifdef SHA1_ASM +void sha1_block_data_order(SHA_CTX *ctx, const void *p, size_t num); +#endif #ifndef SHA1_ASM -static -#endif -void sha1_block_data_order(SHA_CTX *c, const void *p, size_t num); +static inline SHA_LONG +Ch(SHA_LONG x, SHA_LONG y, SHA_LONG z) +{ + return (x & y) ^ (~x & z); +} -#define HASH_NO_UPDATE -#define HASH_NO_TRANSFORM -#define HASH_NO_FINAL +static inline SHA_LONG +Parity(SHA_LONG x, SHA_LONG y, SHA_LONG z) +{ + return x ^ y ^ z; +} -#include "md32_common.h" +static inline SHA_LONG +Maj(SHA_LONG x, SHA_LONG y, SHA_LONG z) +{ + return (x & y) ^ (x & z) ^ (y & z); +} -#define K_00_19 0x5a827999UL -#define K_20_39 0x6ed9eba1UL -#define K_40_59 0x8f1bbcdcUL -#define K_60_79 0xca62c1d6UL +static inline void +sha1_msg_schedule_update(SHA_LONG *W0, SHA_LONG W2, SHA_LONG W8, SHA_LONG W13) +{ + *W0 = crypto_rol_u32(W13 ^ W8 ^ W2 ^ *W0, 1); +} -/* As pointed out by Wei Dai , F() below can be - * simplified to the code in F_00_19. Wei attributes these optimisations - * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel. - * #define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) - * I've just become aware of another tweak to be made, again from Wei Dai, - * in F_40_59, (x&a)|(y&a) -> (x|y)&a - */ -#define F_00_19(b, c, d) ((((c) ^ (d)) & (b)) ^ (d)) -#define F_20_39(b, c, d) ((b) ^ (c) ^ (d)) -#define F_40_59(b, c, d) (((b) & (c)) | (((b)|(c)) & (d))) -#define F_60_79(b, c, d) F_20_39(b, c, d) +static inline void +sha1_round1(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, + SHA_LONG Wt) +{ + SHA_LONG Kt, T; + Kt = 0x5a827999UL; + T = crypto_rol_u32(*a, 5) + Ch(*b, *c, *d) + *e + Kt + Wt; -#define BODY_00_15(i, a, b, c, d, e, f, xi) \ - (f)=xi+(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ - (b)=ROTATE((b),30); + *e = *d; + *d = *c; + *c = crypto_rol_u32(*b, 30); + *b = *a; + *a = T; +} -#define BODY_16_19(i, a, b, c, d, e, f, xi, xa, xb, xc, xd) \ - Xupdate(f, xi, xa, xb, xc, xd); \ - (f)+=(e)+K_00_19+ROTATE((a),5)+F_00_19((b),(c),(d)); \ - (b)=ROTATE((b),30); +static inline void +sha1_round2(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, + SHA_LONG Wt) +{ + SHA_LONG Kt, T; -#define BODY_20_31(i, a, b, c, d, e, f, xi, xa, xb, xc, xd) \ - Xupdate(f, xi, xa, xb, xc, xd); \ - (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ - (b)=ROTATE((b),30); + Kt = 0x6ed9eba1UL; + T = crypto_rol_u32(*a, 5) + Parity(*b, *c, *d) + *e + Kt + Wt; -#define BODY_32_39(i, a, b, c, d, e, f, xa, xb, xc, xd) \ - Xupdate(f, xa, xa, xb, xc, xd); \ - (f)+=(e)+K_20_39+ROTATE((a),5)+F_20_39((b),(c),(d)); \ - (b)=ROTATE((b),30); + *e = *d; + *d = *c; + *c = crypto_rol_u32(*b, 30); + *b = *a; + *a = T; +} -#define BODY_40_59(i, a, b, c, d, e, f, xa, xb, xc, xd) \ - Xupdate(f, xa, xa, xb, xc, xd); \ - (f)+=(e)+K_40_59+ROTATE((a),5)+F_40_59((b),(c),(d)); \ - (b)=ROTATE((b),30); +static inline void +sha1_round3(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, + SHA_LONG Wt) +{ + SHA_LONG Kt, T; -#define BODY_60_79(i, a, b, c, d, e, f, xa, xb, xc, xd) \ - Xupdate(f, xa, xa, xb, xc, xd); \ - (f)=xa+(e)+K_60_79+ROTATE((a),5)+F_60_79((b),(c),(d)); \ - (b)=ROTATE((b),30); + Kt = 0x8f1bbcdcUL; + T = crypto_rol_u32(*a, 5) + Maj(*b, *c, *d) + *e + Kt + Wt; + + *e = *d; + *d = *c; + *c = crypto_rol_u32(*b, 30); + *b = *a; + *a = T; +} + +static inline void +sha1_round4(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, + SHA_LONG Wt) +{ + SHA_LONG Kt, T; + + Kt = 0xca62c1d6UL; + T = crypto_rol_u32(*a, 5) + Parity(*b, *c, *d) + *e + Kt + Wt; + + *e = *d; + *d = *c; + *c = crypto_rol_u32(*b, 30); + *b = *a; + *a = T; +} -#if !defined(SHA1_ASM) -#include static void -sha1_block_data_order(SHA_CTX *c, const void *_in, size_t num) +sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num) { const uint8_t *in = _in; const SHA_LONG *in32; - unsigned int A, B, C, D, E, T; + unsigned int a, b, c, d, e; unsigned int X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15; while (num--) { - A = c->h0; - B = c->h1; - C = c->h2; - D = c->h3; - E = c->h4; + a = ctx->h0; + b = ctx->h1; + c = ctx->h2; + d = ctx->h3; + e = ctx->h4; if ((size_t)in % 4 == 0) { /* Input is 32 bit aligned. */ @@ -198,102 +220,168 @@ sha1_block_data_order(SHA_CTX *c, const void *_in, size_t num) } in += SHA_CBLOCK; - BODY_00_15( 0, A, B, C, D, E, T, X0); - BODY_00_15( 1, T, A, B, C, D, E, X1); - BODY_00_15( 2, E, T, A, B, C, D, X2); - BODY_00_15( 3, D, E, T, A, B, C, X3); - BODY_00_15( 4, C, D, E, T, A, B, X4); - BODY_00_15( 5, B, C, D, E, T, A, X5); - BODY_00_15( 6, A, B, C, D, E, T, X6); - BODY_00_15( 7, T, A, B, C, D, E, X7); - BODY_00_15( 8, E, T, A, B, C, D, X8); - BODY_00_15( 9, D, E, T, A, B, C, X9); - BODY_00_15(10, C, D, E, T, A, B, X10); - BODY_00_15(11, B, C, D, E, T, A, X11); - BODY_00_15(12, A, B, C, D, E, T, X12); - BODY_00_15(13, T, A, B, C, D, E, X13); - BODY_00_15(14, E, T, A, B, C, D, X14); - BODY_00_15(15, D, E, T, A, B, C, X15); + sha1_round1(&a, &b, &c, &d, &e, X0); + sha1_round1(&a, &b, &c, &d, &e, X1); + sha1_round1(&a, &b, &c, &d, &e, X2); + sha1_round1(&a, &b, &c, &d, &e, X3); + sha1_round1(&a, &b, &c, &d, &e, X4); + sha1_round1(&a, &b, &c, &d, &e, X5); + sha1_round1(&a, &b, &c, &d, &e, X6); + sha1_round1(&a, &b, &c, &d, &e, X7); + sha1_round1(&a, &b, &c, &d, &e, X8); + sha1_round1(&a, &b, &c, &d, &e, X9); + sha1_round1(&a, &b, &c, &d, &e, X10); + sha1_round1(&a, &b, &c, &d, &e, X11); + sha1_round1(&a, &b, &c, &d, &e, X12); + sha1_round1(&a, &b, &c, &d, &e, X13); + sha1_round1(&a, &b, &c, &d, &e, X14); + sha1_round1(&a, &b, &c, &d, &e, X15); - BODY_16_19(16, C, D, E, T, A, B, X0, X0, X2, X8, X13); - BODY_16_19(17, B, C, D, E, T, A, X1, X1, X3, X9, X14); - BODY_16_19(18, A, B, C, D, E, T, X2, X2, X4, X10, X15); - BODY_16_19(19, T, A, B, C, D, E, X3, X3, X5, X11, X0); + sha1_msg_schedule_update(&X0, X2, X8, X13); + sha1_msg_schedule_update(&X1, X3, X9, X14); + sha1_msg_schedule_update(&X2, X4, X10, X15); + sha1_msg_schedule_update(&X3, X5, X11, X0); + sha1_msg_schedule_update(&X4, X6, X12, X1); + sha1_msg_schedule_update(&X5, X7, X13, X2); + sha1_msg_schedule_update(&X6, X8, X14, X3); + sha1_msg_schedule_update(&X7, X9, X15, X4); + sha1_msg_schedule_update(&X8, X10, X0, X5); + sha1_msg_schedule_update(&X9, X11, X1, X6); + sha1_msg_schedule_update(&X10, X12, X2, X7); + sha1_msg_schedule_update(&X11, X13, X3, X8); + sha1_msg_schedule_update(&X12, X14, X4, X9); + sha1_msg_schedule_update(&X13, X15, X5, X10); + sha1_msg_schedule_update(&X14, X0, X6, X11); + sha1_msg_schedule_update(&X15, X1, X7, X12); - BODY_20_31(20, E, T, A, B, C, D, X4, X4, X6, X12, X1); - BODY_20_31(21, D, E, T, A, B, C, X5, X5, X7, X13, X2); - BODY_20_31(22, C, D, E, T, A, B, X6, X6, X8, X14, X3); - BODY_20_31(23, B, C, D, E, T, A, X7, X7, X9, X15, X4); - BODY_20_31(24, A, B, C, D, E, T, X8, X8, X10, X0, X5); - BODY_20_31(25, T, A, B, C, D, E, X9, X9, X11, X1, X6); - BODY_20_31(26, E, T, A, B, C, D, X10, X10, X12, X2, X7); - BODY_20_31(27, D, E, T, A, B, C, X11, X11, X13, X3, X8); - BODY_20_31(28, C, D, E, T, A, B, X12, X12, X14, X4, X9); - BODY_20_31(29, B, C, D, E, T, A, X13, X13, X15, X5, X10); - BODY_20_31(30, A, B, C, D, E, T, X14, X14, X0, X6, X11); - BODY_20_31(31, T, A, B, C, D, E, X15, X15, X1, X7, X12); + sha1_round1(&a, &b, &c, &d, &e, X0); + sha1_round1(&a, &b, &c, &d, &e, X1); + sha1_round1(&a, &b, &c, &d, &e, X2); + sha1_round1(&a, &b, &c, &d, &e, X3); + sha1_round2(&a, &b, &c, &d, &e, X4); + sha1_round2(&a, &b, &c, &d, &e, X5); + sha1_round2(&a, &b, &c, &d, &e, X6); + sha1_round2(&a, &b, &c, &d, &e, X7); + sha1_round2(&a, &b, &c, &d, &e, X8); + sha1_round2(&a, &b, &c, &d, &e, X9); + sha1_round2(&a, &b, &c, &d, &e, X10); + sha1_round2(&a, &b, &c, &d, &e, X11); + sha1_round2(&a, &b, &c, &d, &e, X12); + sha1_round2(&a, &b, &c, &d, &e, X13); + sha1_round2(&a, &b, &c, &d, &e, X14); + sha1_round2(&a, &b, &c, &d, &e, X15); - BODY_32_39(32, E, T, A, B, C, D, X0, X2, X8, X13); - BODY_32_39(33, D, E, T, A, B, C, X1, X3, X9, X14); - BODY_32_39(34, C, D, E, T, A, B, X2, X4, X10, X15); - BODY_32_39(35, B, C, D, E, T, A, X3, X5, X11, X0); - BODY_32_39(36, A, B, C, D, E, T, X4, X6, X12, X1); - BODY_32_39(37, T, A, B, C, D, E, X5, X7, X13, X2); - BODY_32_39(38, E, T, A, B, C, D, X6, X8, X14, X3); - BODY_32_39(39, D, E, T, A, B, C, X7, X9, X15, X4); + sha1_msg_schedule_update(&X0, X2, X8, X13); + sha1_msg_schedule_update(&X1, X3, X9, X14); + sha1_msg_schedule_update(&X2, X4, X10, X15); + sha1_msg_schedule_update(&X3, X5, X11, X0); + sha1_msg_schedule_update(&X4, X6, X12, X1); + sha1_msg_schedule_update(&X5, X7, X13, X2); + sha1_msg_schedule_update(&X6, X8, X14, X3); + sha1_msg_schedule_update(&X7, X9, X15, X4); + sha1_msg_schedule_update(&X8, X10, X0, X5); + sha1_msg_schedule_update(&X9, X11, X1, X6); + sha1_msg_schedule_update(&X10, X12, X2, X7); + sha1_msg_schedule_update(&X11, X13, X3, X8); + sha1_msg_schedule_update(&X12, X14, X4, X9); + sha1_msg_schedule_update(&X13, X15, X5, X10); + sha1_msg_schedule_update(&X14, X0, X6, X11); + sha1_msg_schedule_update(&X15, X1, X7, X12); - BODY_40_59(40, C, D, E, T, A, B, X8, X10, X0, X5); - BODY_40_59(41, B, C, D, E, T, A, X9, X11, X1, X6); - BODY_40_59(42, A, B, C, D, E, T, X10, X12, X2, X7); - BODY_40_59(43, T, A, B, C, D, E, X11, X13, X3, X8); - BODY_40_59(44, E, T, A, B, C, D, X12, X14, X4, X9); - BODY_40_59(45, D, E, T, A, B, C, X13, X15, X5, X10); - BODY_40_59(46, C, D, E, T, A, B, X14, X0, X6, X11); - BODY_40_59(47, B, C, D, E, T, A, X15, X1, X7, X12); - BODY_40_59(48, A, B, C, D, E, T, X0, X2, X8, X13); - BODY_40_59(49, T, A, B, C, D, E, X1, X3, X9, X14); - BODY_40_59(50, E, T, A, B, C, D, X2, X4, X10, X15); - BODY_40_59(51, D, E, T, A, B, C, X3, X5, X11, X0); - BODY_40_59(52, C, D, E, T, A, B, X4, X6, X12, X1); - BODY_40_59(53, B, C, D, E, T, A, X5, X7, X13, X2); - BODY_40_59(54, A, B, C, D, E, T, X6, X8, X14, X3); - BODY_40_59(55, T, A, B, C, D, E, X7, X9, X15, X4); - BODY_40_59(56, E, T, A, B, C, D, X8, X10, X0, X5); - BODY_40_59(57, D, E, T, A, B, C, X9, X11, X1, X6); - BODY_40_59(58, C, D, E, T, A, B, X10, X12, X2, X7); - BODY_40_59(59, B, C, D, E, T, A, X11, X13, X3, X8); + sha1_round2(&a, &b, &c, &d, &e, X0); + sha1_round2(&a, &b, &c, &d, &e, X1); + sha1_round2(&a, &b, &c, &d, &e, X2); + sha1_round2(&a, &b, &c, &d, &e, X3); + sha1_round2(&a, &b, &c, &d, &e, X4); + sha1_round2(&a, &b, &c, &d, &e, X5); + sha1_round2(&a, &b, &c, &d, &e, X6); + sha1_round2(&a, &b, &c, &d, &e, X7); + sha1_round3(&a, &b, &c, &d, &e, X8); + sha1_round3(&a, &b, &c, &d, &e, X9); + sha1_round3(&a, &b, &c, &d, &e, X10); + sha1_round3(&a, &b, &c, &d, &e, X11); + sha1_round3(&a, &b, &c, &d, &e, X12); + sha1_round3(&a, &b, &c, &d, &e, X13); + sha1_round3(&a, &b, &c, &d, &e, X14); + sha1_round3(&a, &b, &c, &d, &e, X15); - BODY_60_79(60, A, B, C, D, E, T, X12, X14, X4, X9); - BODY_60_79(61, T, A, B, C, D, E, X13, X15, X5, X10); - BODY_60_79(62, E, T, A, B, C, D, X14, X0, X6, X11); - BODY_60_79(63, D, E, T, A, B, C, X15, X1, X7, X12); - BODY_60_79(64, C, D, E, T, A, B, X0, X2, X8, X13); - BODY_60_79(65, B, C, D, E, T, A, X1, X3, X9, X14); - BODY_60_79(66, A, B, C, D, E, T, X2, X4, X10, X15); - BODY_60_79(67, T, A, B, C, D, E, X3, X5, X11, X0); - BODY_60_79(68, E, T, A, B, C, D, X4, X6, X12, X1); - BODY_60_79(69, D, E, T, A, B, C, X5, X7, X13, X2); - BODY_60_79(70, C, D, E, T, A, B, X6, X8, X14, X3); - BODY_60_79(71, B, C, D, E, T, A, X7, X9, X15, X4); - BODY_60_79(72, A, B, C, D, E, T, X8, X10, X0, X5); - BODY_60_79(73, T, A, B, C, D, E, X9, X11, X1, X6); - BODY_60_79(74, E, T, A, B, C, D, X10, X12, X2, X7); - BODY_60_79(75, D, E, T, A, B, C, X11, X13, X3, X8); - BODY_60_79(76, C, D, E, T, A, B, X12, X14, X4, X9); - BODY_60_79(77, B, C, D, E, T, A, X13, X15, X5, X10); - BODY_60_79(78, A, B, C, D, E, T, X14, X0, X6, X11); - BODY_60_79(79, T, A, B, C, D, E, X15, X1, X7, X12); + sha1_msg_schedule_update(&X0, X2, X8, X13); + sha1_msg_schedule_update(&X1, X3, X9, X14); + sha1_msg_schedule_update(&X2, X4, X10, X15); + sha1_msg_schedule_update(&X3, X5, X11, X0); + sha1_msg_schedule_update(&X4, X6, X12, X1); + sha1_msg_schedule_update(&X5, X7, X13, X2); + sha1_msg_schedule_update(&X6, X8, X14, X3); + sha1_msg_schedule_update(&X7, X9, X15, X4); + sha1_msg_schedule_update(&X8, X10, X0, X5); + sha1_msg_schedule_update(&X9, X11, X1, X6); + sha1_msg_schedule_update(&X10, X12, X2, X7); + sha1_msg_schedule_update(&X11, X13, X3, X8); + sha1_msg_schedule_update(&X12, X14, X4, X9); + sha1_msg_schedule_update(&X13, X15, X5, X10); + sha1_msg_schedule_update(&X14, X0, X6, X11); + sha1_msg_schedule_update(&X15, X1, X7, X12); - c->h0 = (c->h0 + E)&0xffffffffL; - c->h1 = (c->h1 + T)&0xffffffffL; - c->h2 = (c->h2 + A)&0xffffffffL; - c->h3 = (c->h3 + B)&0xffffffffL; - c->h4 = (c->h4 + C)&0xffffffffL; + sha1_round3(&a, &b, &c, &d, &e, X0); + sha1_round3(&a, &b, &c, &d, &e, X1); + sha1_round3(&a, &b, &c, &d, &e, X2); + sha1_round3(&a, &b, &c, &d, &e, X3); + sha1_round3(&a, &b, &c, &d, &e, X4); + sha1_round3(&a, &b, &c, &d, &e, X5); + sha1_round3(&a, &b, &c, &d, &e, X6); + sha1_round3(&a, &b, &c, &d, &e, X7); + sha1_round3(&a, &b, &c, &d, &e, X8); + sha1_round3(&a, &b, &c, &d, &e, X9); + sha1_round3(&a, &b, &c, &d, &e, X10); + sha1_round3(&a, &b, &c, &d, &e, X11); + sha1_round4(&a, &b, &c, &d, &e, X12); + sha1_round4(&a, &b, &c, &d, &e, X13); + sha1_round4(&a, &b, &c, &d, &e, X14); + sha1_round4(&a, &b, &c, &d, &e, X15); + + sha1_msg_schedule_update(&X0, X2, X8, X13); + sha1_msg_schedule_update(&X1, X3, X9, X14); + sha1_msg_schedule_update(&X2, X4, X10, X15); + sha1_msg_schedule_update(&X3, X5, X11, X0); + sha1_msg_schedule_update(&X4, X6, X12, X1); + sha1_msg_schedule_update(&X5, X7, X13, X2); + sha1_msg_schedule_update(&X6, X8, X14, X3); + sha1_msg_schedule_update(&X7, X9, X15, X4); + sha1_msg_schedule_update(&X8, X10, X0, X5); + sha1_msg_schedule_update(&X9, X11, X1, X6); + sha1_msg_schedule_update(&X10, X12, X2, X7); + sha1_msg_schedule_update(&X11, X13, X3, X8); + sha1_msg_schedule_update(&X12, X14, X4, X9); + sha1_msg_schedule_update(&X13, X15, X5, X10); + sha1_msg_schedule_update(&X14, X0, X6, X11); + sha1_msg_schedule_update(&X15, X1, X7, X12); + + sha1_round4(&a, &b, &c, &d, &e, X0); + sha1_round4(&a, &b, &c, &d, &e, X1); + sha1_round4(&a, &b, &c, &d, &e, X2); + sha1_round4(&a, &b, &c, &d, &e, X3); + sha1_round4(&a, &b, &c, &d, &e, X4); + sha1_round4(&a, &b, &c, &d, &e, X5); + sha1_round4(&a, &b, &c, &d, &e, X6); + sha1_round4(&a, &b, &c, &d, &e, X7); + sha1_round4(&a, &b, &c, &d, &e, X8); + sha1_round4(&a, &b, &c, &d, &e, X9); + sha1_round4(&a, &b, &c, &d, &e, X10); + sha1_round4(&a, &b, &c, &d, &e, X11); + sha1_round4(&a, &b, &c, &d, &e, X12); + sha1_round4(&a, &b, &c, &d, &e, X13); + sha1_round4(&a, &b, &c, &d, &e, X14); + sha1_round4(&a, &b, &c, &d, &e, X15); + + ctx->h0 += a; + ctx->h1 += b; + ctx->h2 += c; + ctx->h3 += d; + ctx->h4 += e; } } #endif - int SHA1_Init(SHA_CTX *c) { diff --git a/lib/libcrypto/sha/sha256.c b/lib/libcrypto/sha/sha256.c index 00c936811..d18e8d219 100644 --- a/lib/libcrypto/sha/sha256.c +++ b/lib/libcrypto/sha/sha256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha256.c,v 1.30 2023/08/11 15:27:28 jsing Exp $ */ +/* $OpenBSD: sha256.c,v 1.31 2024/03/28 04:23:02 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -131,16 +131,14 @@ Maj(SHA_LONG x, SHA_LONG y, SHA_LONG z) } static inline void -sha256_msg_schedule_update(SHA_LONG *W0, SHA_LONG W1, - SHA_LONG W9, SHA_LONG W14) +sha256_msg_schedule_update(SHA_LONG *W0, SHA_LONG W1, SHA_LONG W9, SHA_LONG W14) { *W0 = sigma1(W14) + W9 + sigma0(W1) + *W0; } static inline void -sha256_round(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, - SHA_LONG *e, SHA_LONG *f, SHA_LONG *g, SHA_LONG *h, - SHA_LONG Kt, SHA_LONG Wt) +sha256_round(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, + SHA_LONG *f, SHA_LONG *g, SHA_LONG *h, SHA_LONG Kt, SHA_LONG Wt) { SHA_LONG T1, T2; diff --git a/lib/libcrypto/sm3/sm3.c b/lib/libcrypto/sm3/sm3.c index 80be935f7..b10485dfe 100644 --- a/lib/libcrypto/sm3/sm3.c +++ b/lib/libcrypto/sm3/sm3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sm3.c,v 1.6 2023/07/08 06:36:55 jsing Exp $ */ +/* $OpenBSD: sm3.c,v 1.17 2024/03/28 12:09:09 jsing Exp $ */ /* * Copyright (c) 2018, Ribose Inc * @@ -15,42 +15,21 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifndef OPENSSL_NO_SM3 - -#include - #include #include -#define DATA_ORDER_IS_BIG_ENDIAN +#include -#define HASH_LONG SM3_WORD -#define HASH_CTX SM3_CTX -#define HASH_CBLOCK SM3_CBLOCK -#define HASH_UPDATE SM3_Update -#define HASH_TRANSFORM SM3_Transform -#define HASH_FINAL SM3_Final -#define HASH_MAKE_STRING(c, s) do { \ - unsigned long ll; \ - ll = (c)->A; HOST_l2c(ll, (s)); \ - ll = (c)->B; HOST_l2c(ll, (s)); \ - ll = (c)->C; HOST_l2c(ll, (s)); \ - ll = (c)->D; HOST_l2c(ll, (s)); \ - ll = (c)->E; HOST_l2c(ll, (s)); \ - ll = (c)->F; HOST_l2c(ll, (s)); \ - ll = (c)->G; HOST_l2c(ll, (s)); \ - ll = (c)->H; HOST_l2c(ll, (s)); \ -} while (0) -#define HASH_BLOCK_DATA_ORDER SM3_block_data_order +#include "crypto_internal.h" -void SM3_block_data_order(SM3_CTX *c, const void *p, size_t num); -void SM3_transform(SM3_CTX *c, const unsigned char *data); +/* Ensure that SM3_WORD and uint32_t are equivalent size. */ +CTASSERT(sizeof(SM3_WORD) == sizeof(uint32_t)); -#include "md32_common.h" +#ifndef OPENSSL_NO_SM3 -#define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17)) -#define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23)) +#define P0(X) (X ^ crypto_rol_u32(X, 9) ^ crypto_rol_u32(X, 17)) +#define P1(X) (X ^ crypto_rol_u32(X, 15) ^ crypto_rol_u32(X, 23)) #define FF0(X, Y, Z) (X ^ Y ^ Z) #define GG0(X, Y, Z) (X ^ Y ^ Z) @@ -59,17 +38,17 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data); #define GG1(X, Y, Z) ((Z ^ (X & (Y ^ Z)))) #define EXPAND(W0, W7, W13, W3, W10) \ - (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10) + (P1(W0 ^ W7 ^ crypto_rol_u32(W13, 15)) ^ crypto_rol_u32(W3, 7) ^ W10) #define ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) do { \ - const SM3_WORD A12 = ROTATE(A, 12); \ + const SM3_WORD A12 = crypto_rol_u32(A, 12); \ const SM3_WORD A12_SM = A12 + E + TJ; \ - const SM3_WORD SS1 = ROTATE(A12_SM, 7); \ + const SM3_WORD SS1 = crypto_rol_u32(A12_SM, 7); \ const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \ const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \ - B = ROTATE(B, 9); \ + B = crypto_rol_u32(B, 9); \ D = TT1; \ - F = ROTATE(F, 19); \ + F = crypto_rol_u32(F, 19); \ H = P0(TT2); \ } while(0) @@ -79,38 +58,11 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data); #define R2(A, B, C, D, E, F, G, H, TJ, Wi, Wj) \ ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF1, GG1) -#define SM3_A 0x7380166fUL -#define SM3_B 0x4914b2b9UL -#define SM3_C 0x172442d7UL -#define SM3_D 0xda8a0600UL -#define SM3_E 0xa96f30bcUL -#define SM3_F 0x163138aaUL -#define SM3_G 0xe38dee4dUL -#define SM3_H 0xb0fb0e4eUL - -LCRYPTO_ALIAS(SM3_Update); -LCRYPTO_ALIAS(SM3_Final); - -int -SM3_Init(SM3_CTX *c) +static void +sm3_block_data_order(SM3_CTX *ctx, const void *_in, size_t num) { - memset(c, 0, sizeof(*c)); - c->A = SM3_A; - c->B = SM3_B; - c->C = SM3_C; - c->D = SM3_D; - c->E = SM3_E; - c->F = SM3_F; - c->G = SM3_G; - c->H = SM3_H; - return 1; -} -LCRYPTO_ALIAS(SM3_Init); - -void -SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) -{ - const unsigned char *data = p; + const uint8_t *in = _in; + const SM3_WORD *in32; SM3_WORD A, B, C, D, E, F, G, H; SM3_WORD W00, W01, W02, W03, W04, W05, W06, W07; SM3_WORD W08, W09, W10, W11, W12, W13, W14, W15; @@ -129,22 +81,45 @@ SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) * We have to load all message bytes immediately since SM3 reads * them slightly out of order. */ - HOST_c2l(data, W00); - HOST_c2l(data, W01); - HOST_c2l(data, W02); - HOST_c2l(data, W03); - HOST_c2l(data, W04); - HOST_c2l(data, W05); - HOST_c2l(data, W06); - HOST_c2l(data, W07); - HOST_c2l(data, W08); - HOST_c2l(data, W09); - HOST_c2l(data, W10); - HOST_c2l(data, W11); - HOST_c2l(data, W12); - HOST_c2l(data, W13); - HOST_c2l(data, W14); - HOST_c2l(data, W15); + if ((uintptr_t)in % 4 == 0) { + /* Input is 32 bit aligned. */ + in32 = (const SM3_WORD *)in; + W00 = be32toh(in32[0]); + W01 = be32toh(in32[1]); + W02 = be32toh(in32[2]); + W03 = be32toh(in32[3]); + W04 = be32toh(in32[4]); + W05 = be32toh(in32[5]); + W06 = be32toh(in32[6]); + W07 = be32toh(in32[7]); + W08 = be32toh(in32[8]); + W09 = be32toh(in32[9]); + W10 = be32toh(in32[10]); + W11 = be32toh(in32[11]); + W12 = be32toh(in32[12]); + W13 = be32toh(in32[13]); + W14 = be32toh(in32[14]); + W15 = be32toh(in32[15]); + } else { + /* Input is not 32 bit aligned. */ + W00 = crypto_load_be32toh(&in[0 * 4]); + W01 = crypto_load_be32toh(&in[1 * 4]); + W02 = crypto_load_be32toh(&in[2 * 4]); + W03 = crypto_load_be32toh(&in[3 * 4]); + W04 = crypto_load_be32toh(&in[4 * 4]); + W05 = crypto_load_be32toh(&in[5 * 4]); + W06 = crypto_load_be32toh(&in[6 * 4]); + W07 = crypto_load_be32toh(&in[7 * 4]); + W08 = crypto_load_be32toh(&in[8 * 4]); + W09 = crypto_load_be32toh(&in[9 * 4]); + W10 = crypto_load_be32toh(&in[10 * 4]); + W11 = crypto_load_be32toh(&in[11 * 4]); + W12 = crypto_load_be32toh(&in[12 * 4]); + W13 = crypto_load_be32toh(&in[13 * 4]); + W14 = crypto_load_be32toh(&in[14 * 4]); + W15 = crypto_load_be32toh(&in[15 * 4]); + } + in += SM3_CBLOCK; R1(A, B, C, D, E, F, G, H, 0x79cc4519, W00, W00 ^ W04); W00 = EXPAND(W00, W07, W13, W03, W10); @@ -274,4 +249,113 @@ SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) } } +int +SM3_Init(SM3_CTX *c) +{ + memset(c, 0, sizeof(*c)); + + c->A = 0x7380166fUL; + c->B = 0x4914b2b9UL; + c->C = 0x172442d7UL; + c->D = 0xda8a0600UL; + c->E = 0xa96f30bcUL; + c->F = 0x163138aaUL; + c->G = 0xe38dee4dUL; + c->H = 0xb0fb0e4eUL; + + return 1; +} +LCRYPTO_ALIAS(SM3_Init); + +int +SM3_Update(SM3_CTX *c, const void *data_, size_t len) +{ + const unsigned char *data = data_; + unsigned char *p; + SM3_WORD l; + size_t n; + + if (len == 0) + return 1; + + l = (c->Nl + (((SM3_WORD)len) << 3))&0xffffffffUL; + /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to + * Wei Dai for pointing it out. */ + if (l < c->Nl) /* overflow */ + c->Nh++; + c->Nh+=(SM3_WORD)(len>>29); /* might cause compiler warning on 16-bit */ + c->Nl = l; + + n = c->num; + if (n != 0) { + p = (unsigned char *)c->data; + + if (len >= SM3_CBLOCK || len + n >= SM3_CBLOCK) { + memcpy(p + n, data, SM3_CBLOCK - n); + sm3_block_data_order(c, p, 1); + n = SM3_CBLOCK - n; + data += n; + len -= n; + c->num = 0; + memset(p, 0, SM3_CBLOCK); /* keep it zeroed */ + } else { + memcpy(p + n, data, len); + c->num += (unsigned int)len; + return 1; + } + } + + n = len / SM3_CBLOCK; + if (n > 0) { + sm3_block_data_order(c, data, n); + n *= SM3_CBLOCK; + data += n; + len -= n; + } + + if (len != 0) { + p = (unsigned char *)c->data; + c->num = (unsigned int)len; + memcpy(p, data, len); + } + return 1; +} +LCRYPTO_ALIAS(SM3_Update); + +int +SM3_Final(unsigned char *md, SM3_CTX *c) +{ + unsigned char *p = (unsigned char *)c->data; + size_t n = c->num; + + p[n] = 0x80; /* there is always room for one */ + n++; + + if (n > (SM3_CBLOCK - 8)) { + memset(p + n, 0, SM3_CBLOCK - n); + n = 0; + sm3_block_data_order(c, p, 1); + } + + memset(p + n, 0, SM3_CBLOCK - 8 - n); + c->data[SM3_LBLOCK - 2] = htobe32(c->Nh); + c->data[SM3_LBLOCK - 1] = htobe32(c->Nl); + + sm3_block_data_order(c, p, 1); + c->num = 0; + memset(p, 0, SM3_CBLOCK); + + crypto_store_htobe32(&md[0 * 4], c->A); + crypto_store_htobe32(&md[1 * 4], c->B); + crypto_store_htobe32(&md[2 * 4], c->C); + crypto_store_htobe32(&md[3 * 4], c->D); + crypto_store_htobe32(&md[4 * 4], c->E); + crypto_store_htobe32(&md[5 * 4], c->F); + crypto_store_htobe32(&md[6 * 4], c->G); + crypto_store_htobe32(&md[7 * 4], c->H); + + return 1; +} +LCRYPTO_ALIAS(SM3_Final); + #endif /* !OPENSSL_NO_SM3 */ diff --git a/lib/libcrypto/whrlpool/wp_dgst.c b/lib/libcrypto/whrlpool/wp_dgst.c index 71fd79c84..0e7c9c56d 100644 --- a/lib/libcrypto/whrlpool/wp_dgst.c +++ b/lib/libcrypto/whrlpool/wp_dgst.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wp_dgst.c,v 1.7 2023/09/04 08:43:41 tb Exp $ */ +/* $OpenBSD: wp_dgst.c,v 1.8 2024/03/29 00:16:22 jsing Exp $ */ /** * The Whirlpool hashing function. * @@ -58,92 +58,88 @@ #include "wp_local.h" -int WHIRLPOOL_Init(WHIRLPOOL_CTX *c) - { - memset (c,0,sizeof(*c)); - return(1); - } +int +WHIRLPOOL_Init(WHIRLPOOL_CTX *c) +{ + memset (c, 0, sizeof(*c)); + return (1); +} -int WHIRLPOOL_Update (WHIRLPOOL_CTX *c,const void *_inp,size_t bytes) - { +int +WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *_inp, size_t bytes) +{ /* Well, largest suitable chunk size actually is * (1<<(sizeof(size_t)*8-3))-64, but below number * is large enough for not to care about excessive * calls to WHIRLPOOL_BitUpdate... */ - size_t chunk = ((size_t)1)<<(sizeof(size_t)*8-4); + size_t chunk = ((size_t)1) << (sizeof(size_t)*8 - 4); const unsigned char *inp = _inp; - while (bytes>=chunk) - { - WHIRLPOOL_BitUpdate(c,inp,chunk*8); + while (bytes >= chunk) { + WHIRLPOOL_BitUpdate(c, inp, chunk*8); bytes -= chunk; - inp += chunk; - } - if (bytes) - WHIRLPOOL_BitUpdate(c,inp,bytes*8); - - return(1); + inp += chunk; } + if (bytes) + WHIRLPOOL_BitUpdate(c, inp, bytes*8); -void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits) - { + return (1); +} + +void +WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *_inp, size_t bits) +{ size_t n; unsigned int bitoff = c->bitoff, - bitrem = bitoff%8, - inpgap = (8-(unsigned int)bits%8)&7; - const unsigned char *inp=_inp; + bitrem = bitoff % 8, + inpgap = (8 - (unsigned int)bits % 8)&7; + const unsigned char *inp = _inp; /* This 256-bit increment procedure relies on the size_t * being natural size of CPU register, so that we don't * have to mask the value in order to detect overflows. */ c->bitlen[0] += bits; if (c->bitlen[0] < bits) /* overflow */ - { + { n = 1; - do { c->bitlen[n]++; - } while(c->bitlen[n]==0 - && ++n<(WHIRLPOOL_COUNTER/sizeof(size_t))); - } + do { + c->bitlen[n]++; + } while (c->bitlen[n]==0 && + ++n < (WHIRLPOOL_COUNTER/sizeof(size_t))); + } #ifndef OPENSSL_SMALL_FOOTPRINT - reconsider: +reconsider: if (inpgap==0 && bitrem==0) /* byte-oriented loop */ - { - while (bits) - { - if (bitoff==0 && (n=bits/WHIRLPOOL_BBLOCK)) - { - whirlpool_block(c,inp,n); - inp += n*WHIRLPOOL_BBLOCK/8; + { + while (bits) { + if (bitoff == 0 && (n = bits/WHIRLPOOL_BBLOCK)) { + whirlpool_block(c, inp, n); + inp += n*WHIRLPOOL_BBLOCK/8; bits %= WHIRLPOOL_BBLOCK; - } - else - { + } else { unsigned int byteoff = bitoff/8; bitrem = WHIRLPOOL_BBLOCK - bitoff;/* re-use bitrem */ - if (bits >= bitrem) - { + if (bits >= bitrem) { bits -= bitrem; bitrem /= 8; - memcpy(c->data+byteoff,inp,bitrem); - inp += bitrem; - whirlpool_block(c,c->data,1); + memcpy(c->data + byteoff, inp, bitrem); + inp += bitrem; + whirlpool_block(c, c->data, 1); bitoff = 0; - } - else - { - memcpy(c->data+byteoff,inp,bits/8); + } else { + memcpy(c->data + byteoff, inp, bits/8); bitoff += (unsigned int)bits; bits = 0; - } - c->bitoff = bitoff; } + c->bitoff = bitoff; } } + } else /* bit-oriented loop */ #endif - { + { /* inp | @@ -156,113 +152,116 @@ void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c,const void *_inp,size_t bits) | c->bitoff/8 */ - while (bits) - { - unsigned int byteoff = bitoff/8; + while (bits) { + unsigned int byteoff = bitoff/8; unsigned char b; #ifndef OPENSSL_SMALL_FOOTPRINT - if (bitrem==inpgap) - { - c->data[byteoff++] |= inp[0] & (0xff>>inpgap); - inpgap = 8-inpgap; + if (bitrem == inpgap) { + c->data[byteoff++] |= inp[0] & (0xff >> inpgap); + inpgap = 8 - inpgap; bitoff += inpgap; bitrem = 0; /* bitoff%8 */ bits -= inpgap; inpgap = 0; /* bits%8 */ inp++; - if (bitoff==WHIRLPOOL_BBLOCK) - { - whirlpool_block(c,c->data,1); + if (bitoff == WHIRLPOOL_BBLOCK) { + whirlpool_block(c, c->data, 1); bitoff = 0; - } + } c->bitoff = bitoff; goto reconsider; - } - else + } else #endif - if (bits>=8) - { - b = ((inp[0]<>(8-inpgap))); + if (bits >= 8) { + b = ((inp[0]<>(8 - inpgap))); b &= 0xff; - if (bitrem) c->data[byteoff++] |= b>>bitrem; - else c->data[byteoff++] = b; + if (bitrem) + c->data[byteoff++] |= b >> bitrem; + else + c->data[byteoff++] = b; bitoff += 8; - bits -= 8; + bits -= 8; inp++; - if (bitoff>=WHIRLPOOL_BBLOCK) - { - whirlpool_block(c,c->data,1); - byteoff = 0; + if (bitoff >= WHIRLPOOL_BBLOCK) { + whirlpool_block(c, c->data, 1); + byteoff = 0; bitoff %= WHIRLPOOL_BBLOCK; - } - if (bitrem) c->data[byteoff] = b<<(8-bitrem); } - else /* remaining less than 8 bits */ - { - b = (inp[0]<data[byteoff++] |= b>>bitrem; - else c->data[byteoff++] = b; - bitoff += (unsigned int)bits; - if (bitoff==WHIRLPOOL_BBLOCK) - { - whirlpool_block(c,c->data,1); - byteoff = 0; - bitoff %= WHIRLPOOL_BBLOCK; - } - if (bitrem) c->data[byteoff] = b<<(8-bitrem); - bits = 0; - } - c->bitoff = bitoff; + if (bitrem) + c->data[byteoff] = b << (8 - bitrem); } + else /* remaining less than 8 bits */ + { + b = (inp[0]<data[byteoff++] |= b >> bitrem; + else + c->data[byteoff++] = b; + bitoff += (unsigned int)bits; + if (bitoff == WHIRLPOOL_BBLOCK) { + whirlpool_block(c, c->data, 1); + byteoff = 0; + bitoff %= WHIRLPOOL_BBLOCK; + } + if (bitrem) + c->data[byteoff] = b << (8 - bitrem); + bits = 0; + } + c->bitoff = bitoff; } } +} -int WHIRLPOOL_Final (unsigned char *md,WHIRLPOOL_CTX *c) - { - unsigned int bitoff = c->bitoff, - byteoff = bitoff/8; - size_t i,j,v; +int +WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c) +{ + unsigned int bitoff = c->bitoff, + byteoff = bitoff/8; + size_t i, j, v; unsigned char *p; bitoff %= 8; - if (bitoff) c->data[byteoff] |= 0x80>>bitoff; - else c->data[byteoff] = 0x80; + if (bitoff) + c->data[byteoff] |= 0x80 >> bitoff; + else + c->data[byteoff] = 0x80; byteoff++; /* pad with zeros */ - if (byteoff > (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)) - { - if (byteoffdata[byteoff],0,WHIRLPOOL_BBLOCK/8-byteoff); - whirlpool_block(c,c->data,1); + if (byteoff > (WHIRLPOOL_BBLOCK/8 - WHIRLPOOL_COUNTER)) { + if (byteoff < WHIRLPOOL_BBLOCK/8) + memset(&c->data[byteoff], 0, WHIRLPOOL_BBLOCK/8 - byteoff); + whirlpool_block(c, c->data, 1); byteoff = 0; - } - if (byteoff < (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)) - memset(&c->data[byteoff],0, - (WHIRLPOOL_BBLOCK/8-WHIRLPOOL_COUNTER)-byteoff); + } + if (byteoff < (WHIRLPOOL_BBLOCK/8 - WHIRLPOOL_COUNTER)) + memset(&c->data[byteoff], 0, + (WHIRLPOOL_BBLOCK/8 - WHIRLPOOL_COUNTER) - byteoff); /* smash 256-bit c->bitlen in big-endian order */ p = &c->data[WHIRLPOOL_BBLOCK/8-1]; /* last byte in c->data */ - for(i=0;ibitlen[i],j=0;j>=8) + for (i = 0; i < WHIRLPOOL_COUNTER/sizeof(size_t); i++) + for (v = c->bitlen[i], j = 0; j < sizeof(size_t); j++, v >>= 8) *p-- = (unsigned char)(v&0xff); - whirlpool_block(c,c->data,1); + whirlpool_block(c, c->data, 1); if (md) { - memcpy(md,c->H.c,WHIRLPOOL_DIGEST_LENGTH); - memset(c,0,sizeof(*c)); - return(1); - } - return(0); + memcpy(md, c->H.c, WHIRLPOOL_DIGEST_LENGTH); + memset(c, 0, sizeof(*c)); + return (1); } + return (0); +} -unsigned char *WHIRLPOOL(const void *inp, size_t bytes,unsigned char *md) - { +unsigned char * +WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md) +{ WHIRLPOOL_CTX ctx; static unsigned char m[WHIRLPOOL_DIGEST_LENGTH]; - if (md == NULL) md=m; + if (md == NULL) + md = m; WHIRLPOOL_Init(&ctx); - WHIRLPOOL_Update(&ctx,inp,bytes); - WHIRLPOOL_Final(md,&ctx); - return(md); - } + WHIRLPOOL_Update(&ctx, inp, bytes); + WHIRLPOOL_Final(md, &ctx); + return (md); +} diff --git a/lib/libcrypto/x509/x509_vpm.c b/lib/libcrypto/x509/x509_vpm.c index a3fa84448..674c8e445 100644 --- a/lib/libcrypto/x509/x509_vpm.c +++ b/lib/libcrypto/x509/x509_vpm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vpm.c,v 1.42 2024/01/08 09:51:09 tb Exp $ */ +/* $OpenBSD: x509_vpm.c,v 1.43 2024/03/29 00:25:32 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2004. */ @@ -82,7 +82,7 @@ int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, const unsigned char *ip, static void str_free(char *s) { - free(s); + free(s); } static STACK_OF(OPENSSL_STRING) * diff --git a/lib/libcrypto/x86_64cpuid.pl b/lib/libcrypto/x86_64cpuid.pl index 5e85c40c9..a735a97f6 100644 --- a/lib/libcrypto/x86_64cpuid.pl +++ b/lib/libcrypto/x86_64cpuid.pl @@ -15,17 +15,7 @@ open OUT,"| \"$^X\" $xlate $flavour $output"; ($arg1,$arg2,$arg3,$arg4)=("%rdi","%rsi","%rdx","%rcx"); # Unix order print<<___; -.extern OPENSSL_cpuid_setup -.hidden OPENSSL_cpuid_setup -.section .init - _CET_ENDBR - call OPENSSL_cpuid_setup - -.extern OPENSSL_ia32cap_P -.hidden OPENSSL_ia32cap_P - .text - .globl OPENSSL_ia32_cpuid .type OPENSSL_ia32_cpuid,\@abi-omnipotent .align 16 diff --git a/lib/libcrypto/x86cpuid.pl b/lib/libcrypto/x86cpuid.pl index e081957f0..89ca7b670 100644 --- a/lib/libcrypto/x86cpuid.pl +++ b/lib/libcrypto/x86cpuid.pl @@ -150,8 +150,4 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } &set_label("nocpuid"); &function_end("OPENSSL_ia32_cpuid"); -&external_label("OPENSSL_ia32cap_P"); - -&initseg("OPENSSL_cpuid_setup"); - &asm_finish(); diff --git a/lib/libtls/tls_config.c b/lib/libtls/tls_config.c index 645562e83..10dc5003c 100644 --- a/lib/libtls/tls_config.c +++ b/lib/libtls/tls_config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_config.c,v 1.69 2024/03/27 07:35:30 joshua Exp $ */ +/* $OpenBSD: tls_config.c,v 1.70 2024/03/28 06:55:02 joshua Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -301,7 +301,8 @@ tls_config_parse_alpn(struct tls_config *config, const char *alpn, *alpn_len = 0; if ((buf_len = strlen(alpn) + 1) > 65535) { - tls_config_set_errorx(config, TLS_ERROR_UNKNOWN, "alpn too large"); + tls_config_set_errorx(config, TLS_ERROR_INVALID_ARGUMENT, + "alpn too large"); goto err; } @@ -865,7 +866,7 @@ tls_config_set_session_id(struct tls_config *config, const unsigned char *session_id, size_t len) { if (len > TLS_MAX_SESSION_ID_LENGTH) { - tls_config_set_errorx(config, TLS_ERROR_UNKNOWN, + tls_config_set_errorx(config, TLS_ERROR_INVALID_ARGUMENT, "session ID too large"); return (-1); } @@ -878,12 +879,12 @@ int tls_config_set_session_lifetime(struct tls_config *config, int lifetime) { if (lifetime > TLS_MAX_SESSION_TIMEOUT) { - tls_config_set_errorx(config, TLS_ERROR_UNKNOWN, + tls_config_set_errorx(config, TLS_ERROR_INVALID_ARGUMENT, "session lifetime too large"); return (-1); } if (lifetime != 0 && lifetime < TLS_MIN_SESSION_TIMEOUT) { - tls_config_set_errorx(config, TLS_ERROR_UNKNOWN, + tls_config_set_errorx(config, TLS_ERROR_INVALID_ARGUMENT, "session lifetime too small"); return (-1); } diff --git a/lib/libtls/tls_signer.c b/lib/libtls/tls_signer.c index 95a3640d7..d423b3b1c 100644 --- a/lib/libtls/tls_signer.c +++ b/lib/libtls/tls_signer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls_signer.c,v 1.11 2024/03/28 02:08:24 joshua Exp $ */ +/* $OpenBSD: tls_signer.c,v 1.12 2024/03/28 06:55:02 joshua Exp $ */ /* * Copyright (c) 2021 Eric Faurot * @@ -204,7 +204,7 @@ tls_sign_rsa(struct tls_signer *signer, struct tls_signer_key *skey, } if (input_len > INT_MAX) { - tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN, + tls_error_setx(&signer->error, TLS_ERROR_INVALID_ARGUMENT, "input too large"); return (-1); } @@ -252,7 +252,7 @@ tls_sign_ecdsa(struct tls_signer *signer, struct tls_signer_key *skey, } if (input_len > INT_MAX) { - tls_error_setx(&signer->error, TLS_ERROR_UNKNOWN, + tls_error_setx(&signer->error, TLS_ERROR_INVALID_ARGUMENT, "digest too large"); return (-1); } diff --git a/regress/lib/libcrypto/Makefile b/regress/lib/libcrypto/Makefile index 91e8645ed..32147fd48 100644 --- a/regress/lib/libcrypto/Makefile +++ b/regress/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.54 2023/12/27 12:34:32 jsing Exp $ +# $OpenBSD: Makefile,v 1.55 2024/03/28 06:45:36 beck Exp $ SUBDIR += aead SUBDIR += aes @@ -26,7 +26,6 @@ SUBDIR += evp SUBDIR += exdata SUBDIR += free SUBDIR += gcm128 -SUBDIR += gost SUBDIR += hkdf SUBDIR += hmac SUBDIR += idea diff --git a/regress/lib/libcrypto/gost/Makefile b/regress/lib/libcrypto/gost/Makefile deleted file mode 100644 index 14b0f9b82..000000000 --- a/regress/lib/libcrypto/gost/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2014/11/09 19:45:26 miod Exp $ - -PROG= gost2814789t -LDADD= -lcrypto -DPADD= ${LIBCRYPTO} -WARNINGS= Yes -CFLAGS+= -DLIBRESSL_INTERNAL -Werror - -.include diff --git a/regress/lib/libcrypto/gost/gost2814789t.c b/regress/lib/libcrypto/gost/gost2814789t.c deleted file mode 100644 index 261b9271a..000000000 --- a/regress/lib/libcrypto/gost/gost2814789t.c +++ /dev/null @@ -1,1486 +0,0 @@ -/* $OpenBSD: gost2814789t.c,v 1.11 2024/02/29 20:06:24 tb Exp $ */ -/* vim: set fileencoding=ascii : Charset: ASCII */ -/* test/gostr2814789t.c */ -/* ==================================================================== - * Copyright (c) 2012 Crypto-Pro, Ltd., Serguei E. Leontiev, - * lse@cryptopro.ru - * - * This file is distributed under the same license as OpenSSL - * ==================================================================== - */ -#include -#include - -#if defined(OPENSSL_NO_GOST) -int main(int argc, char *argv[]) -{ - printf("No GOST 28147-89 support\n"); - return 0; -} -#else - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define G89_MAX_TC_LEN (2048) -#define G89_BLOCK_LEN (8) - -#undef U64 -#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -#define U64(C) C##UI64 -#elif defined(_LP64) || defined(__arch64__) -#define U64(C) C##UL -#else -#define U64(C) C##ULL -#endif - -typedef enum g89_mode_ { - G89_ECB, - G89_CFB, - G89_CNT, - G89_IMIT -} g89_mode; - -typedef struct g89_tc_ { - uint64_t ullLen; /* ullLen > G89_MAX_TC_LEN */ - /* Clear text ullLen */ - /* of zero unsigned chars */ - const unsigned char bIn[G89_MAX_TC_LEN]; /* Clear text, when */ - /* ullLen <= G89_MAX_TC_LEN */ - const char *szParamSet; /* S-Box ID */ - const char *szDerive; /* String for derive bRawKey */ - const unsigned char bRawKey[EVP_MAX_KEY_LENGTH]; - g89_mode gMode; /* Mode of encryption or MAC */ - const unsigned char bIV[EVP_MAX_IV_LENGTH]; /* IV for CFB or CNT mode */ - const unsigned char bOut[G89_MAX_TC_LEN]; /* Cipher text for ECB/CFB/CNT */ - /* mode, when ullLen <= G89_MAX_TC_LEN; - * Last 16 unsigned char of cipher text for - * ECB/CFB/CNT, when ullLen > - * G89_MAX_TC_LEN; - * 4 unsigned char MAC for imitovstavka */ -} g89_tc; - -const g89_tc tcs[] = { - /* - * GOST R 34.11-94 Test cases - */ - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 1, K[1], see Errata for RFC 5831 */ - 8, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - "id-GostR3411-94-TestParamSet", - NULL, - { - 0x54, 0x6d, 0x20, 0x33, 0x68, 0x65, 0x6c, 0x32, - 0x69, 0x73, 0x65, 0x20, 0x73, 0x73, 0x6e, 0x62, - 0x20, 0x61, 0x67, 0x79, 0x69, 0x67, 0x74, 0x74, - 0x73, 0x65, 0x68, 0x65, 0x20, 0x2c, 0x3d, 0x73 - }, - G89_ECB, - { 0 }, - { - 0x1b, 0x0b, 0xbc, 0x32, 0xce, 0xbc, 0xab, 0x42 - } - }, - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 1, K[4] */ - 8, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - "id-GostR3411-94-TestParamSet", - NULL, - { - 0xec, 0x0a, 0x8b, 0xa1, 0x5e, 0xc0, 0x04, 0xa8, - 0xba, 0xc5, 0x0c, 0xac, 0x0c, 0x62, 0x1d, 0xee, - 0xe1, 0xc7, 0xb8, 0xe7, 0x00, 0x7a, 0xe2, 0xec, - 0xf2, 0x73, 0x1b, 0xff, 0x4e, 0x80, 0xe2, 0xa0 - }, - G89_ECB, - { 0 }, - { - 0x2d, 0x56, 0x2a, 0x0d, 0x19, 0x04, 0x86, 0xe7 - } - }, - { /* see p. A.3.1 [GOSTR341194], p. 7.3.1 [ENG-GOSTR341194] */ - /* */ - /* Iteration 2, K[1] */ - 8, - { - 0x34, 0xc0, 0x15, 0x33, 0xe3, 0x7d, 0x1c, 0x56 - }, - "id-GostR3411-94-TestParamSet", - NULL, - { - 0x34, 0x87, 0x24, 0xa4, 0xc1, 0xa6, 0x76, 0x67, - 0x15, 0x3d, 0xde, 0x59, 0x33, 0x88, 0x42, 0x50, - 0xe3, 0x24, 0x8c, 0x65, 0x7d, 0x41, 0x3b, 0x8c, - 0x1c, 0x9c, 0xa0, 0x9a, 0x56, 0xd9, 0x68, 0xcf - }, - G89_ECB, - { 0 }, - { - 0x86, 0x3e, 0x78, 0xdd, 0x2d, 0x60, 0xd1, 0x3c - } - }, - /* - * id-Gost28147-89-CryptoPro-A-ParamSet (1.2.643.2.2.31.1) - * Test cases - */ - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x74, 0x3d, 0x76, 0xf9, 0x1b, 0xee, 0x35, 0x3c, - 0xa2, 0x5c, 0x3b, 0x10, 0xeb, 0x64, 0xcf, 0xf5 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testecb1", - { - 0xbb, 0xf1, 0xed, 0xd3, 0x20, 0xaf, 0x8a, 0x62, - 0x8e, 0x11, 0xc8, 0xa9, 0x51, 0xcc, 0xbe, 0x81, - 0x47, 0x7b, 0x41, 0xa1, 0x6a, 0xf6, 0x7f, 0x05, - 0xe8, 0x51, 0x2f, 0x9e, 0x01, 0xf8, 0xcf, 0x49 - }, - G89_ECB, - { 0 }, - { - 0xc3, 0x73, 0x90, 0x95, 0x35, 0x58, 0x08, 0x63, - 0xcb, 0x68, 0x85, 0x96, 0x77, 0xe8, 0xfb, 0xa9 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0xd2, 0xfd, 0xf8, 0x3a, 0xc1, 0xb4, 0x39, 0x23, - 0x2e, 0xaa, 0xcc, 0x98, 0x0a, 0x02, 0xda, 0x33 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcfb1", - { - 0x8d, 0x5a, 0x2c, 0x83, 0xa7, 0xc7, 0x0a, 0x61, - 0xd6, 0x1b, 0x34, 0xb5, 0x1f, 0xdf, 0x42, 0x68, - 0x66, 0x71, 0xa3, 0x5d, 0x87, 0x4c, 0xfd, 0x84, - 0x99, 0x36, 0x63, 0xb6, 0x1e, 0xd6, 0x0d, 0xad - }, - G89_CFB, - { - 0x46, 0x60, 0x6f, 0x0d, 0x88, 0x34, 0x23, 0x5a - }, - { - 0x88, 0xb7, 0x75, 0x16, 0x74, 0xa5, 0xee, 0x2d, - 0x14, 0xfe, 0x91, 0x67, 0xd0, 0x5c, 0xcc, 0x40 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x90, 0xa2, 0x39, 0x66, 0xae, 0x01, 0xb9, 0xa3, - 0x52, 0x4e, 0xc8, 0xed, 0x6c, 0xdd, 0x88, 0x30 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcnt1", - { - 0x59, 0x9f, 0x84, 0xba, 0xc3, 0xf3, 0xd2, 0xf1, - 0x60, 0xe1, 0xe3, 0xf2, 0x6a, 0x96, 0x1a, 0xf9, - 0x9c, 0x48, 0xb2, 0x4e, 0xbc, 0xbb, 0xbf, 0x7c, - 0xd8, 0xf3, 0xac, 0xcd, 0x96, 0x8d, 0x28, 0x6a - }, - G89_CNT, - { - 0x8d, 0xaf, 0xa8, 0xd1, 0x58, 0xed, 0x05, 0x8d - }, - { - 0x6e, 0x72, 0x62, 0xcc, 0xe3, 0x59, 0x36, 0x90, - 0x83, 0x3a, 0xfe, 0xa9, 0x1b, 0xc9, 0xbe, 0xce - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0xb5, 0xa1, 0xf0, 0xe3, 0xce, 0x2f, 0x02, 0x1d, - 0x67, 0x61, 0x94, 0x34, 0x5c, 0x41, 0xe3, 0x6e - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit1", - { - 0x9d, 0x05, 0xb7, 0x9e, 0x90, 0xca, 0xd0, 0x0a, - 0x2c, 0xda, 0xd2, 0x2e, 0xf4, 0xe8, 0x6f, 0x5c, - 0xf5, 0xdc, 0x37, 0x68, 0x19, 0x85, 0xb3, 0xbf, - 0xaa, 0x18, 0xc1, 0xc3, 0x05, 0x0a, 0x91, 0xa2 - }, - G89_IMIT, - { 0 }, - { - 0xf8, 0x1f, 0x08, 0xa3 - } - }, - /* - * Other paramsets and key meshing test cases. - */ - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1039, - { - 0x8c, 0x9c, 0x44, 0x35, 0xfb, 0xe9, 0xa5, 0xa3, - 0xa0, 0xae, 0x28, 0x56, 0x91, 0x10, 0x8e, 0x1e , - 0xd2, 0xbb, 0x18, 0x53, 0x81, 0x27, 0x0d, 0xa6, - 0x68, 0x59, 0x36, 0xc5, 0x81, 0x62, 0x9a, 0x8e, - 0x7d, 0x50, 0xf1, 0x6f, 0x97, 0x62, 0x29, 0xec, - 0x80, 0x51, 0xe3, 0x7d, 0x6c, 0xc4, 0x07, 0x95, - 0x28, 0x63, 0xdc, 0xb4, 0xb9, 0x2d, 0xb8, 0x13, - 0xb1, 0x05, 0xb5, 0xf9, 0xeb, 0x75, 0x37, 0x4e, - 0xf7, 0xbf, 0x51, 0xf1, 0x98, 0x86, 0x43, 0xc4, - 0xe4, 0x3d, 0x3e, 0xa7, 0x62, 0xec, 0x41, 0x59, - 0xe0, 0xbd, 0xfb, 0xb6, 0xfd, 0xec, 0xe0, 0x77, - 0x13, 0xd2, 0x59, 0x90, 0xa1, 0xb8, 0x97, 0x6b, - 0x3d, 0x8b, 0x7d, 0xfc, 0x9d, 0xca, 0x82, 0x73, - 0x32, 0x70, 0x0a, 0x74, 0x03, 0xc6, 0x0c, 0x26, - 0x7f, 0x56, 0xf0, 0x9d, 0xb2, 0xeb, 0x71, 0x40, - 0xd7, 0xc3, 0xb1, 0xa7, 0xc5, 0x1e, 0x20, 0x17, - 0xb3, 0x50, 0x1d, 0x8a, 0x6e, 0x19, 0xcb, 0xbe, - 0x20, 0x86, 0x2b, 0xd6, 0x1c, 0xfd, 0xb4, 0xb7, - 0x5d, 0x9a, 0xb3, 0xe3, 0x7d, 0x15, 0x7a, 0x35, - 0x01, 0x9f, 0x5d, 0x65, 0x89, 0x4b, 0x34, 0xc6, - 0xf4, 0x81, 0x3f, 0x78, 0x30, 0xcf, 0xe9, 0x15, - 0x90, 0x9a, 0xf9, 0xde, 0xba, 0x63, 0xd0, 0x19, - 0x14, 0x66, 0x3c, 0xb9, 0xa4, 0xb2, 0x84, 0x94, - 0x02, 0xcf, 0xce, 0x20, 0xcf, 0x76, 0xe7, 0xc5, - 0x48, 0xf7, 0x69, 0x3a, 0x5d, 0xec, 0xaf, 0x41, - 0xa7, 0x12, 0x64, 0x83, 0xf5, 0x99, 0x1e, 0x9e, - 0xb2, 0xab, 0x86, 0x16, 0x00, 0x23, 0x8e, 0xe6, - 0xd9, 0x80, 0x0b, 0x6d, 0xc5, 0x93, 0xe2, 0x5c, - 0x8c, 0xd8, 0x5e, 0x5a, 0xae, 0x4a, 0x85, 0xfd, - 0x76, 0x01, 0xea, 0x30, 0xf3, 0x78, 0x34, 0x10, - 0x72, 0x51, 0xbc, 0x9f, 0x76, 0xce, 0x1f, 0xd4, - 0x8f, 0x33, 0x50, 0x34, 0xc7, 0x4d, 0x7b, 0xcf, - 0x91, 0x63, 0x7d, 0x82, 0x9e, 0xa1, 0x23, 0x45, - 0xf5, 0x45, 0xac, 0x98, 0x7a, 0x48, 0xff, 0x64, - 0xd5, 0x59, 0x47, 0xde, 0x2b, 0x3f, 0xfa, 0xec, - 0x50, 0xe0, 0x81, 0x60, 0x8b, 0xc3, 0xfc, 0x80, - 0x98, 0x17, 0xc7, 0xa3, 0xc2, 0x57, 0x3d, 0xab, - 0x91, 0x67, 0xf5, 0xc4, 0xab, 0x92, 0xc8, 0xd6, - 0x3b, 0x6b, 0x3f, 0xff, 0x15, 0x6b, 0xcf, 0x53, - 0x65, 0x02, 0xf1, 0x74, 0xca, 0xa9, 0xbe, 0x24, - 0xd2, 0xf0, 0xb7, 0x26, 0xa8, 0xd7, 0x6d, 0xed, - 0x90, 0x36, 0x7b, 0x3e, 0x41, 0xa9, 0x7f, 0xa3, - 0x1b, 0xf4, 0x43, 0xc5, 0x51, 0xbe, 0x28, 0x59, - 0xe9, 0x45, 0x26, 0x49, 0x38, 0x32, 0xf8, 0xf3, - 0x92, 0x6e, 0x30, 0xcc, 0xb0, 0xa0, 0xf9, 0x01, - 0x14, 0xc8, 0xba, 0xd9, 0xf0, 0x2a, 0x29, 0xe2, - 0x52, 0x9a, 0x76, 0x95, 0x3a, 0x16, 0x32, 0xec, - 0xf4, 0x10, 0xec, 0xee, 0x47, 0x00, 0x70, 0x19, - 0xe4, 0x72, 0x35, 0x66, 0x44, 0x53, 0x2d, 0xa2, - 0xf3, 0xaa, 0x7e, 0x8a, 0x33, 0x13, 0xcd, 0xc8, - 0xbf, 0x0e, 0x40, 0x90, 0x00, 0xe4, 0x42, 0xc3, - 0x09, 0x84, 0xe1, 0x66, 0x17, 0xa2, 0xaf, 0x03, - 0xab, 0x6b, 0xa1, 0xec, 0xfb, 0x17, 0x72, 0x81, - 0xfe, 0x9a, 0x9f, 0xf4, 0xb2, 0x33, 0x1f, 0xae, - 0x0c, 0xd1, 0x6a, 0xae, 0x19, 0xb8, 0xaf, 0xec, - 0xe3, 0xea, 0x00, 0xf8, 0xac, 0x87, 0x07, 0x5f, - 0x6d, 0xb0, 0xac, 0x6b, 0x22, 0x48, 0x36, 0xbf, - 0x22, 0x18, 0xb0, 0x03, 0x9f, 0x6c, 0x70, 0x45, - 0x36, 0xf0, 0x6b, 0xc6, 0xc2, 0xa5, 0x72, 0x2c, - 0xd8, 0xe0, 0x27, 0x3d, 0xec, 0x56, 0x07, 0x05, - 0x7d, 0x83, 0xa1, 0x65, 0x7d, 0x41, 0x5b, 0xcd, - 0x77, 0x24, 0xe5, 0xaa, 0x76, 0x47, 0xd0, 0x50, - 0xf6, 0xe7, 0xb5, 0x59, 0x75, 0x31, 0x27, 0xef, - 0xd8, 0xa6, 0x4e, 0x7f, 0xb8, 0x40, 0xb1, 0xdf, - 0x53, 0x14, 0xed, 0xf1, 0x68, 0x5f, 0xfc, 0x3f, - 0x02, 0xdb, 0x05, 0xeb, 0x31, 0xe4, 0x2c, 0x7f, - 0x32, 0xb5, 0x70, 0x8e, 0x75, 0x85, 0xa4, 0x5c, - 0x16, 0x23, 0x37, 0xf2, 0x10, 0x79, 0xcb, 0xdc, - 0xf8, 0x1c, 0x25, 0xc2, 0xa1, 0x3d, 0x9c, 0x33, - 0x6c, 0xed, 0xc3, 0xe7, 0xf3, 0x02, 0x87, 0x82, - 0x4e, 0xfb, 0xac, 0xb3, 0x2d, 0xfc, 0xf8, 0x0d, - 0x1d, 0x4a, 0x39, 0xd4, 0xb3, 0x09, 0xbb, 0xe9, - 0x25, 0xc7, 0xec, 0x6a, 0x87, 0x72, 0x84, 0xed, - 0x12, 0x60, 0x19, 0x64, 0xeb, 0x16, 0x2a, 0x5b, - 0x10, 0x76, 0x27, 0xff, 0x7b, 0xe4, 0xae, 0xe5, - 0xa4, 0x04, 0x02, 0x7f, 0xbb, 0x0a, 0xb5, 0xf4, - 0x05, 0xa5, 0x56, 0x1c, 0x53, 0x31, 0x7a, 0x93, - 0xba, 0x16, 0x15, 0xab, 0x62, 0x60, 0xfc, 0xde, - 0x72, 0x36, 0x6e, 0x28, 0xaf, 0x98, 0x0d, 0xe6, - 0xf4, 0xde, 0x60, 0xa7, 0x7e, 0x06, 0x07, 0x86, - 0xf3, 0x94, 0xb6, 0x6d, 0x0d, 0x93, 0xa6, 0xbc, - 0x60, 0x70, 0x33, 0xac, 0x3f, 0xa1, 0xa8, 0x4a, - 0x20, 0x61, 0xb6, 0xb5, 0x43, 0xa3, 0x15, 0x5a, - 0x00, 0xbe, 0x76, 0x98, 0x57, 0x72, 0xab, 0x7a, - 0x0e, 0x18, 0x93, 0x82, 0x3a, 0x18, 0x78, 0x6e, - 0x71, 0x7b, 0x78, 0x4f, 0x7e, 0x8c, 0xde, 0x7a, - 0x62, 0xb5, 0x0a, 0x7c, 0x45, 0x1d, 0x16, 0xd5, - 0xc3, 0x8c, 0x9b, 0x25, 0xb4, 0x50, 0x90, 0xcd, - 0x96, 0x93, 0xad, 0x0f, 0xd4, 0x43, 0xcb, 0x49, - 0x0f, 0xfc, 0x5a, 0x31, 0xf4, 0x19, 0xb7, 0xd4, - 0xeb, 0x4d, 0x40, 0x58, 0xd0, 0x3b, 0xc8, 0xe0, - 0x4a, 0x54, 0x2f, 0xdb, 0x22, 0xc3, 0x29, 0x7b, - 0x40, 0x90, 0x61, 0x43, 0xd3, 0x7e, 0xe2, 0x30, - 0x2b, 0x48, 0x3c, 0xce, 0x90, 0x93, 0xb1, 0x8b, - 0x31, 0x96, 0x65, 0x6d, 0x57, 0x8b, 0x9d, 0x4d, - 0x53, 0xf0, 0x83, 0x1c, 0xe5, 0xa1, 0x9d, 0x55, - 0xe3, 0xbf, 0x7e, 0xca, 0x1a, 0x74, 0x66, 0x14, - 0xcc, 0x47, 0x43, 0xd9, 0xbb, 0xef, 0x97, 0x7d, - 0xb7, 0x6e, 0xff, 0xf1, 0x22, 0xf8, 0x10, 0x2d, - 0x3f, 0xcd, 0x49, 0x96, 0xd9, 0x09, 0x11, 0xb8, - 0x33, 0xd0, 0x23, 0x9a, 0xfa, 0x16, 0xcb, 0x50, - 0x26, 0x57, 0x24, 0x5c, 0x0e, 0xba, 0xf0, 0x3f, - 0x37, 0x2f, 0xa3, 0xf7, 0x18, 0x57, 0x48, 0x48, - 0x95, 0xcf, 0xef, 0x87, 0x67, 0x2a, 0xe9, 0xb6, - 0x8a, 0x21, 0x36, 0x7f, 0xff, 0x48, 0x6c, 0x46, - 0x35, 0x57, 0xf2, 0xbc, 0x48, 0x67, 0x8f, 0x63, - 0x23, 0x78, 0x11, 0x2b, 0xc2, 0x08, 0xde, 0x51, - 0xe8, 0x8b, 0x92, 0x29, 0xf9, 0x9a, 0x9e, 0xad, - 0xed, 0x0f, 0xeb, 0xa2, 0xd2, 0x40, 0x92, 0xd4, - 0xde, 0x62, 0x95, 0x76, 0xfd, 0x6e, 0x3c, 0xbf, - 0xc0, 0xd7, 0x0d, 0xe5, 0x1b, 0xa4, 0xc7, 0x18, - 0xe1, 0x58, 0xa4, 0x56, 0xef, 0x2e, 0x17, 0x1b, - 0x75, 0xcb, 0xbc, 0xf9, 0x2a, 0x95, 0x71, 0xa7, - 0x1d, 0x7f, 0xe7, 0x73, 0x63, 0x05, 0x6b, 0x19, - 0x4c, 0xf4, 0x22, 0x14, 0xc4, 0x59, 0x88, 0x66, - 0x92, 0x86, 0x61, 0x5c, 0x6a, 0xae, 0xec, 0x58, - 0xff, 0xc9, 0xf2, 0x44, 0xd4, 0xa2, 0xf5, 0x98, - 0xeb, 0x5f, 0x09, 0xbc, 0x8a, 0xbf, 0x3c, 0xb4, - 0x3e, 0xb1, 0x20, 0x05, 0x44, 0x96, 0x79, 0x0a, - 0x40, 0x92, 0x7f, 0x9d, 0xd1, 0xaf, 0xbc, 0x90, - 0x95, 0x0a, 0x81, 0xd4, 0xa7, 0xc6, 0xb8, 0xe0, - 0xe4, 0x39, 0x30, 0x1d, 0x79, 0xc0, 0xe5, 0xfa, - 0xb4, 0xe9, 0x63, 0xb4, 0x09, 0x72, 0x3b, 0x3e, - 0xd9, 0xf6, 0xd9, 0x10, 0x21, 0x18, 0x7e, 0xe5, - 0xad, 0x81, 0xd7, 0xd5, 0x82, 0xd0, 0x8c, 0x3b, - 0x38, 0x95, 0xf8, 0x92, 0x01, 0xa9, 0x92, 0x00, - 0x70, 0xd1, 0xa7, 0x88, 0x77, 0x1f, 0x3a, 0xeb, - 0xb5, 0xe4, 0xf5, 0x9d, 0xc7, 0x37, 0x86, 0xb2, - 0x12, 0x46, 0x34, 0x19, 0x72, 0x8c, 0xf5, 0x8c, - 0xf6, 0x78, 0x98, 0xe0, 0x7c, 0xd3, 0xf4 - }, - "id-Gost28147-89-CryptoPro-B-ParamSet", - "testcfb2", - { - 0x48, 0x0c, 0x74, 0x1b, 0x02, 0x6b, 0x55, 0xd5, - 0xb6, 0x6d, 0xd7, 0x1d, 0x40, 0x48, 0x05, 0x6b, - 0x6d, 0xeb, 0x3c, 0x29, 0x0f, 0x84, 0x80, 0x23, - 0xee, 0x0d, 0x47, 0x77, 0xe3, 0xfe, 0x61, 0xc9 - }, - G89_CFB, - { - 0x1f, 0x3f, 0x82, 0x1e, 0x0d, 0xd8, 0x1e, 0x22 - }, - { - 0x23, 0xc6, 0x7f, 0x20, 0xa1, 0x23, 0x58, 0xbc, - 0x7b, 0x05, 0xdb, 0x21, 0x15, 0xcf, 0x96, 0x41, - 0xc7, 0x88, 0xef, 0x76, 0x5c, 0x49, 0xdb, 0x42, - 0xbf, 0xf3, 0xc0, 0xf5, 0xbd, 0x5d, 0xd9, 0x8e, - 0xaf, 0x3d, 0xf4, 0xe4, 0xda, 0x88, 0xbd, 0xbc, - 0x47, 0x5d, 0x76, 0x07, 0xc9, 0x5f, 0x54, 0x1d, - 0x1d, 0x6a, 0xa1, 0x2e, 0x18, 0xd6, 0x60, 0x84, - 0x02, 0x18, 0x37, 0x92, 0x92, 0x15, 0xab, 0x21, - 0xee, 0x21, 0xcc, 0x71, 0x6e, 0x51, 0xd9, 0x2b, - 0xcc, 0x81, 0x97, 0x3f, 0xeb, 0x45, 0x99, 0xb8, - 0x1b, 0xda, 0xff, 0x90, 0xd3, 0x41, 0x06, 0x9c, - 0x3f, 0xfb, 0xe4, 0xb2, 0xdc, 0xc9, 0x03, 0x0d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7, 0x0d, 0xc6, 0x8f, 0x91, - 0x66, 0x67, 0x82, 0x0f, 0x49, 0xc9, 0xc5, 0x65, - 0x81, 0xa1, 0x39, 0x5a, 0x53, 0x9f, 0x02, 0xa5, - 0xd5, 0x36, 0x22, 0xa8, 0xa8, 0x1c, 0x37, 0x0e, - 0x76, 0x46, 0xdf, 0xbd, 0x6a, 0xdb, 0xfc, 0x1b, - 0xbd, 0x10, 0xb8, 0xb1, 0xbc, 0x72, 0x4c, 0x58, - 0x4a, 0xda, 0x6d, 0x66, 0x00, 0xda, 0x7a, 0x66, - 0xa0, 0xe7, 0x3b, 0x39, 0xa3, 0xf7, 0x05, 0x07, - 0xfa, 0x21, 0x4b, 0xc7, 0x94, 0xc0, 0xd3, 0x7b, - 0x19, 0x02, 0x5d, 0x4a, 0x10, 0xf1, 0xc2, 0x0f, - 0x19, 0x68, 0x27, 0xc7, 0x7d, 0xbf, 0x55, 0x03, - 0x57, 0x7d, 0xaf, 0x77, 0xae, 0x80, 0x2f, 0x7a, - 0xe6, 0x1f, 0x4b, 0xdc, 0x15, 0x18, 0xc0, 0x62, - 0xa1, 0xe8, 0xd9, 0x1c, 0x9e, 0x8c, 0x96, 0x39, - 0xc1, 0xc4, 0x88, 0xf7, 0x0c, 0xe1, 0x04, 0x84, - 0x68, 0x51, 0xce, 0xf1, 0x90, 0xda, 0x7f, 0x76, - 0xc8, 0xc0, 0x88, 0xef, 0x8e, 0x15, 0x25, 0x3e, - 0x7b, 0xe4, 0x79, 0xb5, 0x66, 0x2d, 0x9c, 0xd1, - 0x13, 0xda, 0xd0, 0xd5, 0x46, 0xd5, 0x8d, 0x46, - 0x18, 0x07, 0xee, 0xd8, 0xc9, 0x64, 0xe3, 0xbe, - 0x0e, 0x68, 0x27, 0x09, 0x96, 0x26, 0xf6, 0xe2, - 0x19, 0x61, 0x3f, 0xf4, 0x58, 0x27, 0x0a, 0xeb, - 0xce, 0x7c, 0xb6, 0x68, 0x92, 0xe7, 0x12, 0x3b, - 0x31, 0xd4, 0x48, 0xdf, 0x35, 0x8d, 0xf4, 0x86, - 0x42, 0x2a, 0x15, 0x4b, 0xe8, 0x19, 0x1f, 0x26, - 0x65, 0x9b, 0xa8, 0xda, 0x4b, 0x79, 0x1f, 0x8e, - 0xe6, 0x13, 0x7e, 0x49, 0x8f, 0xc1, 0xce, 0xdc, - 0x5e, 0x64, 0x74, 0xce, 0x02, 0x78, 0xe0, 0xcf, - 0xa0, 0xed, 0x5e, 0x31, 0x74, 0xd1, 0xd0, 0xb4, - 0xee, 0x70, 0x19, 0x14, 0x3c, 0x8f, 0x16, 0xa6, - 0xcf, 0x12, 0x93, 0x15, 0x88, 0xeb, 0x91, 0x65, - 0x76, 0x98, 0xfd, 0xa1, 0x94, 0x30, 0xba, 0x43, - 0x62, 0x65, 0x40, 0x04, 0x77, 0x9e, 0xd6, 0xab, - 0x8b, 0x0d, 0x93, 0x80, 0x50, 0x5f, 0xa2, 0x76, - 0x20, 0xa7, 0xd6, 0x9c, 0x27, 0x15, 0x27, 0xbc, - 0xa5, 0x5a, 0xbf, 0xe9, 0x92, 0x82, 0x05, 0xa8, - 0x41, 0xe9, 0xb5, 0x60, 0xd5, 0xc0, 0xd7, 0x4b, - 0xad, 0x38, 0xb2, 0xe9, 0xd1, 0xe5, 0x51, 0x5f, - 0x24, 0x78, 0x24, 0x9a, 0x23, 0xd2, 0xc2, 0x48, - 0xbd, 0x0e, 0xf1, 0x37, 0x72, 0x91, 0x87, 0xb0, - 0x4e, 0xbd, 0x99, 0x6b, 0x2c, 0x01, 0xb6, 0x79, - 0x69, 0xec, 0x0c, 0xed, 0xe5, 0x3f, 0x50, 0x64, - 0x7c, 0xb9, 0xdd, 0xe1, 0x92, 0x81, 0xb5, 0xd0, - 0xcb, 0x17, 0x83, 0x86, 0x8b, 0xea, 0x4f, 0x93, - 0x08, 0xbc, 0x22, 0x0c, 0xef, 0xe8, 0x0d, 0xf5, - 0x9e, 0x23, 0xe1, 0xf9, 0xb7, 0x6b, 0x45, 0x0b, - 0xcb, 0xa9, 0xb6, 0x4d, 0x28, 0x25, 0xba, 0x3e, - 0x86, 0xf2, 0x75, 0x47, 0x5d, 0x9d, 0x6b, 0xf6, - 0x8a, 0x05, 0x58, 0x73, 0x3d, 0x00, 0xde, 0xfd, - 0x69, 0xb1, 0x61, 0x16, 0xf5, 0x2e, 0xb0, 0x9f, - 0x31, 0x6a, 0x00, 0xb9, 0xef, 0x71, 0x63, 0x47, - 0xa3, 0xca, 0xe0, 0x40, 0xa8, 0x7e, 0x02, 0x04, - 0xfe, 0xe5, 0xce, 0x48, 0x73, 0xe3, 0x94, 0xcf, - 0xe2, 0xff, 0x29, 0x7e, 0xf6, 0x32, 0xbb, 0xb7, - 0x55, 0x12, 0x21, 0x7a, 0x9c, 0x75, 0x04, 0x0c, - 0xb4, 0x7c, 0xb0, 0x3d, 0x40, 0xb3, 0x11, 0x9a, - 0x7a, 0x9a, 0x13, 0xfb, 0x77, 0xa7, 0x51, 0x68, - 0xf7, 0x05, 0x47, 0x3b, 0x0f, 0x52, 0x5c, 0xe6, - 0xc2, 0x99, 0x3a, 0x37, 0x54, 0x5c, 0x4f, 0x2b, - 0xa7, 0x01, 0x08, 0x74, 0xbc, 0x91, 0xe3, 0xe2, - 0xfe, 0x65, 0x94, 0xfd, 0x3d, 0x18, 0xe0, 0xf0, - 0x62, 0xed, 0xc2, 0x10, 0x82, 0x9c, 0x58, 0x7f, - 0xb2, 0xa3, 0x87, 0x8a, 0x74, 0xd9, 0xc1, 0xfb, - 0x84, 0x28, 0x17, 0xc7, 0x2b, 0xcb, 0x53, 0x1f, - 0x4e, 0x8a, 0x82, 0xfc, 0xb4, 0x3f, 0xc1, 0x47, - 0x25, 0xf3, 0x21, 0xdc, 0x4c, 0x2d, 0x08, 0xfa, - 0xe7, 0x0f, 0x03, 0xa9, 0x68, 0xde, 0x6b, 0x41, - 0xa0, 0xf9, 0x41, 0x6c, 0x57, 0x4d, 0x3a, 0x0e, - 0xea, 0x51, 0xca, 0x9f, 0x97, 0x11, 0x7d, 0xf6, - 0x8e, 0x88, 0x63, 0x67, 0xc9, 0x65, 0x13, 0xca, - 0x38, 0xed, 0x35, 0xbe, 0xf4, 0x27, 0xa9, 0xfc, - 0xa9, 0xe6, 0xc3, 0x40, 0x86, 0x08, 0x39, 0x72, - 0x37, 0xee, 0xb2, 0x87, 0x09, 0x96, 0xb7, 0x40, - 0x87, 0x36, 0x92, 0xc1, 0x5d, 0x6a, 0x2c, 0x43, - 0xca, 0x25, 0xc8, 0x35, 0x37, 0x2d, 0xb5, 0xa9, - 0x27, 0x44, 0x50, 0xf2, 0x6d, 0x22, 0x75, 0x41, - 0x77, 0x2a, 0xdb, 0xb1, 0x8c, 0x6d, 0x05, 0xe8, - 0xc9, 0x99, 0xc7, 0x08, 0xf9, 0x14, 0x8f, 0x78, - 0xa9, 0x8f, 0xc2, 0x5a, 0x7a, 0x65, 0xc5, 0xd8, - 0x86, 0xbb, 0x72, 0x69, 0x6b, 0x6b, 0x45, 0x83, - 0x5b, 0xb1, 0xf7, 0xcd, 0x16, 0x73, 0xee, 0xe9, - 0x80, 0x85, 0xfe, 0x8e, 0xe1, 0xae, 0x53, 0x8f, - 0xde, 0xbe, 0x48, 0x8b, 0x59, 0xef, 0xf6, 0x7e, - 0xd8, 0xb5, 0xa8, 0x47, 0xc0, 0x4e, 0x15, 0x58, - 0xca, 0xd3, 0x2f, 0xf8, 0x6c, 0xa6, 0x3d, 0x78, - 0x4d, 0x7a, 0x54, 0xd6, 0x10, 0xe5, 0xcc, 0x05, - 0xe2, 0x29, 0xb5, 0x86, 0x07, 0x39, 0x7d, 0x78, - 0x8e, 0x5a, 0x8f, 0x83, 0x4c, 0xe7, 0x3d, 0x68, - 0x3e, 0xe5, 0x02, 0xe6, 0x64, 0x4f, 0x5e, 0xb4, - 0x49, 0x77, 0xf0, 0xc0, 0xfa, 0x6f, 0xc8, 0xfb, - 0x9f, 0x84, 0x6f, 0x55, 0xfb, 0x30, 0x5e, 0x89, - 0x93, 0xa9, 0xf3, 0xa6, 0xa3, 0xd7, 0x26, 0xbb, - 0xd8, 0xa8, 0xd9, 0x95, 0x1d, 0xfe, 0xfc, 0xd7, - 0xa8, 0x93, 0x66, 0x2f, 0x04, 0x53, 0x06, 0x64, - 0x7f, 0x31, 0x29, 0xae, 0xb7, 0x9f, 0xba, 0xc4, - 0x6d, 0x68, 0xd1, 0x24, 0x32, 0xf4, 0x11 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 4, - { - 0x07, 0x9c, 0x91, 0xbe - }, - "id-Gost28147-89-CryptoPro-C-ParamSet", - "testcfb3", - { - 0x77, 0xc3, 0x45, 0x8e, 0xf6, 0x42, 0xe7, 0x04, - 0x8e, 0xfc, 0x08, 0xe4, 0x70, 0x96, 0xd6, 0x05, - 0x93, 0x59, 0x02, 0x6d, 0x6f, 0x97, 0xca, 0xe9, - 0xcf, 0x89, 0x44, 0x4b, 0xde, 0x6c, 0x22, 0x1d - }, - G89_CFB, - { - 0x43, 0x7c, 0x3e, 0x8e, 0x2f, 0x2a, 0x00, 0x98 - }, - { - 0x19, 0x35, 0x81, 0x34 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 9, - { - 0x2f, 0x31, 0xd8, 0x83, 0xb4, 0x20, 0xe8, 0x6e, - 0xda - }, - "id-Gost28147-89-CryptoPro-D-ParamSet", - "testcfb4", - { - 0x38, 0x9f, 0xe8, 0x37, 0xff, 0x9c, 0x5d, 0x29, - 0xfc, 0x48, 0x55, 0xa0, 0x87, 0xea, 0xe8, 0x40, - 0x20, 0x87, 0x5b, 0xb2, 0x01, 0x15, 0x55, 0xa7, - 0xe3, 0x2d, 0xcb, 0x3d, 0xd6, 0x59, 0x04, 0x73 - }, - G89_CFB, - { - 0xc5, 0xa2, 0xd2, 0x1f, 0x2f, 0xdf, 0xb8, 0xeb - }, - { - 0x6d, 0xa4, 0xed, 0x40, 0x08, 0x88, 0x71, 0xad, - 0x16 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880+8, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mcfb", - { - 0x61, 0x58, 0x44, 0x5a, 0x41, 0xf6, 0xc7, 0x0f, - 0x6b, 0xdb, 0x51, 0x91, 0x6a, 0xf6, 0x81, 0x30, - 0x8c, 0xa7, 0x98, 0xdd, 0x38, 0x35, 0x8a, 0x60, - 0x85, 0xb4, 0xf0, 0xf9, 0x43, 0xa2, 0x7d, 0x9a - }, - G89_CFB, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x1c, 0x16, 0xa0, 0xe9, 0x63, 0x94, 0xfe, 0x38, - 0x37, 0xa7, 0x9b, 0x70, 0x25, 0x2e, 0xd6, 0x00 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - U64(4294967296)+16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gcfb", - { - 0xae, 0x57, 0xa2, 0xdd, 0xa4, 0xef, 0x4f, 0x96, - 0xb8, 0x94, 0xa5, 0xd1, 0x1b, 0xc8, 0x9b, 0x42, - 0xa5, 0x24, 0xcc, 0x89, 0x5c, 0xb8, 0x92, 0x52, - 0xc1, 0x12, 0x6a, 0xb0, 0x9a, 0x26, 0xe8, 0x06 - }, - G89_CFB, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x2e, 0x62, 0xb0, 0x2e, 0xc7, 0x87, 0x4b, 0x29, - 0x33, 0x16, 0x6b, 0xb4, 0xd6, 0x61, 0x66, 0xd9 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1037, - { - 0x3d, 0x0b, 0x69, 0xf7, 0xa8, 0xe4, 0xfc, 0x99, - 0x22, 0x2e, 0xee, 0xd1, 0x63, 0x12, 0xfe, 0xa8, - 0x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0xd6, 0x65, 0xc5, 0x29, 0xfc, 0xda, - 0x69, 0xfc, 0xc0, 0xd6, 0x70, 0x99, 0x61, 0x3f, - 0x60, 0x02, 0xd8, 0x12, 0x22, 0xc8, 0x34, 0xc6, - 0x3b, 0xb3, 0xc2, 0x33, 0xa1, 0x5c, 0x8f, 0x4c, - 0xd1, 0x52, 0x72, 0xf2, 0x42, 0x05, 0x8e, 0x18, - 0x1f, 0x16, 0xda, 0xb8, 0x53, 0xa1, 0x5f, 0x01, - 0x32, 0x1b, 0x90, 0xb3, 0x53, 0x9b, 0xd0, 0x85, - 0x61, 0x2d, 0x17, 0xed, 0x0a, 0xa4, 0xa5, 0x27, - 0x09, 0x75, 0x7c, 0xbc, 0x30, 0xf7, 0x5e, 0x59, - 0x9a, 0x07, 0x96, 0x84, 0x28, 0x86, 0x4b, 0xa7, - 0x22, 0x35, 0x28, 0xc7, 0xed, 0x0d, 0xc3, 0xce, - 0x98, 0xcc, 0x2d, 0xec, 0xd4, 0x98, 0x09, 0x8e, - 0x52, 0x5f, 0x2b, 0x9a, 0x13, 0xbe, 0x99, 0x16, - 0x73, 0xd1, 0x1f, 0x81, 0xe5, 0xa2, 0x08, 0x78, - 0xcb, 0x0c, 0x20, 0xd4, 0xa5, 0xea, 0x4b, 0x5b, - 0x95, 0x5a, 0x92, 0x9a, 0x52 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testcnt2", - { - 0x1b, 0x5d, 0xdb, 0x77, 0xcf, 0xf9, 0xec, 0x95, - 0x5e, 0xcc, 0x67, 0x9f, 0x5d, 0x28, 0xad, 0x4a, - 0x27, 0xf4, 0x32, 0xc6, 0xb2, 0xcb, 0xb1, 0x45, - 0x6a, 0x88, 0x14, 0x0c, 0x9b, 0x9b, 0x5f, 0x48 - }, - G89_CNT, - { - 0x71, 0x58, 0x8c, 0xe1, 0x55, 0xf4, 0xf6, 0xb3 - }, - { - 0x8e, 0xcd, 0x8f, 0xc8, 0xac, 0xe1, 0x15, 0x48, - 0x2d, 0xae, 0x24, 0x8a, 0xc7, 0xfb, 0xba, 0x0f, - 0x1d, 0x8a, 0x95, 0xa2, 0x43, 0xef, 0xcb, 0xdc, - 0x59, 0x57, 0xa7, 0xc7, 0x0e, 0xe3, 0xe2, 0xb9, - 0x0d, 0x86, 0x29, 0x62, 0xcb, 0x83, 0x4d, 0x07, - 0x0c, 0x40, 0xd4, 0x7b, 0x2e, 0xca, 0xba, 0xbf, - 0x4a, 0x60, 0x3b, 0x31, 0x98, 0xc8, 0x88, 0x47, - 0xd9, 0x82, 0xab, 0xfc, 0x8f, 0x48, 0xe2, 0x46, - 0xab, 0xd3, 0xa1, 0xab, 0x8a, 0x05, 0x22, 0x8c, - 0xf4, 0xec, 0x9a, 0x1e, 0x76, 0xab, 0x1a, 0x60, - 0xd9, 0x25, 0x6b, 0xb8, 0x56, 0xe5, 0xb2, 0xea, - 0x10, 0xf3, 0x62, 0x04, 0x32, 0x5e, 0xaa, 0x3b, - 0x7b, 0x57, 0xbc, 0x3b, 0x8b, 0x43, 0x47, 0xf2, - 0xd5, 0x03, 0x7e, 0x51, 0x01, 0xff, 0x77, 0x28, - 0xca, 0x90, 0xa3, 0xfe, 0x7e, 0x2e, 0x70, 0x16, - 0x75, 0x18, 0x44, 0xf0, 0x1b, 0x85, 0x05, 0xea, - 0xe3, 0x21, 0xf7, 0x26, 0x86, 0x76, 0x3c, 0x67, - 0x9d, 0xfc, 0xbc, 0x10, 0x7f, 0x77, 0xe4, 0xed, - 0xd3, 0x12, 0xf8, 0x83, 0x00, 0x1f, 0x4b, 0x92, - 0x95, 0x92, 0x5c, 0xf3, 0x5a, 0xf3, 0xb7, 0xd0, - 0xa9, 0x5f, 0xf2, 0x18, 0xc4, 0x66, 0x62, 0xc1, - 0x84, 0x0e, 0x66, 0xe8, 0x80, 0x7d, 0x1f, 0xf0, - 0xba, 0x01, 0x9b, 0x71, 0xae, 0x93, 0xcc, 0x27, - 0x54, 0x34, 0x9a, 0xbd, 0xca, 0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, - 0x5a, 0x4f, 0x39, 0xb5, 0xa2, 0x12, 0x96, 0x0a, - 0x32, 0x84, 0xb2, 0xa1, 0x06, 0x68, 0x56, 0x57, - 0x97, 0xa3, 0x7b, 0x22, 0x61, 0x76, 0x5d, 0x30, - 0x1a, 0x31, 0xab, 0x99, 0x06, 0xc5, 0x1a, 0x96, - 0xcf, 0xcf, 0x14, 0xff, 0xb2, 0xc4, 0xcc, 0x2b, - 0xbf, 0x0c, 0x9d, 0x91, 0x8f, 0x79, 0x5b, 0xbc, - 0xa9, 0x6b, 0x91, 0x6a, 0xb4, 0x93, 0x5c, 0x7b, - 0x5d, 0xc2, 0x8a, 0x75, 0xc0, 0xc1, 0x08, 0xfa, - 0x99, 0xf9, 0x4d, 0x5e, 0x0c, 0x06, 0x64, 0x60, - 0xa9, 0x01, 0x4a, 0x34, 0x0f, 0x33, 0x84, 0x95, - 0x69, 0x30, 0xc1, 0x1c, 0x36, 0xf8, 0xfc, 0x30, - 0x23, 0xb2, 0x71, 0xe5, 0x52, 0x4d, 0x12, 0x1a, - 0xc9, 0xbe, 0xee, 0xc9, 0xcb, 0x01, 0x85, 0xf3, - 0xdb, 0x30, 0xf9, 0x41, 0xa9, 0x40, 0xb0, 0x06, - 0x29, 0x77, 0xcd, 0xc5, 0xec, 0x58, 0x02, 0x48, - 0x83, 0x53, 0x44, 0x6a, 0xd2, 0xca, 0x05, 0xd8, - 0x5a, 0x08, 0xeb, 0xa9, 0xf4, 0xe6, 0xc7, 0x9d, - 0xd5, 0x7b, 0x74, 0x0b, 0x31, 0xb7, 0xa5, 0x57, - 0x7c, 0x7a, 0xfd, 0x1a, 0x0e, 0xd7, 0x97, 0x41, - 0xbf, 0xdd, 0xc6, 0x19, 0x6c, 0x77, 0x8c, 0x18, - 0x52, 0x57, 0x83, 0xba, 0x71, 0x25, 0xee, 0x39, - 0xbb, 0xe2, 0x43, 0xa0, 0x14, 0xdc, 0x0e, 0x84, - 0xb4, 0x2b, 0xde, 0x3e, 0x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- 0x9d, 0x93, 0xf7, 0xdf, 0xb8, 0x43, 0x72, 0x7e, - 0xda, 0x3e, 0x20, 0x1f, 0xbc, 0x21, 0x2a, 0xce, - 0x00, 0xfa, 0x96, 0x9f, 0x3d, 0xe5, 0x88, 0x96, - 0xef, 0x29, 0x84, 0xdf, 0x6c, 0x1c, 0x96, 0xd8, - 0x58, 0x47, 0xaa, 0x92, 0xf3, 0x07, 0xe5, 0xfb, - 0xaf, 0xea, 0x95, 0x7e, 0x0b, 0x71, 0xcd, 0x81, - 0x0f, 0xb7, 0x0a, 0x59, 0x8f, 0x31, 0x4d, 0xd1, - 0xc3, 0xf3, 0x2f, 0x70, 0x5c, 0x59, 0x18, 0x97, - 0xaf, 0x77, 0x95, 0x5e, 0xaf, 0x40, 0x06, 0x12, - 0x81, 0x61, 0x86, 0x08, 0x4e, 0xbc, 0x89, 0x46, - 0x07, 0x2e, 0x5b, 0x10, 0xaa, 0x12, 0xf0, 0xa7, - 0x84, 0xe2, 0x9a, 0x08, 0xf1, 0xde, 0x59, 0xe3, - 0x0e, 0x47, 0x4b, 0xff, 0xc3, 0xc9, 0x18, 0xaf, - 0x95, 0x9c, 0x67, 0x2a, 0xde, 0x8a, 0x7a, 0x99, - 0x04, 0xc4, 0xb8, 0x97, 0x4c, 0x04, 0x29, 0x71, - 0x05, 0xda, 0xb3, 0xd6, 0xdb, 0x6c, 0x71, 0xe6, - 0xe8, 0x03, 0xbf, 0x94, 0x7d, 0xde, 0x3d, 0xc8, - 0x44, 0xfa, 0x7d, 0x62, 0xb4, 0x36, 0x03, 0xee, - 0x36, 0x52, 0x64, 0xb4, 0x85, 0x6d, 0xd5, 0x78, - 0xf0, 0x6f, 0x67, 0x2d, 0x0e, 0xe0, 0x2c, 0x88, - 0x9b, 0x55, 0x19, 0x29, 0x40, 0xf6, 0x8c, 0x12, - 0xbb, 0x2c, 0x83, 0x96, 0x40, 0xc0, 0x36, 0xf5, - 0x77, 0xff, 0x70, 0x8c, 0x75, 0x92, 0x0b, 0xad, - 0x05, 0x9b, 0x7e, 0xa2, 0xfc, 0xa9, 0xd1, 0x64, - 0x76, 0x82, 0x13, 0xba, 0x22, 0x5e, 0x33, 0x0e, - 0x26, 0x70, 0xa9, 0xbe, 0x74, 0x28, 0xf5, 0xe2, - 0xc4, 0x96, 0xee, 0x3a, 0xbc, 0x97, 0xa6, 0x2c, - 0x2a, 0xe0, 0x64, 0x8d, 0x35, 0xc6, 0x1a, 0xca, - 0xf4, 0x92, 0xfa, 0xc3, 0xf1, 0x1f, 0x98, 0xe4, - 0x43, 0x88, 0x69, 0x3a, 0x09, 0xbf, 0x63, 0xe5, - 0x96, 0x29, 0x0b, 0x9b, 0x62, 0x23, 0x14, 0x8a, - 0x95, 0xe4, 0x1c, 0x5c, 0x0a, 0xa9, 0xc5, 0xb9, - 0x6f, 0x4f, 0x2b, 0x25, 0x6f, 0x74, 0x1e, 0x18, - 0xd5, 0xfe, 0x27, 0x7d, 0x3f, 0x6e, 0x55, 0x2c, - 0x67, 0xe6, 0xde, 0xb5, 0xcc, 0xc0, 0x2d, 0xff, - 0xc4, 0xe4, 0x06, 0x21, 0xa5, 0xc8, 0xd3, 0xd6, - 0x6c, 0xa1, 0xc3, 0xfb, 0x88, 0x92, 0xb1, 0x1d, - 0x90, 0xe1, 0x35, 0x05, 0x9b, 0x29, 0x6d, 0xba, - 0xf1, 0xf4, 0x1e, 0x23, 0x2e - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880+8, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mcnt", - { - 0x07, 0x52, 0x65, 0xe7, 0xca, 0xa3, 0xca, 0x45, - 0xcf, 0x3a, 0x05, 0x1d, 0x38, 0x03, 0x53, 0x0c, - 0x22, 0x31, 0xba, 0x99, 0x4f, 0x9b, 0x6a, 0x1b, - 0x7e, 0x09, 0x9d, 0x4e, 0xb5, 0xc9, 0x84, 0x2e - }, - G89_CNT, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0x3d, 0x05, 0x07, 0x57, 0xc0, 0x75, 0x89, 0x97, - 0xd6, 0x94, 0x49, 0x11, 0x1d, 0xd0, 0x91, 0xee - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - U64(4294967296)+16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gcnt", - { - 0x75, 0xa3, 0x3c, 0xae, 0x03, 0x6b, 0x10, 0xdb, - 0xc1, 0x56, 0x50, 0x89, 0x03, 0xd2, 0x9f, 0x91, - 0xee, 0xe8, 0x64, 0x1d, 0x43, 0xf2, 0x4e, 0xf8, - 0xf2, 0x6c, 0xed, 0xda, 0x8f, 0xe4, 0x88, 0xe9 - }, - G89_CNT, - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, - { - 0xfa, 0x6c, 0x96, 0x78, 0xe2, 0xf8, 0xdd, 0xaa, - 0x67, 0x5a, 0xc9, 0x5d, 0x57, 0xf1, 0xbd, 0x99 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 1035, - { - 0xd6, 0xcf, 0x31, 0x96, 0x9c, 0xa1, 0xfb, 0xd6, - 0x8d, 0xa3, 0xdd, 0x01, 0xd9, 0x88, 0xc0, 0x2f, - 0xbc, 0x46, 0xc7, 0x3a, 0xe4, 0x21, 0x86, 0x96, - 0x8d, 0xe2, 0xca, 0xb6, 0x37, 0xa2, 0xe1, 0xa8, - 0x7e, 0xa7, 0x79, 0x2e, 0xa4, 0x56, 0x75, 0x7f, - 0x3e, 0x55, 0x8b, 0x43, 0xae, 0x65, 0xdf, 0xaa, - 0x42, 0xb6, 0x00, 0xa6, 0x61, 0x03, 0x0d, 0xd3, - 0x41, 0x02, 0x27, 0x23, 0x95, 0x79, 0x9b, 0x34, - 0x81, 0xa9, 0x86, 0xb5, 0xa7, 0x90, 0xe2, 0xae, - 0xc4, 0x2f, 0xc3, 0x8e, 0x32, 0x56, 0x13, 0xfa, - 0x4d, 0x4e, 0x9f, 0x15, 0x75, 0x7e, 0x74, 0xdc, - 0x32, 0x2d, 0xee, 0x4d, 0x67, 0x70, 0x9f, 0x62, - 0xb9, 0xc4, 0xdb, 0x24, 0x84, 0xcc, 0x16, 0x7b, - 0xda, 0x22, 0xf7, 0xc5, 0xf3, 0x93, 0x35, 0x73, - 0xc6, 0x03, 0x1c, 0x77, 0xa5, 0xf2, 0x76, 0x56, - 0xb4, 0x95, 0xd4, 0x7e, 0x0d, 0x20, 0xc6, 0x6e, - 0xee, 0x8f, 0x25, 0x48, 0xff, 0x7e, 0x01, 0x3a, - 0xb4, 0x1f, 0xaa, 0x35, 0xc0, 0x33, 0x58, 0x9c, - 0xb5, 0xba, 0x65, 0x4b, 0xd3, 0x51, 0x14, 0xec, - 0x61, 0xce, 0xe4, 0xba, 0x49, 0xba, 0x39, 0x32, - 0xab, 0xce, 0x81, 0x72, 0xce, 0xab, 0xed, 0xd4, - 0xd2, 0x19, 0x87, 0x85, 0x92, 0xfa, 0x64, 0x34, - 0xd8, 0x86, 0xf4, 0x8a, 0x08, 0x3c, 0xde, 0xee, - 0x97, 0x92, 0x92, 0x69, 0xba, 0x9b, 0x5f, 0x7a, - 0x03, 0xc1, 0x5d, 0x43, 0x02, 0x8c, 0xbe, 0xd2, - 0x46, 0x72, 0x81, 0x40, 0x7d, 0x68, 0x98, 0x45, - 0x0b, 0x54, 0x27, 0x1c, 0xaf, 0x80, 0x42, 0xe4, - 0xd5, 0xd4, 0xe4, 0xa2, 0x98, 0x07, 0x8f, 0x03, - 0xf5, 0x2c, 0x8c, 0x88, 0xca, 0x5a, 0xde, 0xe4, - 0x9f, 0xb1, 0x5f, 0x82, 0xff, 0x20, 0x67, 0x52, - 0x85, 0x84, 0x4f, 0xc8, 0xfe, 0xa7, 0x9e, 0xae, - 0x1c, 0xfa, 0xb8, 0x75, 0xd3, 0xf7, 0x9f, 0x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, 0xad, 0x6b, 0x0e, 0x04, - 0x7d, 0xaf, 0xc2, 0x3b, 0xa5, 0x68, 0x9b, 0x0c, - 0xf3, 0x56, 0xf3, 0xda, 0x8d, 0xc8, 0x7d, 0x39, - 0xdc, 0xd5, 0x99, 0xc6, 0x01, 0x10, 0xce, 0x42, - 0x1b, 0xac, 0x48, 0xdc, 0x97, 0x78, 0x0a, 0xec, - 0xb3, 0x8f, 0x47, 0x35, 0xa3, 0x6a, 0x64, 0xb2, - 0x8e, 0x63, 0x69, 0x22, 0x66, 0xae, 0x2e, 0xe0, - 0x88, 0xf9, 0x40, 0x3c, 0xc9, 0xa2, 0x57, 0x61, - 0xf6, 0xad, 0xf0, 0xdc, 0x90, 0x56, 0x3f, 0x06, - 0x9b, 0x7d, 0xbd, 0xc2, 0x81, 0x02, 0xab, 0xb8, - 0x15, 0x09, 0x88, 0x4a, 0xff, 0x2f, 0x31, 0xbf, - 0x5e, 0xfa, 0x6a, 0x7e, 0xf6, 0xc5, 0xa7, 0xf7, - 0xd5, 0xab, 0x55, 0xac, 0xae, 0x0d, 0x8c, 0x8d, - 0x7f, 0x4b, 0x25, 0xbb, 0x32, 0xff, 0x11, 0x33, - 0x2e, 0x37, 0x37, 0x69, 0x96, 0x15, 0x17, 0xb1, - 0x17, 0x49, 0xe0, 0x9a, 0x9c, 0xd9, 0x5b, 0x8d, - 0x58, 0xa3, 0x1d, 0x92, 0x87, 0xf8, 0x80, 0xb9, - 0xbd, 0x5a, 0xec, 0x40, 0xe1, 0x00, 0x33, 0x60, - 0xe4, 0x86, 0x16, 0x6d, 0x61, 0x81, 0xf2, 0x28, - 0x6a, 0xa7, 0xce, 0x3f, 0x95, 0xae, 0x43, 0xca, - 0xe1, 0x3f, 0x81, 0x74, 0x7e, 0x1c, 0x47, 0x17, - 0x95, 0xc6, 0x60, 0xda, 0x74, 0x77, 0xd9, 0x9f, - 0xfa, 0x92, 0xb4, 0xbe, 0xe1, 0x23, 0x98, 0x18, - 0x95, 0x63, 0x03, 0x13, 0x4c, 0x1a, 0x2d, 0x41, - 0xcd, 0xe4, 0x84, 0xf7, 0xe6, 0x38, 0xef, 0xff, - 0x95, 0xb2, 0xe8, 0x7c, 0x8f, 0x58, 0xb5, 0xb5, - 0xed, 0x27, 0x7f, 0x3c, 0x18, 0xab, 0xbe, 0x7f, - 0x4f, 0xe2, 0x35, 0x15, 0x71, 0xb7, 0x6f, 0x85, - 0x38, 0x9b, 0x88, 0xf6, 0x9c, 0x8d, 0x43, 0xb5, - 0x58, 0x9e, 0xf2, 0xd1, 0x96, 0xbe, 0xb7, 0xad, - 0x1a, 0xa0, 0x98 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit2", - { - 0x80, 0xd9, 0xa0, 0xdc, 0x21, 0xf9, 0x30, 0x40, - 0x75, 0xfe, 0x49, 0x1b, 0x9e, 0x71, 0x90, 0x91, - 0x78, 0x88, 0x21, 0x60, 0x39, 0xe7, 0xc9, 0x2b, - 0xfb, 0x55, 0x1d, 0xf4, 0xdd, 0x2b, 0x0a, 0x01 - }, - G89_IMIT, - { 0 }, - { - 0x90, 0xf2, 0x11, 0x9a - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 10, - { - 0x1d, 0xeb, 0xe6, 0x79, 0x0a, 0x59, 0x00, 0xe6, - 0x8e, 0x5c - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit3", - { - 0xa9, 0xb6, 0x37, 0xcc, 0x6d, 0x9b, 0x2f, 0x25, - 0xb0, 0xdf, 0x47, 0x04, 0x50, 0x68, 0xb0, 0x27, - 0x41, 0x27, 0x58, 0x6a, 0xbd, 0x0a, 0x6e, 0x50, - 0x2f, 0xc6, 0xfc, 0xc0, 0x3e, 0x29, 0x42, 0xa5 - }, - G89_IMIT, - { 0 }, - { - 0x31, 0x7c, 0x16, 0xe4 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 6, - { - 0xef, 0x06, 0x8f, 0x14, 0xc9, 0x04 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit4", - { - 0xb0, 0x6c, 0x48, 0x23, 0x0a, 0x6e, 0xf4, 0xec, - 0x27, 0x98, 0x01, 0x23, 0xa7, 0xd8, 0xbf, 0x60, - 0x89, 0xef, 0xad, 0xe8, 0x8f, 0x79, 0x14, 0x8c, - 0x18, 0x5c, 0x9a, 0xda, 0xef, 0x0b, 0xdd, 0xa0 - }, - G89_IMIT, - { 0 }, - { - 0xe9, 0x72, 0xae, 0xbf - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 16, - { - 0x02, 0xf8, 0xec, 0x2b, 0x4d, 0x1f, 0xbc, 0x7c, - 0x6e, 0x47, 0xe3, 0x87, 0x22, 0x75, 0x41, 0xa7 - }, - "id-Gost28147-89-CryptoPro-B-ParamSet", - "testimit5", - { - 0x33, 0xd3, 0xef, 0x01, 0x19, 0x95, 0x0e, 0x15, - 0xa1, 0x69, 0x75, 0xae, 0x56, 0x27, 0x17, 0x79, - 0x63, 0x47, 0xab, 0x62, 0x9d, 0x4a, 0xf0, 0x34, - 0xd3, 0x1e, 0x69, 0x74, 0xec, 0x31, 0x48, 0xfc - }, - G89_IMIT, - { 0 }, - { - 0xf5, 0x55, 0x1f, 0x28 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 8, - { - 0xf3, 0xb2, 0x29, 0xd2, 0x7a, 0x37, 0x03, 0x12 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit6", - { - 0x42, 0x35, 0x81, 0x91, 0x0b, 0xa9, 0x99, 0xff, - 0xd9, 0x43, 0xf8, 0xc6, 0x19, 0x55, 0x1f, 0x2f, - 0x2d, 0x45, 0x40, 0x20, 0x1e, 0x1d, 0x32, 0x7a, - 0xb1, 0x07, 0x6b, 0x4f, 0x45, 0x90, 0xd9, 0x80 - }, - G89_IMIT, - { 0 }, - { - 0x6e, 0x15, 0xfa, 0xe8 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 0, - { - 0 - }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "testimit7", - { - 0x26, 0xcb, 0xb9, 0xf0, 0x0c, 0x62, 0x9f, 0xaa, - 0x4a, 0x1d, 0xb6, 0x30, 0x09, 0x01, 0x56, 0x89, - 0x66, 0xd4, 0xe4, 0x0e, 0xfe, 0xf6, 0x10, 0x6b, - 0x6c, 0xe8, 0x04, 0x3a, 0xe3, 0x61, 0x4b, 0x19 - }, - G89_IMIT, - { 0 }, - { - 0x00, 0x00, 0x00, 0x00 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 5242880, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test5Mimit", - { - 0xaa, 0x85, 0x84, 0xcd, 0x65, 0x28, 0xe1, 0xdb, - 0xb8, 0x20, 0x19, 0x43, 0xe0, 0x36, 0x35, 0x10, - 0x19, 0xc3, 0x70, 0x5b, 0x27, 0xc1, 0x9d, 0x84, - 0x75, 0xa3, 0xc6, 0x49, 0x46, 0x8f, 0x7c, 0x4e - }, - G89_IMIT, - { 0 }, - { - 0x2a, 0xe6, 0x23, 0xc6 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - 3221225472U + 16, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test3Gimit1", - { - 0xd5, 0xda, 0xfe, 0x06, 0x60, 0xdc, 0xf0, 0xb3, - 0x49, 0x5a, 0x02, 0x59, 0xc8, 0x2e, 0x4a, 0x2b, - 0xcc, 0x9b, 0x98, 0x04, 0xb7, 0xf2, 0x78, 0xb7, - 0xce, 0xa3, 0xf2, 0xdb, 0x9e, 0xa8, 0x49, 0x1d - }, - G89_IMIT, - { 0 }, - { - 0xcc, 0x46, 0x67, 0xe4 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - U64(4)*1024*1024*1024, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit3", - { - 0x0d, 0xf1, 0xa8, 0x7f, 0x57, 0x03, 0x44, 0xcc, - 0xdb, 0x20, 0xde, 0xed, 0x85, 0x50, 0x38, 0xda, - 0xc9, 0x44, 0xec, 0x2c, 0x0d, 0x66, 0xb7, 0xdc, - 0x17, 0x14, 0x55, 0x95, 0x33, 0x6e, 0x43, 0x3e - }, - G89_IMIT, - { 0 }, - { - 0xb7, 0x21, 0x2e, 0x48 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - U64(4)*1024*1024*1024+4, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit1", - { - 0x0c, 0xf3, 0xe9, 0xb0, 0x28, 0x3b, 0x9f, 0x8b, - 0xe3, 0x82, 0xb9, 0xa2, 0xa6, 0xbd, 0x80, 0xd2, - 0xcd, 0xfa, 0x3f, 0xf7, 0x90, 0xa7, 0x55, 0x06, - 0x9b, 0x7a, 0x58, 0xee, 0xe7, 0xf1, 0x9d, 0xbe - }, - G89_IMIT, - { 0 }, - { - 0xda, 0x15, 0x10, 0x73 - } - }, - { /* Calculated by libcapi10, CryptoPro CSP 3.6R2, Mac OSX */ - U64(4)*1024*1024*1024+10, - { 0 }, - "id-Gost28147-89-CryptoPro-A-ParamSet", - "test4Gimit2", - { - 0x97, 0x1a, 0x42, 0x22, 0xfa, 0x07, 0xb2, 0xca, - 0xf9, 0xd2, 0x34, 0x5a, 0x92, 0xb1, 0x1f, 0x6b, - 0x53, 0xf8, 0xaf, 0xed, 0x9a, 0x73, 0xc4, 0x38, - 0xd7, 0x7d, 0x25, 0x81, 0x00, 0x0d, 0xd4, 0x29 - }, - G89_IMIT, - { 0 }, - { - 0x52, 0xaa, 0x22, 0xb4 - } - } -}; - -/* const */ unsigned char bZB[40*1024*1024]; -unsigned char bTS[40*1024*1024]; - -int main(int argc, char *argv[]) -{ - unsigned int t; - uint64_t ullMaxLen = 6*1000*1000; - int ignore = 0; - EVP_MD_CTX *mctx = NULL; - EVP_CIPHER_CTX *ectx = NULL; - EVP_PKEY *mac_key; - unsigned char bDerive[EVP_MAX_KEY_LENGTH]; - unsigned char bTest[G89_MAX_TC_LEN]; - unsigned char bTest1[G89_MAX_TC_LEN]; - uint64_t ullLeft; - unsigned int mdl = 0; - int enlu = 0; - int enlf = 0; - size_t siglen; - size_t l = 0; - BIO *bio_err; - const EVP_MD *md_gost94 = NULL; - const EVP_CIPHER *cp_g89ecb = NULL; - const EVP_CIPHER *cp_g89cfb = NULL; - const EVP_CIPHER *cp_g89cnt = NULL; - const EVP_CIPHER *ctype = NULL; - const EVP_MD *md_g89imit = NULL; - int ret = 0; - - printf("Testing GOST 28147-89 "); - - if(1 < argc) { - if(1 != sscanf(argv[1], "%" SCNu64, &ullMaxLen) || - ( 2 < argc ? - 1 != sscanf(argv[2], "%d", &ignore) : 0)) { - fflush(NULL); - fprintf(stderr, "Usage: %s [maxlen [ignore-error]]\n", - argv[0]); - ret = 1; - goto out; - } - } - - ERR_load_crypto_strings(); - OPENSSL_load_builtin_modules(); - OpenSSL_add_all_algorithms(); - - memset(bZB, 0, sizeof bZB); - memset(bTS, 0, sizeof bTS); - - /* Test load engine */ - if(NULL == (md_gost94 = EVP_get_digestbyname(SN_id_GostR3411_94))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_GostR3411_94 "\" - not found\n"); - if(!ignore) { - ret = 7; - goto out; - } - } - if(NULL == (cp_g89cfb = EVP_get_cipherbyname(SN_id_Gost28147_89))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_Gost28147_89 "\" - not found\n"); - if(!ignore) { - ret = 8; - goto out; - } - } - if(NULL == (cp_g89cnt = EVP_get_cipherbyname(SN_gost89_cnt))) { - fflush(NULL); - fprintf(stderr, "\"" SN_gost89_cnt "\" - not found\n"); - if(!ignore) { - ret = 9; - goto out; - } - } - if(NULL == (cp_g89ecb = EVP_get_cipherbyname(SN_gost89_ecb))) { - fflush(NULL); - fprintf(stderr, "\"" SN_gost89_ecb "\" - not found\n"); - if(!ignore) { - ret = 8; - goto out; - } - } - if(NULL == (md_g89imit = EVP_get_digestbyname(SN_id_Gost28147_89_MAC))) { - fflush(NULL); - fprintf(stderr, "\"" SN_id_Gost28147_89_MAC "\" - not found\n"); - if(!ignore) { - ret = 10; - goto out; - } - } - - /* Test cases */ - for(t = 0; t < sizeof(tcs)/sizeof(tcs[0]); t++) { - if(NULL != tcs[t].szDerive) { - memset(bDerive, 0x3c, sizeof(bDerive)); - mdl = sizeof(bDerive); - if (!EVP_Digest(tcs[t].szDerive, strlen(tcs[t].szDerive), bDerive, - &mdl, md_gost94, NULL)) - goto out; - if(0 != memcmp(tcs[t].bRawKey, bDerive, mdl)) { - fflush(NULL); - fprintf(stderr, "Engine test t=%d " - "derive key error.\n", t); - if(!ignore) { - ret = 12; - goto out; - } - } - } - if(ullMaxLen < tcs[t].ullLen) { - printf("@"); - continue; - } - memset(bTest, 0xa5, sizeof(bTest)); - memset(bTest1, 0x5a, sizeof(bTest1)); - - switch(tcs[t].gMode) { - case G89_ECB: - ctype = cp_g89ecb; - goto engine_cipher_check; - case G89_CFB: - ctype = cp_g89cfb; - goto engine_cipher_check; - case G89_CNT: - ctype = cp_g89cnt; -engine_cipher_check: - if ((ectx = EVP_CIPHER_CTX_new()) == NULL) - goto imit_fail; - if (!EVP_EncryptInit_ex(ectx, ctype, NULL, tcs[t].bRawKey, - tcs[t].bIV)) - goto imit_fail; - if (!EVP_CIPHER_CTX_ctrl(ectx, EVP_CTRL_GOST_SET_SBOX, - OBJ_txt2nid(tcs[t].szParamSet), 0)) - goto imit_fail; - if(G89_MAX_TC_LEN >= tcs[t].ullLen) { - enlu = sizeof(bTest); - if (!EVP_EncryptUpdate(ectx, bTest, &enlu, tcs[t].bIn, - (int)tcs[t].ullLen)) - goto imit_fail; - l = (size_t)tcs[t].ullLen; - } else { - for(ullLeft = tcs[t].ullLen; - ullLeft >= sizeof(bZB); - ullLeft -= sizeof(bZB)) { - printf("B"); - fflush(NULL); - enlu = sizeof(bTS); - if (!EVP_EncryptUpdate(ectx, bTS, &enlu, bZB, - sizeof(bZB))) - goto imit_fail; - } - printf("b%" PRIu64 "/%" PRIu64, ullLeft, tcs[t].ullLen); - fflush(NULL); - if (!EVP_EncryptUpdate(ectx, bTS, &enlu, bZB, (int)ullLeft)) - goto imit_fail; - memcpy(bTest, &bTS[enlu-16], 16); - enlu = (int)tcs[t].ullLen; - l = 16; - } - enlf = sizeof(bTest1); - if (tcs[t].gMode == G89_ECB) - enlf = 0; - else { - if (!EVP_EncryptFinal_ex(ectx, bTest1, &enlf)) - goto imit_fail; - } - EVP_CIPHER_CTX_free(ectx); - ectx = NULL; - break; - case G89_IMIT: - if ((mctx = EVP_MD_CTX_new()) == NULL) - goto imit_fail; - mac_key = EVP_PKEY_new_mac_key( - NID_id_Gost28147_89_MAC, NULL, - bDerive, mdl); - if (mac_key == NULL) - goto imit_fail; - if (!EVP_DigestSignInit(mctx, NULL, md_g89imit, NULL, mac_key)) - goto imit_fail; - if (!EVP_MD_CTX_ctrl(mctx, EVP_MD_CTRL_GOST_SET_SBOX, - OBJ_txt2nid(tcs[t].szParamSet), 0)) - goto imit_fail; - if(G89_MAX_TC_LEN >= tcs[t].ullLen) { - if (!EVP_DigestSignUpdate(mctx, tcs[t].bIn, - (unsigned int)tcs[t].ullLen)) - goto imit_fail; - } else { - for(ullLeft = tcs[t].ullLen; - ullLeft >= sizeof(bZB); - ullLeft -= sizeof(bZB)) { - printf("B"); - fflush(NULL); - if (!EVP_DigestSignUpdate(mctx, bZB, sizeof(bZB))) - goto imit_fail; - } - printf("b%" PRIu64 "/%" PRIu64, ullLeft, tcs[t].ullLen); - fflush(NULL); - if (!EVP_DigestSignUpdate(mctx, bZB, (unsigned int)ullLeft)) - goto imit_fail; - } - siglen = 4; - OPENSSL_assert(EVP_DigestSignFinal(mctx, bTest, &siglen)); - EVP_MD_CTX_free(mctx); - mctx = NULL; - EVP_PKEY_free(mac_key); - enlu = (int)tcs[t].ullLen; - enlf = 0; - l = siglen; - break; - } - if((int)tcs[t].ullLen != enlu || 0 != enlf || - 0 != memcmp(tcs[t].bOut, bTest, l)) { -imit_fail: - fflush(NULL); - fprintf(stderr, "\nEngine test t=%d len=%" PRIu64 - " mode=%d failed.\n", t, tcs[t].ullLen, tcs[t].gMode); - if(!ignore) { - ret = 13; - goto out; - } - } else { - printf("."); - fflush(NULL); - } - } - - printf(" passed\n"); - fflush(NULL); - - out: - - bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); - ERR_print_errors(bio_err); - (void)BIO_flush(bio_err); - BIO_free(bio_err); - EVP_CIPHER_CTX_free(ectx); - EVP_MD_CTX_free(mctx); - return ret; -} -#endif diff --git a/sys/dev/pci/drm/i915/gt/uc/intel_guc_ads.c b/sys/dev/pci/drm/i915/gt/uc/intel_guc_ads.c index 13470c677..a8565e308 100644 --- a/sys/dev/pci/drm/i915/gt/uc/intel_guc_ads.c +++ b/sys/dev/pci/drm/i915/gt/uc/intel_guc_ads.c @@ -141,8 +141,6 @@ static u32 guc_ads_blob_size(struct intel_guc *guc) static void guc_policies_init(struct intel_guc *guc) { - STUB(); -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); struct drm_i915_private *i915 = gt->i915; u32 global_flags = 0; @@ -157,14 +155,11 @@ static void guc_policies_init(struct intel_guc *guc) ads_blob_write(guc, policies.global_flags, global_flags); ads_blob_write(guc, policies.is_valid, 1); -#endif } void intel_guc_ads_print_policy_info(struct intel_guc *guc, struct drm_printer *dp) { - STUB(); -#ifdef notyet if (unlikely(iosys_map_is_null(&guc->ads_map))) return; @@ -175,7 +170,6 @@ void intel_guc_ads_print_policy_info(struct intel_guc *guc, ads_blob_read(guc, policies.max_num_work_items)); drm_printf(dp, " Flags = %u\n", ads_blob_read(guc, policies.global_flags)); -#endif } static int guc_action_policies_update(struct intel_guc *guc, u32 policy_offset) @@ -190,9 +184,6 @@ static int guc_action_policies_update(struct intel_guc *guc, u32 policy_offset) int intel_guc_global_policies_update(struct intel_guc *guc) { - STUB(); - return -ENOSYS; -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); u32 scheduler_policies; intel_wakeref_t wakeref; @@ -213,14 +204,11 @@ int intel_guc_global_policies_update(struct intel_guc *guc) ret = guc_action_policies_update(guc, scheduler_policies); return ret; -#endif } static void guc_mapping_table_init(struct intel_gt *gt, struct iosys_map *info_map) { - STUB(); -#ifdef notyet unsigned int i, j; struct intel_engine_cs *engine; enum intel_engine_id id; @@ -237,7 +225,6 @@ static void guc_mapping_table_init(struct intel_gt *gt, info_map_write(info_map, mapping_table[guc_class][ilog2(engine->logical_mask)], engine->instance); } -#endif } /* @@ -267,14 +254,12 @@ static int guc_mmio_reg_cmp(const void *a, const void *b) static struct guc_mmio_reg * __must_check __mmio_reg_add(struct temp_regset *regset, struct guc_mmio_reg *reg) { - STUB(); - return ERR_PTR(-ENOSYS); -#ifdef notyet u32 pos = regset->storage_used; struct guc_mmio_reg *slot; if (pos >= regset->storage_max) { size_t size = ALIGN((pos + 1) * sizeof(*slot), PAGE_SIZE); +#ifdef ___linux__ struct guc_mmio_reg *r = krealloc(regset->storage, size, GFP_KERNEL); if (!r) { @@ -282,6 +267,17 @@ __mmio_reg_add(struct temp_regset *regset, struct guc_mmio_reg *reg) -ENOMEM); return ERR_PTR(-ENOMEM); } +#else + struct guc_mmio_reg *r = kmalloc(size, GFP_KERNEL); + if (!r) { + WARN_ONCE(1, "Incomplete regset list: can't add register (%d)\n", + -ENOMEM); + return ERR_PTR(-ENOMEM); + } + memcpy(r, regset->storage, + ALIGN((pos) * sizeof(*slot), PAGE_SIZE)); + kfree(regset->storage); +#endif regset->registers = r + (regset->registers - regset->storage); regset->storage = r; @@ -293,7 +289,6 @@ __mmio_reg_add(struct temp_regset *regset, struct guc_mmio_reg *reg) *slot = *reg; return slot; -#endif } static long __must_check guc_mmio_reg_add(struct intel_gt *gt, @@ -457,8 +452,6 @@ fail_regset_init: static void guc_mmio_reg_state_init(struct intel_guc *guc) { - STUB(); -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); struct intel_engine_cs *engine; enum intel_engine_id id; @@ -498,14 +491,11 @@ static void guc_mmio_reg_state_init(struct intel_guc *guc) addr_ggtt += count * sizeof(struct guc_mmio_reg); } -#endif } static void fill_engine_enable_masks(struct intel_gt *gt, struct iosys_map *info_map) { - STUB(); -#ifdef notyet info_map_write(info_map, engine_enabled_masks[GUC_RENDER_CLASS], RCS_MASK(gt)); info_map_write(info_map, engine_enabled_masks[GUC_COMPUTE_CLASS], CCS_MASK(gt)); info_map_write(info_map, engine_enabled_masks[GUC_BLITTER_CLASS], BCS_MASK(gt)); @@ -516,7 +506,6 @@ static void fill_engine_enable_masks(struct intel_gt *gt, if (gt->engine[GSC0]) info_map_write(info_map, engine_enabled_masks[GUC_GSC_OTHER_CLASS], BIT(gt->engine[GSC0]->instance)); -#endif } #define LR_HW_CONTEXT_SIZE (80 * sizeof(u32)) @@ -527,9 +516,6 @@ static void fill_engine_enable_masks(struct intel_gt *gt, #define LRC_SKIP_SIZE(i915) (LRC_PPHWSP_SZ * PAGE_SIZE + LR_HW_CONTEXT_SZ(i915)) static int guc_prep_golden_context(struct intel_guc *guc) { - STUB(); - return -ENOSYS; -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); u32 addr_ggtt, offset; u32 total_size = 0, alloc_size, real_size; @@ -597,7 +583,6 @@ static int guc_prep_golden_context(struct intel_guc *guc) GEM_BUG_ON(guc->ads_golden_ctxt_size != total_size); return total_size; -#endif } static struct intel_engine_cs *find_engine_state(struct intel_gt *gt, u8 engine_class) @@ -629,10 +614,6 @@ static void guc_init_golden_context(struct intel_guc *guc) if (!intel_uc_uses_guc_submission(>->uc)) return; - STUB(); - return; -#ifdef notyet - GEM_BUG_ON(iosys_map_is_null(&guc->ads_map)); /* @@ -666,20 +647,16 @@ static void guc_init_golden_context(struct intel_guc *guc) addr_ggtt += alloc_size; - shmem_read_to_iosys_map(engine->default_state, 0, &guc->ads_map, + uao_read_to_iosys_map(engine->default_state, 0, &guc->ads_map, offset, real_size); offset += alloc_size; } GEM_BUG_ON(guc->ads_golden_ctxt_size != total_size); -#endif } static u32 guc_get_capture_engine_mask(struct iosys_map *info_map, u32 capture_class) { - STUB(); - return 0; -#ifdef notyet u32 mask; switch (capture_class) { @@ -709,15 +686,11 @@ static u32 guc_get_capture_engine_mask(struct iosys_map *info_map, u32 capture_c } return mask; -#endif } static int guc_capture_prep_lists(struct intel_guc *guc) { - STUB(); - return -ENOSYS; -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); u32 ads_ggtt, capture_offset, null_ggtt, total_size = 0; struct guc_gt_system_info local_info; @@ -828,13 +801,10 @@ engine_instance_list: guc->ads_capture_size, PAGE_ALIGN(total_size)); return PAGE_ALIGN(total_size); -#endif } static void __guc_ads_init(struct intel_guc *guc) { - STUB(); -#ifdef notyet struct intel_gt *gt = guc_to_gt(guc); struct drm_i915_private *i915 = gt->i915; struct iosys_map info_map = IOSYS_MAP_INIT_OFFSET(&guc->ads_map, @@ -885,7 +855,6 @@ static void __guc_ads_init(struct intel_guc *guc) guc_ads_private_data_offset(guc)); i915_gem_object_flush_map(guc->ads_vma->obj); -#endif } /** @@ -963,8 +932,6 @@ void intel_guc_ads_destroy(struct intel_guc *guc) static void guc_ads_private_data_reset(struct intel_guc *guc) { - STUB(); -#ifdef notyet u32 size; size = guc_ads_private_data_size(guc); @@ -973,7 +940,6 @@ static void guc_ads_private_data_reset(struct intel_guc *guc) iosys_map_memset(&guc->ads_map, guc_ads_private_data_offset(guc), 0, size); -#endif } /** @@ -1002,15 +968,10 @@ u32 intel_guc_engine_usage_offset(struct intel_guc *guc) struct iosys_map intel_guc_engine_usage_record_map(struct intel_engine_cs *engine) { - STUB(); - struct iosys_map x = {}; - return x; -#ifdef notyet struct intel_guc *guc = &engine->gt->uc.guc; u8 guc_class = engine_class_to_guc_class(engine->class); size_t offset = offsetof(struct __guc_ads_blob, engine_usage.engines[guc_class][ilog2(engine->logical_mask)]); return IOSYS_MAP_INIT_OFFSET(&guc->ads_map, offset); -#endif } diff --git a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c index 40298b3cd..2723b7af5 100644 --- a/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c +++ b/sys/dev/pci/drm/i915/gt/uc/intel_guc_submission.c @@ -1214,8 +1214,6 @@ __extend_last_switch(struct intel_guc *guc, u64 *prev_start, u32 new_start) static void __get_engine_usage_record(struct intel_engine_cs *engine, u32 *last_in, u32 *id, u32 *total) { - STUB(); -#ifdef notyet struct iosys_map rec_map = intel_guc_engine_usage_record_map(engine); int i = 0; @@ -1229,7 +1227,6 @@ static void __get_engine_usage_record(struct intel_engine_cs *engine, record_read(&rec_map, total_runtime) == *total) break; } while (++i < 6); -#endif } static void guc_update_engine_gt_clks(struct intel_engine_cs *engine) @@ -2068,9 +2065,6 @@ static void guc_submit_request(struct i915_request *rq) static int new_guc_id(struct intel_guc *guc, struct intel_context *ce) { - STUB(); - return -ENOSYS; -#ifdef notyet int ret; GEM_BUG_ON(intel_context_is_child(ce)); @@ -2094,13 +2088,10 @@ static int new_guc_id(struct intel_guc *guc, struct intel_context *ce) ce->guc_id.id = ret; return 0; -#endif } static void __release_guc_id(struct intel_guc *guc, struct intel_context *ce) { - STUB(); -#ifdef notyet GEM_BUG_ON(intel_context_is_child(ce)); if (!context_guc_id_invalid(ce)) { @@ -2119,7 +2110,6 @@ static void __release_guc_id(struct intel_guc *guc, struct intel_context *ce) } if (!list_empty(&ce->guc_id.link)) list_del_init(&ce->guc_id.link); -#endif } static void release_guc_id(struct intel_guc *guc, struct intel_context *ce) diff --git a/sys/dev/pci/drm/include/linux/iosys-map.h b/sys/dev/pci/drm/include/linux/iosys-map.h index 4639769b8..1c07f18dc 100644 --- a/sys/dev/pci/drm/include/linux/iosys-map.h +++ b/sys/dev/pci/drm/include/linux/iosys-map.h @@ -35,6 +35,15 @@ iosys_map_memcpy_to(struct iosys_map *ism, size_t off, const void *src, memcpy(ism->vaddr + off, src, len); } +static inline void +iosys_map_memset(struct iosys_map *ism, size_t off, int c, size_t len) +{ + if (ism->is_iomem) + memset_io(ism->vaddr_iomem + off, c, len); + else + memset(ism->vaddr + off, c, len); +} + static inline bool iosys_map_is_null(const struct iosys_map *ism) { @@ -78,4 +87,53 @@ iosys_map_set_vaddr(struct iosys_map *ism, void *addr) ism->is_iomem = false; } +static inline struct iosys_map +IOSYS_MAP_INIT_OFFSET(struct iosys_map *ism, size_t off) +{ + struct iosys_map nism = *ism; + iosys_map_incr(&nism, off); + return nism; +} + +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 + +#define iosys_map_rd(_ism, _o, _t) ({ \ + _t v; \ + if ((_ism)->is_iomem) { \ + void *addr = (_ism)->vaddr_iomem + (_o); \ + v = _Generic(v, \ + uint8_t : ioread8(addr), \ + uint16_t: ioread16(addr), \ + uint32_t: ioread32(addr), \ + uint64_t: ioread64(addr)); \ + } else \ + v = READ_ONCE(*(_t *)((_ism)->vaddr + (_o))); \ + v; \ +}) + +#define iosys_map_wr(_ism, _o, _t, _v) ({ \ + _t v = (_v); \ + if ((_ism)->is_iomem) { \ + void *addr = (_ism)->vaddr_iomem + (_o); \ + _Generic(v, \ + uint8_t : iowrite8(v, addr), \ + uint16_t: iowrite16(v, addr), \ + uint32_t: iowrite32(v, addr), \ + uint64_t: iowrite64(v, addr)); \ + } else \ + WRITE_ONCE(*(_t *)((_ism)->vaddr + (_o)), v); \ +}) + +#define iosys_map_rd_field(_ism, _o, _t, _f) ({ \ + _t *t; \ + iosys_map_rd(_ism, _o + offsetof(_t, _f), __typeof(t->_f)); \ +}) + +#define iosys_map_wr_field(_ism, _o, _t, _f, _v) ({ \ + _t *t; \ + iosys_map_wr(_ism, _o + offsetof(_t, _f), __typeof(t->_f), _v); \ +}) + +#endif /* C11 */ + #endif diff --git a/sys/dev/pci/sdhc_pci.c b/sys/dev/pci/sdhc_pci.c index 544928674..f42d414b0 100644 --- a/sys/dev/pci/sdhc_pci.c +++ b/sys/dev/pci/sdhc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sdhc_pci.c,v 1.24 2022/03/11 18:00:51 mpi Exp $ */ +/* $OpenBSD: sdhc_pci.c,v 1.25 2024/03/28 23:38:54 jsg Exp $ */ /* * Copyright (c) 2006 Uwe Stuehler @@ -131,7 +131,8 @@ sdhc_pci_attach(struct device *parent, struct device *self, void *aux) (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_100SERIES_LP_EMMC || PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_APOLLOLAKE_EMMC || PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_GLK_EMMC || - PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_JSL_EMMC)) + PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_JSL_EMMC || + PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_ADL_N_EMMC)) sc->sc.sc_flags |= SDHC_F_NOPWR0; /* Some RICOH controllers need to be bumped into the right mode. */ diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index fe8e5a2b1..119241629 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.263 2023/09/04 13:08:11 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.265 2024/03/29 01:16:30 millert Exp $ */ /* * Copyright (c) 2010-2012, 2014-2021 Ingo Schwarze * Copyright (c) 2008-2012 Kristaps Dzonsons