aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-05-30 15:40:07 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-05-30 16:40:07 -0400
commit5ca7eb75069883bc5be9a078ee85207461fb5d55 (patch)
treeaa9c9b10ffd04d2541adcf8b2c182d9c353ef9ba /src
parent24f3d5b088ad657ebc47abb86e7a05ac5f0b1599 (diff)
downloadcryptography-5ca7eb75069883bc5be9a078ee85207461fb5d55.tar.gz
cryptography-5ca7eb75069883bc5be9a078ee85207461fb5d55.tar.bz2
cryptography-5ca7eb75069883bc5be9a078ee85207461fb5d55.zip
move files to make the next PR easier to read (#3651)
Diffstat (limited to 'src')
-rw-r--r--src/_cffi_src/openssl/src/osrandom_engine.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/src/_cffi_src/openssl/src/osrandom_engine.c b/src/_cffi_src/openssl/src/osrandom_engine.c
index 7300d784..d5c73868 100644
--- a/src/_cffi_src/openssl/src/osrandom_engine.c
+++ b/src/_cffi_src/openssl/src/osrandom_engine.c
@@ -80,49 +80,6 @@ static const char *osurandom_get_implementation(void) {
#endif /* CRYPTOGRAPHY_OSRANDOM_ENGINE_CRYPTGENRANDOM */
/****************************************************************************
- * BSD getentropy
- */
-#if CRYPTOGRAPHY_OSRANDOM_ENGINE == CRYPTOGRAPHY_OSRANDOM_ENGINE_GETENTROPY
-static const char *Cryptography_osrandom_engine_name = "osrandom_engine getentropy()";
-
-static int osrandom_init(ENGINE *e) {
- return 1;
-}
-
-static int osrandom_rand_bytes(unsigned char *buffer, int size) {
- int len, res;
- while (size > 0) {
- /* OpenBSD and macOS restrict maximum buffer size to 256. */
- len = size > 256 ? 256 : size;
- res = getentropy(buffer, 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;
-}
-
-static int osrandom_finish(ENGINE *e) {
- return 1;
-}
-
-static int osrandom_rand_status(void) {
- return 1;
-}
-
-static const char *osurandom_get_implementation(void) {
- return "getentropy";
-}
-#endif /* CRYPTOGRAPHY_OSRANDOM_ENGINE_GETENTROPY */
-
-/****************************************************************************
* /dev/urandom helpers for all non-BSD Unix platforms
*/
#ifdef CRYPTOGRAPHY_OSRANDOM_NEEDS_DEV_URANDOM
@@ -237,6 +194,49 @@ static void dev_urandom_close(void) {
#endif /* CRYPTOGRAPHY_OSRANDOM_NEEDS_DEV_URANDOM */
/****************************************************************************
+ * BSD getentropy
+ */
+#if CRYPTOGRAPHY_OSRANDOM_ENGINE == CRYPTOGRAPHY_OSRANDOM_ENGINE_GETENTROPY
+static const char *Cryptography_osrandom_engine_name = "osrandom_engine getentropy()";
+
+static int osrandom_init(ENGINE *e) {
+ return 1;
+}
+
+static int osrandom_rand_bytes(unsigned char *buffer, int size) {
+ int len, res;
+ while (size > 0) {
+ /* OpenBSD and macOS restrict maximum buffer size to 256. */
+ len = size > 256 ? 256 : size;
+ res = getentropy(buffer, 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;
+}
+
+static int osrandom_finish(ENGINE *e) {
+ return 1;
+}
+
+static int osrandom_rand_status(void) {
+ return 1;
+}
+
+static const char *osurandom_get_implementation(void) {
+ return "getentropy";
+}
+#endif /* CRYPTOGRAPHY_OSRANDOM_ENGINE_GETENTROPY */
+
+/****************************************************************************
* Linux getrandom engine with fallback to dev_urandom
*/