09243bd
%global includetests 0
09243bd
# 0=no, 1=yes
09243bd
%global cryptlibdir %{_libdir}/%{name}
09243bd
# The python3 subpackage cannot be build, because DL_EXPORT is missing in Python.h
09243bd
%global with_python3 0
09243bd
09243bd
Name:       cryptlib
b6ca2e8
Version:    3.4.3.1  
b6ca2e8
Release:    1%{?dist}
09243bd
Summary:    Security library and toolkit for encryption and authentication services    
09243bd
09243bd
Group:      System Environment/Libraries         
21f826b
License:    Sleepycat and OpenSSL     
09243bd
URL:        https://www.cs.auckland.ac.nz/~pgut001/cryptlib      
b6ca2e8
Source0:    https://crypto-bone.com/fedora/cl3431_fedora.zip      
b6ca2e8
Source1:    https://crypto-bone.com/fedora/cl3431_fedora.zip.sig
09243bd
# for security reasons a public signing key should always be stored in distgit
09243bd
# and never be used with a URL to make impersonation attacks harder
09243bd
# (verified: https://senderek.ie/keys/codesigningkey)
09243bd
Source2:    gpgkey-3274CB29956498038A9C874BFBF6E2C28E9C98DD.asc
09243bd
Source3:    https://crypto-bone.com/fedora/README-manual
09243bd
Source4:    https://crypto-bone.com/fedora/cryptlib-tests.tar.gz
09243bd
Source5:    https://crypto-bone.com/fedora/cryptlib-perlfiles.tar.gz
b6ca2e8
b6ca2e8
# soname is now libcl.so.3.4
b6ca2e8
Patch1:     ccflagspatch
b6ca2e8
Patch2:     javapatch
88ef35a
Patch3:     nativepatch
09243bd
09243bd
ExclusiveArch: x86_64 %{ix86} %{arm}
09243bd
09243bd
BuildRequires: gcc 
09243bd
BuildRequires: libbsd-devel   
09243bd
BuildRequires: gnupg2
09243bd
BuildRequires: coreutils
09243bd
BuildRequires: python >= 2.7
09243bd
BuildRequires: python2-devel >= 2.7
09243bd
%if %{with_python3}
ec0328a
BuildRequires: python3-devel
09243bd
%endif
09243bd
BuildRequires: java-devel
ec0328a
BuildRequires: perl
df6395a
BuildRequires: perl-devel
ec0328a
%if 0%{?fedora} >= 23
ec0328a
BuildRequires: perl-generators
ec0328a
%endif
ec0328a
BuildRequires: perl-Data-Dumper
09243bd
BuildRequires: perl-ExtUtils-MakeMaker
09243bd
09243bd
09243bd
# beignet provides a library libcl.so for OpenCL
09243bd
Conflicts: beignet
09243bd
09243bd
%description
09243bd
Cryptlib is a powerful security toolkit that allows even inexperienced crypto
09243bd
programmers to easily add encryption and authentication services to their
09243bd
software. The high-level interface provides anyone with the ability to add
09243bd
strong security capabilities to an application in as little as half an hour,
09243bd
without needing to know any of the low-level details that make the encryption
09243bd
or authentication work.  Because of this, cryptlib dramatically reduces the
09243bd
cost involved in adding security to new or existing applications.
09243bd
09243bd
At the highest level, cryptlib provides implementations of complete security
09243bd
services such as S/MIME and PGP/OpenPGP secure enveloping, SSL/TLS and
09243bd
SSH secure sessions, CA services such as CMP, SCEP, RTCS, and OCSP, and other
09243bd
security operations such as secure time-stamping. Since cryptlib uses
09243bd
industry-standard X.509, S/MIME, PGP/OpenPGP, and SSH/SSL/TLS data formats,
09243bd
the resulting encrypted or signed data can be easily transported to other
09243bd
systems and processed there, and cryptlib itself runs on virtually any
09243bd
operating system - cryptlib doesn't tie you to a single system.
09243bd
This allows email, files and EDI transactions to be authenticated with
09243bd
digital signatures and encrypted in an industry-standard format.
09243bd
09243bd
09243bd
%package devel
09243bd
Summary:  Cryptlib application development files 
09243bd
Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
09243bd
%description devel
09243bd
Header files and code for application development in C (and C++)
09243bd
09243bd
09243bd
%package test
09243bd
Summary:  Cryptlib test program
09243bd
Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
09243bd
%description test
09243bd
Cryptlib test programs for C, Java, Perl and Python
09243bd
09243bd
09243bd
%package java
09243bd
Summary:  Cryptlib bindings for Java
09243bd
Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
Requires: java-headless
09243bd
09243bd
%description java
09243bd
Cryptlib module for application development in Java
09243bd
09243bd
09243bd
%package javadoc
09243bd
Summary:  Cryptlib Java documentation
09243bd
Buildarch : noarch
09243bd
09243bd
%description javadoc
09243bd
Cryptlib Javadoc information
09243bd
09243bd
09243bd
%package python2
09243bd
Summary:  Cryptlib bindings for python2
09243bd
Group:    System Environment/Libraries
09243bd
Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
Requires: python >= 2.7
09243bd
09243bd
%description python2
09243bd
Cryptlib module for application development in Python 2
09243bd
09243bd
09243bd
# The python3 subpackage cannot be build, because DL_EXPORT is missing in Python.h
09243bd
# so python3 setup.py build fails
09243bd
09243bd
%if %{with_python3}
09243bd
     %package python3
