1
0

Accepting request 433503 from X11:Cinnamon:Factory

OBS-URL: https://build.opensuse.org/request/show/433503
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/nemo-extensions?expand=0&rev=4
This commit is contained in:
Dominique Leuenberger 2016-10-10 14:20:58 +00:00 committed by Git OBS Bridge
commit 05a50b182c
3 changed files with 348 additions and 26 deletions

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Wed Oct 5 19:37:54 UTC 2016 - sor.alexei@meowr.ru
- Add nemo-gtkhash_mbedtls-2.x.patch: Add mbed TLS 2.x+ support.
- Enable gcrypt in nemo-gtkhash for openSUSE Leap 42.x.
- Separate locales into nemo-extension-compare-lang,
nemo-extension-emblems-lang, nemo-extension-gtkhash-lang,
nemo-extension-image-converter-lang, nemo-extension-preview-lang,
nemo-extension-pastebin-lang, nemo-extension-repairer-lang,
nemo-extension-seahorse-lang, nemo-extension-share-lang.
-------------------------------------------------------------------
Wed May 4 16:34:01 UTC 2016 - sor.alexei@meowr.ru
@ -69,4 +80,3 @@ Mon Oct 28 08:55:22 UTC 2013 - i@marguerite.su
- initial version 2.0.0
* a meta package

View File

