summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/bootstrap_hash.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:30 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:30 +0300
commit2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch)
tree012bb94d777798f1f56ac1cec429509766d05181 /contrib/tools/python3/src/Python/bootstrap_hash.c
parent6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Python/bootstrap_hash.c')
-rw-r--r--contrib/tools/python3/src/Python/bootstrap_hash.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/contrib/tools/python3/src/Python/bootstrap_hash.c b/contrib/tools/python3/src/Python/bootstrap_hash.c
index e189ce0d901..a1a9e077995 100644
--- a/contrib/tools/python3/src/Python/bootstrap_hash.c
+++ b/contrib/tools/python3/src/Python/bootstrap_hash.c
@@ -1,5 +1,5 @@
#include "Python.h"
-#include "pycore_initconfig.h"
+#include "pycore_initconfig.h"
#ifdef MS_WINDOWS
# include <windows.h>
/* All sample MSDN wincrypt programs include the header below. It is at least
@@ -25,16 +25,16 @@
# include <sanitizer/msan_interface.h>
#endif
-#if defined(__APPLE__) && defined(__has_builtin)
-# if __has_builtin(__builtin_available)
-# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME __builtin_available(macOS 10.12, iOS 10.10, tvOS 10.0, watchOS 3.0, *)
-# endif
-#endif
-#ifndef HAVE_GETENTRYPY_GETRANDOM_RUNTIME
-# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME 1
-#endif
-
-
+#if defined(__APPLE__) && defined(__has_builtin)
+# if __has_builtin(__builtin_available)
+# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME __builtin_available(macOS 10.12, iOS 10.10, tvOS 10.0, watchOS 3.0, *)
+# endif
+#endif
+#ifndef HAVE_GETENTRYPY_GETRANDOM_RUNTIME
+# define HAVE_GETENTRYPY_GETRANDOM_RUNTIME 1
+#endif
+
+
#ifdef Py_DEBUG
int _Py_HashSecret_Initialized = 0;
#else
@@ -48,8 +48,8 @@ static int
win32_urandom_init(int raise)
{
/* Acquire context */
- if (!CryptAcquireContextW(&hCryptProv, NULL, NULL,
- PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+ if (!CryptAcquireContextW(&hCryptProv, NULL, NULL,
+ PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
goto error;
return 0;
@@ -75,8 +75,8 @@ win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
while (size > 0)
{
- DWORD chunk = (DWORD)Py_MIN(size, PY_DWORD_MAX);
- if (!CryptGenRandom(hCryptProv, chunk, buffer))
+ DWORD chunk = (DWORD)Py_MIN(size, PY_DWORD_MAX);
+ if (!CryptGenRandom(hCryptProv, chunk, buffer))
{
/* CryptGenRandom() failed */
if (raise) {
@@ -173,7 +173,7 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
}
/* getrandom(GRND_NONBLOCK) fails with EAGAIN if the system urandom
- is not initialized yet. For _PyRandom_Init(), we ignore the
+ is not initialized yet. For _PyRandom_Init(), we ignore the
error and fall back on reading /dev/urandom which never blocks,
even if the system urandom is not initialized yet:
see the PEP 524. */
@@ -218,17 +218,17 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
error.
getentropy() is retried if it failed with EINTR: interrupted by a signal. */
-
-#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)
-static int
-py_getentropy(char *buffer, Py_ssize_t size, int raise)
- __attribute__((availability(macos,introduced=10.12)))
- __attribute__((availability(ios,introduced=10.0)))
- __attribute__((availability(tvos,introduced=10.0)))
- __attribute__((availability(watchos,introduced=3.0)));
-#endif
-
+
+#if defined(__APPLE__) && defined(__has_attribute) && __has_attribute(availability)
static int
+py_getentropy(char *buffer, Py_ssize_t size, int raise)
+ __attribute__((availability(macos,introduced=10.12)))
+ __attribute__((availability(ios,introduced=10.0)))
+ __attribute__((availability(tvos,introduced=10.0)))
+ __attribute__((availability(watchos,introduced=3.0)));
+#endif
+
+static int
py_getentropy(char *buffer, Py_ssize_t size, int raise)
{
/* Is getentropy() supported by the running kernel? Set to 0 if
@@ -518,21 +518,21 @@ pyurandom(void *buffer, Py_ssize_t size, int blocking, int raise)
#else
#if defined(PY_GETRANDOM) || defined(PY_GETENTROPY)
- if (HAVE_GETENTRYPY_GETRANDOM_RUNTIME) {
+ if (HAVE_GETENTRYPY_GETRANDOM_RUNTIME) {
#ifdef PY_GETRANDOM
- res = py_getrandom(buffer, size, blocking, raise);
+ res = py_getrandom(buffer, size, blocking, raise);
#else
- res = py_getentropy(buffer, size, raise);
+ res = py_getentropy(buffer, size, raise);
#endif
- if (res < 0) {
- return -1;
- }
- if (res == 1) {
- return 0;
- }
- /* getrandom() or getentropy() function is not available: failed with
- ENOSYS or EPERM. Fall back on reading from /dev/urandom. */
- } /* end of availability block */
+ if (res < 0) {
+ return -1;
+ }
+ if (res == 1) {
+ return 0;
+ }
+ /* getrandom() or getentropy() function is not available: failed with
+ ENOSYS or EPERM. Fall back on reading from /dev/urandom. */
+ } /* end of availability block */
#endif
return dev_urandom(buffer, size, raise);
@@ -569,14 +569,14 @@ _PyOS_URandomNonblock(void *buffer, Py_ssize_t size)
}
-PyStatus
-_Py_HashRandomization_Init(const PyConfig *config)
+PyStatus
+_Py_HashRandomization_Init(const PyConfig *config)
{
void *secret = &_Py_HashSecret;
Py_ssize_t secret_size = sizeof(_Py_HashSecret_t);
if (_Py_HashSecret_Initialized) {
- return _PyStatus_OK();
+ return _PyStatus_OK();
}
_Py_HashSecret_Initialized = 1;
@@ -601,11 +601,11 @@ _Py_HashRandomization_Init(const PyConfig *config)
pyurandom() is non-blocking mode (blocking=0): see the PEP 524. */
res = pyurandom(secret, secret_size, 0, 0);
if (res < 0) {
- return _PyStatus_ERR("failed to get random numbers "
- "to initialize Python");
+ return _PyStatus_ERR("failed to get random numbers "
+ "to initialize Python");
}
}
- return _PyStatus_OK();
+ return _PyStatus_OK();
}