File libtpms.spec of Package libtpms

#
# spec file for package libtpms
#
# 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 lname libtpms0
Name:           libtpms
Version:        0.8.2
Release:        0
Summary:        Library providing Trusted Platform Module (TPM) functionality
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
URL:            https://github.com/stefanberger/libtpms
Source0:        https://github.com/stefanberger/libtpms/archive/v%{version}.tar.gz
# CVE-2021-3746 [bsc#1189935], out-of-bounds access via specially crafted TPM 2 command packets
Patch0:         libtpms-CVE-2021-3746.patch
Patch1:		0002-tpm2-Add-maxSize-parameter-to-TPM2B_Marshal-for-sani.patch
Patch2:		0001-tpm2-Reset-TPM2B-buffer-sizes-after-test-fails-for-v.patch
Patch3:		0003-tpm2-Restore-original-value-if-unmarsalled-value-was.patch
Patch4:		0001-tpm2-Check-size-of-buffer-before-accessing-it-CVE-20.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  gcc-c++
BuildRequires:  libtool
BuildRequires:  mozilla-nspr-devel
BuildRequires:  openssl-devel
BuildRequires:  pkgconfig

%description
A library providing TPM functionality for VMs. Targeted for integration
into Qemu.

%package -n %{lname}
Summary:        Library providing Trusted Platform Module (TPM) functionality
Group:          Development/Libraries/C and C++

%description -n %{lname}
A library providing TPM functionality for VMs. Targeted for integration
into Qemu.

%package        devel
Summary:        Include files for libtpms
Group:          Development/Libraries/C and C++
Requires:       %{lname} = %{version}
Requires:       libopenssl-devel
Requires:       mozilla-nspr-devel

%description   devel
Libtpms header files and documentation.

%prep
%setup -q -n libtpms-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1

%build
./bootstrap.sh
%configure \
	--with-tpm2 \
	--with-openssl	\
        --disable-static

make %{?_smp_mflags}

%check
%ifarch ppc64le
export SUSE_ASNEEDED=0
%endif

make %{?_smp_mflags} check

%install
install -d -m 0755 %{buildroot}%{_libdir}
install -d -m 0755 %{buildroot}%{_includedir}/libtpms
install -d -m 0755 %{buildroot}%{_mandir}/man3

%make_install

%post -n %{lname} -p /sbin/ldconfig
%postun -n %{lname} -p /sbin/ldconfig

%files -n %{lname}
%doc README CHANGES
%license LICENSE
%{_libdir}/%{name}.so.%{version}
%{_libdir}/%{name}.so.0

%files devel
%{_libdir}/%{name}.so
%{_libdir}/%{name}.la
%dir %{_includedir}/%{name}
%attr(644, root, root) %{_libdir}/pkgconfig/*.pc
%attr(644, root, root) %{_includedir}/%{name}/*.h
%attr(644, root, root) %{_mandir}/man3/*

%changelog
openSUSE Build Service is sponsored by