@ -34,6 +34,8 @@ Patch1: nemo-terminal_vte-2.91.patch
Patch2: nemo-seahorse_no-nautilus-conflicts.patch
# PATCH-FIX-OPENSUSE nemo-dropbox_no-dropbox-bin.patch sor.alexei@meowr.ru -- Strip dropbox binary installation.
Patch3: nemo-dropbox_no-dropbox-bin.patch
# PATCH-FIX-OPENSUSE nemo-gtkhash_mbedtls-2.x.patch sor.alexei@meowr.ru -- Add mbed TLS 2.x+ support.
Patch4: nemo-gtkhash_mbedtls-2.x.patch
BuildRequires: docutils
BuildRequires: gettext-runtime
BuildRequires: gnome-common
@ -45,7 +47,7 @@ BuildRequires: meld
BuildRequires: mhash-devel
BuildRequires: nemo-devel
BuildRequires: openssl-devel
BuildRequires: pkg-config
BuildRequires: pkgconfig
BuildRequires: python-devel
BuildRequires: python-distutils-extra
BuildRequires: python-gtk-devel
@ -69,7 +71,7 @@ BuildRequires: pkgconfig(nettle)
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(pygobject-3.0)
BuildRequires: pkgconfig(webkitgtk-3.0)
%if 0%{?suse_version} > 1320 || (0%{?suse_version} == 1315 && 0%{?is_opensuse})
%if 0%{?suse_version} > 1320 || (0%{?sle_version} >= 120100 && 0%{?is_opensuse})
BuildRequires: mbedtls-devel
%endif
@ -111,6 +113,7 @@ Requires: python-gobject
Requires: python-gtk
Requires: python-nemo = %{version}
Requires: python-xdg
Recommends: nemo-extension-compare-lang
# nemo-compare was last used in openSUSE 13.2.
Provides: nemo-compare = %{version}
Obsoletes: nemo-compare < %{version}
@ -124,6 +127,8 @@ do the comparison and provides "Compare", "Compare to ~/foo/bar" and
you can choose your favourite compare tool for one-on-one,
three-way and multi-compare situations.
%lang_package -n nemo-extension-compare
%package -n nemo-extension-dropbox
Summary: DropBox support for the Nemo Filemanager
License: GPL-3.0+
@ -144,6 +149,7 @@ License: GPL-3.0
Group: System/GUI/Other
Requires: nemo >= %{_version}
Requires: python-gobject
Recommends: nemo-extension-emblems-lang
# nemo-emblems was last used in openSUSE 13.2.
Provides: nemo-emblems = %{version}
Obsoletes: nemo-emblems < %{version}
@ -156,6 +162,8 @@ Requires: python-gobject-Gdk
Change a directory or a file emblem in Nemo, the Cinnamon desktop
file manager.
%lang_package -n nemo-extension-emblems
%package -n nemo-extension-fileroller
Summary: Fileroller support for the Nemo Filemanager
License: GPL-3.0+
@ -175,6 +183,7 @@ Summary: Nemo extension for computing checksums and more using gtkhash
License: GPL-2.0+
Group: System/GUI/Other
Requires: nemo >= %{_version}
Recommends: nemo-extension-gtkhash-lang
# nemo-gtkhash was last used in openSUSE 13.2.
Obsoletes: nemo-gtkhash < %{version}
Provides: nemo-gtkhash = %{version}
@ -186,12 +195,15 @@ message digests or checksums using the mhash library.
Currently supported hash functions include MD5, MD6, SHA1, SHA256,
SHA512, RIPEMD, TIGER and WHIRLPOOL.
%lang_package -n nemo-extension-gtkhash
%package -n nemo-extension-image-converter
Summary: Nemo extension to mass resize or rotate images
License: GPL-2.0+
Group: System/GUI/Other
Requires: ImageMagick
Requires: nemo >= %{_version}
Recommends: nemo-extension-converter-lang
# nemo-image-converter was last used in openSUSE 13.2.
Provides: nemo-image-converter = %{version}
Obsoletes: nemo-image-converter < %{version}
@ -202,6 +214,8 @@ menu of all images. This opens a dialog where you set the desired
image size and file name. A click on "Resize" finally resizes the
image(s) using ImageMagick's convert tool.
%lang_package -n nemo-extension-image-converter
%package -n nemo-extension-pastebin
Summary: Pastebin extension for Nemo file manager
License: GPL-2.0+
@ -209,6 +223,7 @@ Group: System/GUI/Other
Requires: nemo >= %{_version}
Requires: python-gobject
Requires: python-xdg
Recommends: nemo-extension-pastebin-lang
# nemo-pastebin was last used in openSUSE 13.2.
Provides: nemo-pastebin = %{version}
Obsoletes: nemo-pastebin < %{version}
@ -222,12 +237,15 @@ Requires: python-gobject-Gdk
nemo-pastebin is an extension for the Nemo file manager, which
allows users to send files to pastebins just a right-click away.
%lang_package -n nemo-extension-pastebin
%package -n nemo-extension-preview
Summary: A quick previewer for Nemo file manager
License: GPL-2.0+
Group: System/GUI/Other
Requires: gstreamer-plugins-good
Requires: nemo >= %{_version}
Recommends: nemo-extension-preview-lang
# nemo-preview was last used in openSUSE 13.2.
Obsoletes: nemo-preview < %{version}
Provides: nemo-extension-preview-devel = %{version}
@ -237,6 +255,8 @@ Provides: nemo-preview = %{version}
This is NemoPreview, a quick previewer for Nemo, the Cinnamon
desktop file manager.
%lang_package -n nemo-extension-preview
%package -n nemo-extension-rabbitvcs
Summary: RabbitVCS extension for Nemo file manager
License: GPL-3.0+
@ -258,6 +278,7 @@ Summary: Nemo extension for filename encoding repair
License: GPL-2.0+
Group: System/GUI/Other
Requires: nemo >= %{_version}
Recommends: nemo-extension-repairer-lang
# nemo-repairer was last used in openSUSE 13.2.
Provides: nemo-repairer = %{version}
Obsoletes: nemo-repairer < %{version}
@ -268,6 +289,8 @@ encoding in Nemo. This extension provides the context menu for any
file whose filename uses wrong encoding, so that you cannot read the
filename in Nemo.
%lang_package -n nemo-extension-repairer
You can find a candidate for filename in context menu or submenu.
This extension also provides a decoded name for URL encoded filename.
@ -277,6 +300,7 @@ License: GPL-2.0+
Group: System/GUI/Other
Requires: nautilus-extension-seahorse >= 3.0
Requires: nemo >= %{_version}
Recommends: nemo-extension-seahorse-lang
Supplements: packageand(nemo:seahorse)
# nemo-seahorse was last used in openSUSE 13.2.
Provides: nemo-seahorse = %{version}
@ -284,13 +308,16 @@ Obsoletes: nemo-seahorse < %{version}
%description -n nemo-extension-seahorse
seahorse nemo is an extension for nemo which allows encryption
and decryption of OpenPGP files using GnuPG
and decryption of OpenPGP files using GnuPG.
%lang_package -n nemo-extension-seahorse
%package -n nemo-extension-share
Summary: Samba share extension for Nemo file manager
License: GPL-2.0+
Group: System/GUI/Other
Requires: nemo >= %{_version}
Recommends: nemo-extension-share-lang
Recommends: samba
Supplements: packageand(nemo:samba)
# nemo-share was last used in openSUSE 13.2.
@ -301,6 +328,8 @@ Obsoletes: nemo-share < %{version}
Nemo Share allows you to quickly share a folder from the Cinnamon
Nemo file manager without requiring root access.
%lang_package -n nemo-extension-share
%package -n nemo-extension-terminal
Summary: Nemo extension to enable an embedded terminal
License: GPL-3.0+
@ -328,6 +357,7 @@ directory in Nemo.
%patch1
%patch2
%patch3
%patch4
# Remove spurious executable permission.
chmod a-x nemo-audio-tab/COPYING.GPL3 nemo-emblems/COPYING.GPL3
@ -339,7 +369,7 @@ find . -type d -maxdepth 1 -mindepth 1 | while read dir; do
%configure \
--disable-static
fi
[ -f Makefile ] && make %{?_smp_mflags}
[ -f Makefile ] && make %{?_smp_mflags} V=1
[ -f setup.py ] && ./setup.py build
popd
done
@ -350,19 +380,19 @@ pushd nemo-gtkhash
--disable-static \
--enable-linux-crypto \
--enable-libcrypto \
%if 0%{?suse_version} >= 1320
%if 0%{?suse_version} >= 1320 || (0%{?sle_version} >= 120100 && 0%{?is_opensuse})
--enable-gcrypt \
%else
--disable-gcrypt \
%endif
%if 0%{?suse_version} > 1320 || (0%{?suse_version} == 1315 && 0%{?is_opensuse})
%if 0%{?suse_version} > 1320 || (0%{?sle_version} >= 120100 && 0%{?is_opensuse})
--enable-polarssl \
%endif
--enable-nettle \
--enable-nss \
--enable-mhash \
--enable-nemo
make %{?_smp_mflags}
make %{?_smp_mflags} V=1
popd
%install
@ -376,23 +406,23 @@ find . -type d -maxdepth 1 -mindepth 1 | while read dir; do
done
# For nemo-extension-audio-tab.
install -Dm 0644 nemo-audio-tab/nemo-extension/nemo-audio-tab.py \
install -Dpm 0644 nemo-audio-tab/nemo-extension/nemo-audio-tab.py \
%{buildroot}%{_datadir}/nemo-python/extensions/nemo-audio-tab.py
install -Dm 0755 nemo-audio-tab/nemo-extension/nemo-audio-tab.glade \
install -Dpm 0755 nemo-audio-tab/nemo-extension/nemo-audio-tab.glade \
%{buildroot}%{_datadir}/nemo-python/extensions/nemo-audio-tab.glade
# For nemo-extension-compare.
# "gtk-preferences icon isn't in hicolor-icon-theme, why not Meld?
sed -i 's/^\(Icon=\).*$/\1meld/' nemo-compare/data/nemo-compare-preferences.desktop
install -Dm 0755 nemo-compare/data/nemo-compare-preferences.desktop \
install -Dpm 0755 nemo-compare/data/nemo-compare-preferences.desktop \
%{buildroot}%{_datadir}/applications/nemo-compare-preferences.desktop
install -Dm 0755 nemo-compare/src/nemo-compare.py \
install -Dpm 0755 nemo-compare/src/nemo-compare.py \
%{buildroot}%{_datadir}/nemo-compare/nemo-compare.py
install -Dm 0755 nemo-compare/src/utils.py %{buildroot}%{_datadir}/nemo-compare/utils.py
install -Dm 0755 nemo-compare/src/nemo-compare-preferences.py \
install -Dpm 0755 nemo-compare/src/utils.py %{buildroot}%{_datadir}/nemo-compare/utils.py
install -Dpm 0755 nemo-compare/src/nemo-compare-preferences.py \
%{buildroot}%{_datadir}/nemo-compare/nemo-compare-preferences.py
install -Dm 0644 nemo-compare/debian/nemo-compare-preferences.1 \
install -Dpm 0644 nemo-compare/debian/nemo-compare-preferences.1 \
%{buildroot}%{_mandir}/man1/nemo-compare-preferences.1
mkdir -p %{buildroot}%{_bindir}/ %{buildroot}%{_datadir}/nemo-python/
@ -418,13 +448,13 @@ mkdir -p %{buildroot}%{_docdir}/
mv -f %{buildroot}%{_datadir}/doc/nemo-python/ %{buildroot}%{_docdir}/nemo-python/
# For nemo-extension-rabbitvcs.
install -Dm 0644 nemo-rabbitvcs/RabbitVCS.py \
install -Dpm 0644 nemo-rabbitvcs/RabbitVCS.py \
%{buildroot}%{_datadir}/nemo-python/extensions/RabbitVCS.py
# For nemo-extension-terminal.
pushd nemo-terminal
mkdir -p %{buildroot}%{_datadir}/nemo-terminal/
install -Dm 0755 src/nemo_terminal.py \
install -Dpm 0755 src/nemo_terminal.py \
%{buildroot}%{_datadir}/nemo-python/extensions/nemo_terminal.py
cp -a src/*.xml %{buildroot}%{_datadir}/glib-2.0/schemas/
cp -a pixmap/*.png %{buildroot}%{_datadir}/nemo-terminal/
@ -508,7 +538,7 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_datadir}/nemo-python/extensions/nemo-audio-tab.*
%{python_sitelib}/nemo_audio_tab-*
%files -n nemo-extension-compare -f nemo-compare.lang
%files -n nemo-extension-compare
%defattr(-,root,root)
%doc nemo-compare/nemo-compare/COPYING* nemo-compare/debian/changelog
%{_bindir}/nemo-compare-preferences
@ -517,23 +547,29 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_datadir}/applications/nemo-compare-preferences.desktop
%{_mandir}/man1/nemo-compare-preferences.1%{?ext_man}
%files -n nemo-extension-compare-lang -f nemo-compare.lang
%defattr(-,root,root)
%files -n nemo-extension-dropbox
%defattr(-,root,root)
%doc nemo-dropbox/AUTHORS nemo-dropbox/COPYING nemo-dropbox/debian/changelog
%{_libdir}/nemo/extensions-3.0/libnemo-dropbox.so
%files -n nemo-extension-emblems -f nemo-emblems.lang
%files -n nemo-extension-emblems
%defattr(-,root,root)
%doc nemo-emblems/COPYING* nemo-emblems/debian/changelog
%{_datadir}/nemo-python/extensions/nemo-emblems.py
%{python_sitelib}/nemo_emblems-*
%files -n nemo-extension-emblems-lang -f nemo-emblems.lang
%defattr(-,root,root)
%files -n nemo-extension-fileroller
%defattr(-,root,root)
%doc nemo-fileroller/COPYING nemo-fileroller/debian/changelog
%{_libdir}/nemo/extensions-3.0/libnemo-fileroller.so
%files -n nemo-extension-gtkhash -f nemo-gtkhash.lang
%files -n nemo-extension-gtkhash
%defattr(-,root,root)
%doc nemo-gtkhash/AUTHORS nemo-gtkhash/COPYING nemo-gtkhash/debian/changelog
%{_bindir}/gtkhash
@ -541,13 +577,19 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_datadir}/nemo-gtkhash/
%{_datadir}/glib-2.0/schemas/*gtkhash*.gschema.xml
%files -n nemo-extension-image-converter -f nemo-image-converter.lang
%files -n nemo-extension-gtkhash-lang -f nemo-gtkhash.lang
%defattr(-,root,root)
%files -n nemo-extension-image-converter
%defattr(-,root,root)
%doc nemo-image-converter/AUTHORS nemo-image-converter/COPYING nemo-image-converter/debian/changelog
%{_libdir}/nemo/extensions-3.0/libnemo-image-converter.so
%{_datadir}/nemo-image-converter/
%files -n nemo-extension-pastebin -f nemo-pastebin.lang
%files -n nemo-extension-image-converter-lang -f nemo-image-converter.lang
%defattr(-,root,root)
%files -n nemo-extension-pastebin
%defattr(-,root,root)
%doc nemo-pastebin/COPYING nemo-pastebin/debian/changelog
%{_bindir}/nemo-pastebin.py
@ -558,7 +600,10 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_datadir}/pixmaps/nemo-pastebin.*
%{_datadir}/glib-2.0/schemas/nemo-pastebin.gschema.xml
%files -n nemo-extension-preview -f nemo-preview.lang
%files -n nemo-extension-pastebin-lang -f nemo-pastebin.lang
%defattr(-,root,root)
%files -n nemo-extension-preview
%defattr(-,root,root)
%doc nemo-preview/AUTHORS nemo-preview/COPYING nemo-preview/debian/changelog
%{_bindir}/nemo-preview
@ -567,29 +612,41 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_datadir}/nemo-preview/
%{_datadir}/dbus-1/services/org.nemo.Preview.service
%files -n nemo-extension-preview-lang -f nemo-preview.lang
%defattr(-,root,root)
%files -n nemo-extension-rabbitvcs
%defattr(-,root,root)
%doc nemo-rabbitvcs/AUTHORS nemo-rabbitvcs/COPYING nemo-rabbitvcs/debian/changelog
%{_datadir}/nemo-python/extensions/RabbitVCS.py
%files -n nemo-extension-repairer -f nemo-filename-repairer.lang
%files -n nemo-extension-repairer
%defattr(-,root,root)
%doc nemo-repairer/AUTHORS nemo-repairer/COPYING nemo-repairer/COPYING nemo-repairer/README
%{_bindir}/nemo-filename-repairer
%{_libdir}/nemo/extensions-3.0/libnemo-filename-repairer.so
%{_datadir}/nemo-filename-repairer/
%files -n nemo-extension-seahorse -f nemo-seahorse.lang
%files -n nemo-extension-repairer-lang -f nemo-filename-repairer.lang
%defattr(-,root,root)
%files -n nemo-extension-seahorse
%defattr(-,root,root)
%doc nemo-seahorse/COPYING nemo-seahorse/debian/changelog
%{_libdir}/nemo/extensions-3.0/libnemo-seahorse.so
%files -n nemo-extension-share -f nemo-share.lang
%files -n nemo-extension-seahorse-lang -f nemo-seahorse.lang
%defattr(-,root,root)
%files -n nemo-extension-share
%defattr(-,root,root)
%doc nemo-share/AUTHORS nemo-share/COPYING nemo-share/debian/changelog
%{_libdir}/nemo/extensions-3.0/libnemo-share.so
%{_datadir}/nemo-share/
%files -n nemo-extension-share-lang -f nemo-share.lang
%defattr(-,root,root)
%files -n nemo-extension-terminal
%defattr(-,root,root)
%doc nemo-terminal/AUTHORS nemo-terminal/COPYING nemo-terminal/debian/changelog

View File

@ -0,0 +1,255 @@
--- nemo-gtkhash.orig/configure.ac
+++ nemo-gtkhash/configure.ac
@@ -144,13 +144,25 @@ AC_ARG_ENABLE([polarssl],
AC_MSG_RESULT(["${enable_polarssl}"])
AM_CONDITIONAL([ENABLE_POLARSSL], [test "${enable_polarssl}" = "yes"])
AC_DEFINE([ENABLE_POLARSSL], [0], [Use PolarSSL])
+AC_DEFINE([HAVE_MBEDTLS_2_0_0], [0], [Have mbed TLS 2.x+])
if test "${enable_polarssl}" = "yes" ; then
- AC_CHECK_HEADER([polarssl/md.h], [:], [AC_MSG_ERROR([polarssl headers not found])])
- AC_CHECK_LIB([polarssl], [md_update], [:], [AC_MSG_ERROR([polarssl library not found])])
- POLARSSL_LIBS="-lpolarssl"
+ AC_CHECK_HEADER([mbedtls/md.h], [have_mbedtls_2_0_0="yes"], [have_mbedtls_2_0_0="no"])
+ AC_CHECK_HEADER([polarssl/md.h], [have_mbedtls_1_3_0="yes"], [have_mbedtls_1_3_0="no"])
+ if test "${have_mbedtls_2_0_0}" != "yes" && test "${have_mbedtls_1_3_0}" != "yes"; then
+ AC_MSG_ERROR([mbedtls headers not found])
+ fi
+ if test "${have_mbedtls_2_0_0}" = "yes"; then
+ AC_CHECK_LIB([mbedcrypto], [mbedtls_md_update], [:], [AC_MSG_ERROR([mbedtls library not found])])
+ POLARSSL_LIBS="-lmbedcrypto"
+ hash_libs="${hash_libs} mbedtls"
+ AC_DEFINE([HAVE_MBEDTLS_2_0_0], [1])
+ else
+ AC_CHECK_LIB([polarssl], [md_update], [:], [AC_MSG_ERROR([mbedtls library not found])])
+ POLARSSL_LIBS="-lpolarssl"
+ hash_libs="${hash_libs} polarssl"
+ fi
AC_SUBST([POLARSSL_LIBS])
- hash_libs="${hash_libs} polarssl"
AC_DEFINE([ENABLE_POLARSSL], [1])
fi
@@ -365,6 +377,7 @@ nss_funcs="
SHA1 SHA256 SHA384 SHA512"
polarssl_funcs="
MD2 MD4 MD5
+ RIPEMD160
SHA1 SHA224 SHA256 SHA384 SHA512"
zlib_funcs="
CRC32
--- nemo-gtkhash.orig/src/hash/hash-lib-polarssl.c
+++ nemo-gtkhash/src/hash/hash-lib-polarssl.c
@@ -25,7 +25,11 @@
#include <stdbool.h>
#include <stdint.h>
#include <glib.h>
+#if HAVE_MBEDTLS_2_0_0
+#include <mbedtls/md.h>
+#else
#include <polarssl/md.h>
+#endif
#include "hash-lib-polarssl.h"
#include "hash-lib.h"
@@ -34,35 +38,83 @@
#define LIB_DATA ((struct hash_lib_polarssl_s *)func->lib_data)
struct hash_lib_polarssl_s {
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_context_t ctx;
+#else
md_context_t ctx;
+#endif
};
-static bool gtkhash_hash_lib_polarssl_set_type(const enum hash_func_e id, md_type_t *type)
+static bool gtkhash_hash_lib_polarssl_set_type(const enum hash_func_e id,
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_type_t *type)
+#else
+ md_type_t *type)
+#endif
{
switch (id) {
case HASH_FUNC_MD2:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_MD2;
+#else
*type = POLARSSL_MD_MD2;
+#endif
break;
case HASH_FUNC_MD4:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_MD4;
+#else
*type = POLARSSL_MD_MD4;
+#endif
break;
case HASH_FUNC_MD5:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_MD5;
+#else
*type = POLARSSL_MD_MD5;
+#endif
+ break;
+ case HASH_FUNC_RIPEMD160:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_RIPEMD160;
+#else
+ *type = POLARSSL_MD_RIPEMD160;
+#endif
break;
case HASH_FUNC_SHA1:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_SHA1;
+#else
*type = POLARSSL_MD_SHA1;
+#endif
break;
case HASH_FUNC_SHA224:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_SHA224;
+#else
*type = POLARSSL_MD_SHA224;
+#endif
break;
case HASH_FUNC_SHA256:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_SHA256;
+#else
*type = POLARSSL_MD_SHA256;
+#endif
break;
case HASH_FUNC_SHA384:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_SHA384;
+#else
*type = POLARSSL_MD_SHA384;
+#endif
break;
case HASH_FUNC_SHA512:
+#if HAVE_MBEDTLS_2_0_0
+ *type = MBEDTLS_MD_SHA512;
+#else
*type = POLARSSL_MD_SHA512;
+#endif
break;
default:
return false;
@@ -71,14 +123,29 @@ static bool gtkhash_hash_lib_polarssl_se
return true;
}
+
bool gtkhash_hash_lib_polarssl_is_supported(const enum hash_func_e id)
{
- struct hash_lib_polarssl_s data;
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_type_t type;
+#else
md_type_t type;
-
+#endif
if (!gtkhash_hash_lib_polarssl_set_type(id, &type))
return false;
+ struct hash_lib_polarssl_s data;
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_init(&data.ctx);
+
+ const mbedtls_md_info_t *info = mbedtls_md_info_from_type(type);
+ if (mbedtls_md_setup(&data.ctx, info, 0) != 0) {
+ mbedtls_md_free(&data.ctx);
+ return false;
+ }
+
+ mbedtls_md_free(&data.ctx);
+#else
if (md_init_ctx(&data.ctx, md_info_from_type(type)) != 0)
return false;
@@ -86,6 +153,7 @@ bool gtkhash_hash_lib_polarssl_is_suppor
g_assert_not_reached();
return false;
}
+#endif
return true;
}
@@ -93,34 +161,67 @@ bool gtkhash_hash_lib_polarssl_is_suppor
void gtkhash_hash_lib_polarssl_start(struct hash_func_s *func)
{
func->lib_data = g_new(struct hash_lib_polarssl_s, 1);
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_type_t type;
+#else
md_type_t type;
+#endif
if (!gtkhash_hash_lib_polarssl_set_type(func->id, &type))
g_assert_not_reached();
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_init(&LIB_DATA->ctx);
+
+ const mbedtls_md_info_t *info = mbedtls_md_info_from_type(type);
+ if (mbedtls_md_setup(&LIB_DATA->ctx, info, 0) != 0)
+ g_assert_not_reached();
+
+ if (mbedtls_md_starts(&LIB_DATA->ctx) != 0)
+ g_assert_not_reached();
+
+#else
if (md_init_ctx(&LIB_DATA->ctx, md_info_from_type(type)) != 0)
g_assert_not_reached();
if (md_starts(&LIB_DATA->ctx) != 0)
g_assert_not_reached();
+#endif
}
void gtkhash_hash_lib_polarssl_update(struct hash_func_s *func,
const uint8_t *buffer, const size_t size)
{
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_update(&LIB_DATA->ctx, buffer, size);
+#else
md_update(&LIB_DATA->ctx, buffer, size);
+#endif
}
void gtkhash_hash_lib_polarssl_stop(struct hash_func_s *func)
{
+#if HAVE_MBEDTLS_2_0_0
+ mbedtls_md_free(&LIB_DATA->ctx);
+#else
if (md_free_ctx(&LIB_DATA->ctx) != 0)
g_assert_not_reached();
+#endif
g_free(LIB_DATA);
}
uint8_t *gtkhash_hash_lib_polarssl_finish(struct hash_func_s *func,
size_t *size)
{
+#if HAVE_MBEDTLS_2_0_0
+ *size = mbedtls_md_get_size(LIB_DATA->ctx.md_info);
+ uint8_t *digest = g_malloc(*size);
+
+ if (mbedtls_md_finish(&LIB_DATA->ctx, digest) != 0)
+ g_assert_not_reached();
+
+ mbedtls_md_free(&LIB_DATA->ctx);
+#else
*size = LIB_DATA->ctx.md_info->size;
uint8_t *digest = g_malloc(*size);
@@ -129,6 +230,7 @@ uint8_t *gtkhash_hash_lib_polarssl_finis
if (md_free_ctx(&LIB_DATA->ctx) != 0)
g_assert_not_reached();
+#endif
g_free(LIB_DATA);
return digest;