09243bd
     Summary:  Cryptlib bindings for python3
09243bd
     Group:    System Environment/Libraries
09243bd
     Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
     # specify the python3 version which first provides DL_EXPORT support below
09243bd
     Requires: python >= 3.x  
09243bd
09243bd
     %description python3
09243bd
     Cryptlib module for application development in Python 3
09243bd
%endif
09243bd
09243bd
%package perl
09243bd
Summary:  Cryptlib bindings for perl
09243bd
Group:    System Environment/Libraries
09243bd
Requires: %{name}%{?_isa} = %{version}-%{release}
09243bd
Requires: man
09243bd
09243bd
%description perl
09243bd
Cryptlib module for application development in Perl
09243bd
09243bd
09243bd
09243bd
%prep
09243bd
# source code signature check with GnuPG
09243bd
KEYRING=$(echo %{SOURCE2})
09243bd
KEYRING=${KEYRING%%.asc}.gpg
09243bd
mkdir -p .gnupg
09243bd
gpg2 --homedir .gnupg --no-default-keyring --quiet --yes --output $KEYRING --dearmor  %{SOURCE2}
09243bd
gpg2 --homedir .gnupg --no-default-keyring --keyring $KEYRING --verify %{SOURCE1} %{SOURCE0}
09243bd
09243bd
rm -rf %{name}-%{version}
09243bd
mkdir %{name}-%{version}
09243bd
cd %{name}-%{version}
09243bd
/usr/bin/unzip -a %{SOURCE0}
09243bd
%patch1 -p1
09243bd
%patch2 -p1
88ef35a
%patch3 -p1
09243bd
# remove pre-build jar file
09243bd
rm %{_builddir}/%{name}-%{version}/bindings/cryptlib.jar
09243bd
# adapt perl files in bindings
09243bd
cd %{_builddir}/%{name}-%{version}/bindings
09243bd
/usr/bin/tar xpzf %{SOURCE5}
09243bd
09243bd
09243bd
%build
09243bd
cd %{name}-%{version}
09243bd
chmod +x tools/mkhdr.sh
09243bd
tools/mkhdr.sh
b6ca2e8
# rename cryptlib symbols that may collide with openssl symbols
b6ca2e8
chmod +x tools/rename.sh
b6ca2e8
tools/rename.sh
b6ca2e8
# build java bindings
09243bd
cp /etc/alternatives/java_sdk/include/jni.h .
09243bd
cp /etc/alternatives/java_sdk/include/linux/jni_md.h .
09243bd
09243bd
make clean
09243bd
make shared %{?_smp_mflags} ADDFLAGS="%{optflags}"
09243bd
make stestlib %{?_smp_mflags} ADDFLAGS="%{optflags}"
09243bd
09243bd
# build python modules
09243bd
ln -s libcl.so.3.4.3 libcl.so
09243bd
cd bindings
09243bd
python2 setup.py build
09243bd
09243bd
# DL_EXPORT is missing in Python.h, so the following build fails.
09243bd
# We need to disable the python3 subpackage until this problem is resolved.
09243bd
%if %{with_python3}
09243bd
     python3 setup.py build
