SHA256
1
0
forked from pool/mbedtls

Accepting request 293983 from devel:libraries:c_c++

1

OBS-URL: https://build.opensuse.org/request/show/293983
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/mbedtls?expand=0&rev=2
This commit is contained in:
Dominique Leuenberger 2015-04-02 14:04:15 +00:00 committed by Git OBS Bridge
parent a811e8daf5
commit 658f3b29c4
3 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,67 @@
Index: mbedtls-1.3.10/library/entropy_poll.c
===================================================================
--- mbedtls-1.3.10.orig/library/entropy_poll.c
+++ mbedtls-1.3.10/library/entropy_poll.c
@@ -81,40 +81,35 @@ int platform_entropy_poll( void *data, u
#include <sys/syscall.h>
#if defined(SYS_getrandom)
#define HAVE_GETRANDOM
-static int getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
+static ssize_t getrandom_wrapper( void *buf, size_t buflen, unsigned int flags )
{
return( syscall( SYS_getrandom, buf, buflen, flags ) );
}
#endif /* SYS_getrandom */
#endif /* __linux__ */
-#if defined(HAVE_GETRANDOM)
-
+#include <stdio.h>
#include <errno.h>
int platform_entropy_poll( void *data,
unsigned char *output, size_t len, size_t *olen )
{
- int ret;
+ FILE *file;
+ size_t ret;
((void) data);
- if( ( ret = getrandom_wrapper( output, len, 0 ) ) < 0 )
- return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
-
- *olen = ret;
- return( 0 );
-}
-
-#else /* HAVE_GETRANDOM */
+#if defined(HAVE_GETRANDOM)
+ ssize_t sysret;
-#include <stdio.h>
+ if( ( sysret = getrandom_wrapper( output, len, 0 ) ) >= 0 )
+ {
+ *olen = sysret;
+ return( 0 );
+ }
+ if (sysret < 0 && errno != ENOSYS)
+ return( POLARSSL_ERR_ENTROPY_SOURCE_FAILED );
-int platform_entropy_poll( void *data,
- unsigned char *output, size_t len, size_t *olen )
-{
- FILE *file;
- size_t ret;
- ((void) data);
+#endif /* HAVE_GETRANDOM */
*olen = 0;
@@ -134,7 +129,6 @@ int platform_entropy_poll( void *data,
return( 0 );
}
-#endif /* HAVE_GETRANDOM */
#endif /* _WIN32 && !EFIX64 && !EFI32 */
#endif /* !POLARSSL_NO_PLATFORM_ENTROPY */

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Apr 1 11:05:55 UTC 2015 - schwab@suse.de
- getrandom-syscall-fallback.patch: Fall back to /dev/urandom if getrandom
syscall is not implemented.
-------------------------------------------------------------------
Fri Mar 27 16:59:55 UTC 2015 - mpluskal@suse.com

View File

@ -25,6 +25,7 @@ License: GPL-2.0+
Group: Development/Libraries/C and C++
Url: https://tls.mbed.org
Source: https://tls.mbed.org/download/%{name}-%{version}-gpl.tgz
Patch: getrandom-syscall-fallback.patch
BuildRequires: cmake
BuildRequires: pkg-config
BuildRequires: zlib-devel
@ -54,6 +55,7 @@ A portable, easy to use, readable and flexible SSL library.
%prep
%setup -q
%patch -p1
sed -i 's|//\(#define POLARSSL_THREADING_C\)|\1|' include/polarssl/config.h
sed -i 's|//\(#define POLARSSL_THREADING_PTHREAD\)|\1|' include/polarssl/config.h