kivy-ios/kivy_ios/recipes/cryptography/getentropy.patch

46 lines
1.5 KiB
Diff
Raw Normal View History

2020-09-28 23:29:32 +02:00
--- a/src/_cffi_src/openssl/src/osrandom_engine.c 2019-01-22 17:41:49.000000000 +0100
+++ b/src/_cffi_src/openssl/src/osrandom_engine.c 2019-08-12 11:47:03.000000000 +0100
@@ -243,14 +243,10 @@
#if !defined(__APPLE__)
getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
#else
- if (&getentropy != NULL) {
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS;
- } else {
- getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
- int fd = dev_urandom_fd();
- if (fd < 0) {
- return 0;
- }
+ getentropy_works = CRYPTOGRAPHY_OSRANDOM_GETENTROPY_FALLBACK;
+ int fd = dev_urandom_fd();
+ if (fd < 0) {
+ return 0;
}
#endif
return 1;
2020-09-28 23:29:32 +02:00
@@ -266,22 +262,7 @@
return dev_urandom_read(buffer, size);
#endif
case CRYPTOGRAPHY_OSRANDOM_GETENTROPY_WORKS:
- while (size > 0) {
- /* OpenBSD and macOS restrict maximum buffer size to 256. */
2020-09-28 23:29:32 +02:00
- len = size > 256 ? 256 : size;
- res = getentropy(buffer, (size_t)len);
- if (res < 0) {
- ERR_Cryptography_OSRandom_error(
- CRYPTOGRAPHY_OSRANDOM_F_RAND_BYTES,
- CRYPTOGRAPHY_OSRANDOM_R_GETENTROPY_FAILED,
- __FILE__, __LINE__
- );
- return 0;
- }
- buffer += len;
- size -= len;
- }
- return 1;
+ return 0;
}
__builtin_unreachable();
}