File libcryptopp.spec of Package libcryptopp.38921

#
# spec file for package libcryptopp
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define major 8
%define minor 6
%define patch 0
%define pkg_version %{major}%{minor}%patch
# There is no upstream interface version information.
# Therefore we need unique basenames (see boo#1027192):
%define sover %{major}_%{minor}_%patch
Name:           libcryptopp
# WARNING: Execute "sh precheckin_baselibs.sh" to update baselibs.conf
# WARNING: uses source tarball name to create lib name.
Version:        %{major}.%{minor}.%patch
Release:        0
Summary:        Cryptographic library for C++
License:        BSL-1.0
Group:          Development/Libraries/C and C++
URL:            https://www.cryptopp.com
Source:         https://github.com/weidai11/cryptopp/archive/CRYPTOPP_%{major}_%{minor}_%patch.tar.gz
Source1:        precheckin_baselibs.sh
Source2:        baselibs.conf
# PATCH-FEATURE-OPENSUSE libcryptopp-shared.patch -- improve shared library creation
Patch1:         libcryptopp-shared.patch
# CVE-2023-50980 [bsc#1218219], DoS via malformed DER public key file
Patch2:         libcryptopp-CVE-2023-50980.patch
# CVE-2023-50981 [bsc#1218222], issue on ModularSquareRoot function leads to potential DoS
Patch3:         libcryptopp-CVE-2023-50981.patch
# PATCH-FIX-SUSE: [bsc#1224280] CVE-2024-28285 potential leak of secret key of ElGamal encryption via fault injection 
Patch4:         libcryptopp-CVE-2024-28285.patch
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig

%description
The Crypto++ library is a C++ class library of cryptographic schemes.
Also contains:
pseudo random number generators (PRNG): ANSI X9.17 appendix C,
RandomPool, RDRAND, RDSEED, NIST Hash DRBG.

%package -n %{name}%{sover}
Summary:        Cryptographic Library for C++
Group:          Development/Libraries/C and C++
Obsoletes:      %{name}%{major}_%{minor} = %{version}

%description -n %{name}%{sover}
The Crypto++ library provides authenticated encryption, stream and
block ciphers, block cipher operation modes, message authentication
codes, hash functions, PKI crypto, key agreement schemes and elliptic
curve crypto.

%package -n %{name}-devel
Summary:        Development files for libcryptopp, a cryptographic library for C++
Group:          Development/Libraries/C and C++
Requires:       %{name}%{sover} = %{version}
Obsoletes:      %{name}-devel-static <= %{version}

%description -n %{name}-devel
The Crypto++ library provides authenticated encryption, stream and
block ciphers, block cipher operation modes, message authentication
codes, hash functions, PKI crypto, key agreement schemes and elliptic
curve crypto. This package is used for crypto++ development.

%prep
%autosetup -p1 -n "cryptopp-CRYPTOPP_%{major}_%{minor}_%patch"

%build
%ifarch %{arm} i586
%define _lto_cflags %{nil}
%endif
CXXFLAGS="-DNDEBUG %{optflags} -fpic -fPIC -pthread -fopenmp"
# aarch64 arm -march=armv7-a -mfpu=neon
%ifarch ppc64
CXXFLAGS="$CXXFLAGS -DCRYPTOPP_DISABLE_ALTIVEC"
%endif
%make_build \
    CXXFLAGS="$CXXFLAGS" \
    DESTDIR="" \
    PREFIX="%{_prefix}" \
    LIB="%{_lib}" \
    CXX="g++" \
    LIBSUFFIX="-%{version}" \
    LDFLAGS="-pthread" \
    all static

%install
%make_install \
    PREFIX="%{_prefix}" \
    LIB="%{_lib}" \
    LIBSUFFIX="-%{version}"

rm -rf "%{buildroot}%{_bindir}" %{buildroot}%{_datadir}/cryptopp
rm -rf %{buildroot}%{_libdir}/*.a
# Install .pc file with correct version field.
mkdir %{buildroot}%{_libdir}/pkgconfig/
cat > %{buildroot}%{_libdir}/pkgconfig/cryptopp.pc <<EOF
prefix=%{_prefix}
exec_prefix=\${prefix}
libdir=%{_libdir}
includedir=%{_includedir}

Name:           libcrypto++
Description:    General purpose cryptographic shared library
URL:            https://www.cryptopp.com
Version:        %{version}
Libs: -lcryptopp
Cflags:
EOF

%check
LD_LIBRARY_PATH=%{buildroot}%{_libdir} %make_build test

%post   -n %{name}%{sover} -p /sbin/ldconfig
%postun -n %{name}%{sover} -p /sbin/ldconfig

%files -n %{name}%{sover}
%defattr(-,root,root)
%{_libdir}/libcryptopp.so.%{major}.*

%files -n %{name}-devel
%defattr(-,root,root)
%doc License.txt Readme.txt
%{_includedir}/cryptopp
%{_libdir}/libcryptopp.so
%{_libdir}/pkgconfig/cryptopp.pc

%changelog
openSUSE Build Service is sponsored by