%global installdir %{_sysconfdir}/pki/dhparam
%global defaultdh ffdhe3072.pem

Name:       crypto-groups
Version:    202008.1
Release:    1%{?dist}
Summary:    Standardized Finite-Field Diffie-Hellman Ephemeral parameters
Url:        https://gitlab.com/lcts/crypto-groups
License:    GPLv3
Source0:    https://gitlab.com/lcts/%{name}/-/archive/%{version}/%{name}-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  bash
BuildRequires:  openssl
Requires:       bash
Obsoletes:      ffdhe < 1.1.0-1 ffdhe-rfc7919 < 1.1.0-4
Provides:       ffdhe = 1.1.0-1 ffdhe-rfc7919 = 1.1.0-4

%description
Crypto-groups contains standardized Finite-Field Diffie-Hellman Ephemeral
prime groups as defined by various RFC documents, both as individual
.pem-encoded files for use with web servers etc., as well as concatenated
into a single moduli file for use with OpenSSH.

#-- PREP, BUILD & INSTALL -----------------------------------------------------#
%prep
%autosetup -p1

%build
./generate_pem.sh -e 'modp768-group1,modp1024-group2,modp1024-group22,modp2048-group23,modp2048-group24'

%install
install -p -d -m 0755 %{buildroot}%{installdir}/

install -m 0644 moduli.template %{buildroot}%{installdir}/moduli
install -m 0644 *.pem %{buildroot}%{installdir}/
ln -sf %{installdir}/%{defaultdh} %{buildroot}%{installdir}/default.pem

#-- FILES ---------------------------------------------------------------------#
%files
%doc README.md
%doc definitions
%doc CHANGELOG
%license LICENSE
%dir %{installdir}
%config %{installdir}/*

#-- CHANGELOG -----------------------------------------------------------------#
%changelog
* Tue Aug 25 2020 Christopher Engelhard <ce@lcts.de> 202008.1-1
- initial release
- replaces packages ffdhe and ffdhe-rfc7919
- adds standard modp... groups required for
  FIPS and legacy modes