09243bd
%endif
09243bd
09243bd
# build javadoc
09243bd
mkdir javadoc
09243bd
cd javadoc
09243bd
jar -xf ../cryptlib.jar
09243bd
javadoc cryptlib
09243bd
09243bd
09243bd
%install
09243bd
mkdir -p %{buildroot}%{_libdir}
09243bd
mkdir -p %{buildroot}%{_datadir}/licenses/%{name}
09243bd
mkdir -p %{buildroot}%{_docdir}/%{name}
09243bd
cp %{_builddir}/%{name}-%{version}/libcl.so.3.4.3 %{buildroot}%{_libdir}
09243bd
cd %{buildroot}%{_libdir}
b6ca2e8
ln -s libcl.so.3.4.3 libcl.so.3.4
b6ca2e8
ln -s libcl.so.3.4 libcl.so
09243bd
09243bd
# install header files
09243bd
mkdir -p %{buildroot}/%{_includedir}/%{name}
09243bd
cp %{_builddir}/%{name}-%{version}/crypt.h %{buildroot}%{_includedir}/%{name}
09243bd
cp %{_builddir}/%{name}-%{version}/cryptkrn.h %{buildroot}%{_includedir}/%{name}
09243bd
cp %{_builddir}/%{name}-%{version}/cryptlib.h %{buildroot}%{_includedir}/%{name}
09243bd
09243bd
# add Java bindings
09243bd
mkdir -p %{buildroot}/%{cryptlibdir}/java
09243bd
mkdir -p %{buildroot}/%{_jnidir}
09243bd
cp %{_builddir}/%{name}-%{version}/bindings/cryptlib.jar %{buildroot}%{_jnidir}
09243bd
09243bd
# install docs
09243bd
cp %{_builddir}/%{name}-%{version}/COPYING %{buildroot}%{_datadir}/licenses/%{name}
09243bd
cp %{_builddir}/%{name}-%{version}/README %{buildroot}%{_docdir}/%{name}/README
09243bd
echo "No tests performed." > %{_builddir}/%{name}-%{version}/stestlib.log
09243bd
cp %{_builddir}/%{name}-%{version}/stestlib.log %{buildroot}%{_docdir}/%{name}/stestlib.log
09243bd
cp %{SOURCE3} %{buildroot}%{_docdir}/%{name}
09243bd
09243bd
# install javadoc
09243bd
mkdir -p %{buildroot}%{_javadocdir}/%{name}
09243bd
rm -rf %{_builddir}/%{name}-%{version}/bindings/javadoc/META-INF
09243bd
cp -r %{_builddir}/%{name}-%{version}/bindings/javadoc/* %{buildroot}%{_javadocdir}/%{name}
09243bd
09243bd
# install python2 module
09243bd
mkdir -p %{buildroot}%{python2_sitelib}
09243bd
cp %{_builddir}/%{name}-%{version}/bindings/build/lib.linux-*%{python2_version}/cryptlib_py.so %{buildroot}%{python2_sitelib}
09243bd
09243bd
# install python3 module
09243bd
# add python3 installation code, when setup.py works in python3
09243bd
09243bd
# install Perl module
09243bd
mkdir -p %{buildroot}/usr/local/lib64
09243bd
mkdir -p %{buildroot}%{_libdir}/perl5
09243bd
mkdir -p %{buildroot}%{_mandir}/man3
09243bd
cd %{_builddir}/%{name}-%{version}/bindings
09243bd
mkdir -p %{_builddir}/include
09243bd
cp ../cryptlib.h %{_builddir}/include
b6ca2e8
cp ../tools/GenPerl.pl .
09243bd
export PERL_CRYPT_LIB_HEADER=%{_builddir}/include/cryptlib.h
09243bd
/usr/bin/perl Makefile.PL
09243bd
sed -i '/LDLOADLIBS = /s/thread/thread -L.. -lcl/' Makefile
09243bd
make
09243bd
make pure_install DESTDIR=%{buildroot}
09243bd
# clean the install
09243bd
rm $(find %{buildroot}/usr/local/lib*/perl5 -name ".packlist")
09243bd
chmod 0755 %{buildroot}/usr/local/lib*/perl5/auto/PerlCryptLib/PerlCryptLib.so
09243bd
mv %{buildroot}/usr/local/lib*/perl5/* %{buildroot}%{_libdir}/perl5
09243bd
mv %{buildroot}/usr/local/share/man/man3/* %{buildroot}%{_mandir}/man3
09243bd
09243bd
# install test programs
09243bd
cp %{_builddir}/%{name}-%{version}/stestlib %{buildroot}%{cryptlibdir}
09243bd
cp -r %{_builddir}/%{name}-%{version}/test %{buildroot}%{cryptlibdir}/test
09243bd
# remove all c code from the test directory
09243bd
rm -rf $(find %{buildroot}%{cryptlibdir}/test -name "*.c")
09243bd
09243bd
## remove all header files from the test directory
09243bd
# these header files are needed by the test program stestlib to find test files!
09243bd
#rm -rf $(find %%{buildroot}%%{cryptlibdir}/test -name "*.h")
09243bd
09243bd
cd %{buildroot}%{cryptlibdir}
09243bd
tar xpzf %{SOURCE4} 
09243bd
09243bd
%check
09243bd
# checks are performed after install
09243bd
# in KOJI tests must be disabled as there is no networking
09243bd
%if %{includetests}
09243bd
     cd %{_builddir}/%{name}-%{version}
b6ca2e8
     ln -s libcl.so.3.4.3 ./libcl.so.3.4
09243bd
     export LD_LIBRARY_PATH=.
09243bd
     echo "Running tests on the cryptlib library. This will take a few minutes."
09243bd
     echo "Network access is necessary to complete all tests!"
09243bd
     ./stestlib > %{_builddir}/%{name}-%{version}/stestlib.log
09243bd
     cp %{_builddir}/%{name}-%{version}/stestlib.log %{buildroot}%{_docdir}/%{name}/stestlib.log
09243bd
%endif
09243bd
09243bd
09243bd
%post -p /sbin/ldconfig
09243bd
09243bd
%postun -p /sbin/ldconfig
09243bd
09243bd
09243bd
%files
09243bd
%{_libdir}/libcl.so.3.4.3
b6ca2e8
%{_libdir}/libcl.so.3.4
b6ca2e8
%{_libdir}/libcl.so
09243bd
09243bd
%license   %{_datadir}/licenses/%{name}/COPYING
09243bd
%doc       %{_docdir}/%{name}/README
09243bd
%doc       %{_docdir}/%{name}/stestlib.log
09243bd
%doc       %{_docdir}/%{name}/README-manual
09243bd
09243bd
09243bd
%files devel
09243bd
%{_libdir}/libcl.so
09243bd
%{_includedir}/%{name}/crypt.h
09243bd
%{_includedir}/%{name}/cryptkrn.h
09243bd
%{_includedir}/%{name}/cryptlib.h
09243bd
09243bd
%files java
09243bd
%{_jnidir}/cryptlib.jar
09243bd
09243bd
%files javadoc
09243bd
%{_javadocdir}/%{name}
09243bd
09243bd
%files python2
09243bd
%{python2_sitelib}/cryptlib_py.so
09243bd
09243bd
# at the moment the python3 subpackage cannot be build
09243bd
%if %{with_python3}
09243bd
    %files python3
09243bd
%endif
09243bd
09243bd
%files perl
09243bd
%{_libdir}/perl5
09243bd
%{_mandir}/man3/PerlCryptLib.3pm.gz
09243bd
09243bd
%files test
09243bd
%{cryptlibdir}
09243bd
09243bd
09243bd
%changelog
21f826b
b6ca2e8
* Sat Feb 11 2017 Senderek Web Security <innovation@senderek.ie> - 3.4.3.1-1
b6ca2e8
- update to version 3.4.3.1
b6ca2e8
b6ca2e8
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 3.4.3-10
b6ca2e8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
b6ca2e8
9014633
* Tue Jan 31 2017 Senderek Web Security <innovation@senderek.ie> - 3.4.3-9
9014633
- compile with gcc-7.0 and -march=native
9014633
21f826b
* Tue Jul 26 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-8
21f826b
- change license tag (RHBZ #1352406)
21f826b
- rename symbols that collide with openssl (RHBZ #1352404)
21f826b
6b0636a
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.4.3-7
6b0636a
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
6b0636a
ec0328a
* Thu Jun 16 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-6
ec0328a
- Remove perl-generators for epel7
ec0328a
- Remove python3 script from test subpackage (fixes RHBZ #1347294)
ec0328a
09243bd
* Tue Jun 14 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-5
09243bd
- Fix source locations
09243bd
- Clean up perl file installation
09243bd
- Fix python3 module code in spec file
09243bd
09243bd
* Thu Jun 9 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-4
09243bd
- Removed the doc subpackage
09243bd
09243bd
* Mon Jun 6 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-3
09243bd
- Fixed Java subpackage dependency
09243bd
- Made devel arch specific
09243bd
09243bd
* Fri Jun 3 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-2
09243bd
- Added javadoc subpackage and made docs noarch
09243bd
- Added a perl subpackage
09243bd
- Modified native stestlib program with two tests disabled
09243bd
  (testSessionSSH and testSessionSSHClientCert)
09243bd
09243bd
* Wed Jun 1 2016 Senderek Web Security <innovation@senderek.ie> - 3.4.3-1
09243bd
- Added python2/python3 subpackage
09243bd
- Source code signature check with GnuPG enabled
09243bd
09243bd
* Sun May 29 2016 Senderek Web Security <innovation@senderek.ie> - 3.4-2
09243bd
- Added doc and java subpackage
09243bd
09243bd
* Fri May 27 2016 Senderek Web Security <innovation@senderek.ie> - 3.4-1
09243bd
- Initial version of the rpm package build