From 9f6d7b53470f19410aaf9cbeca773cc2f582a546 Mon Sep 17 00:00:00 2001 From: Glyph Date: Sat, 27 Jun 2015 19:06:17 -0700 Subject: do the hokey pokey you put the functions in, you take the functions out, you make the linter work, and you shake it all about --- .../hazmat/bindings/openssl/binding.py | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/bindings/openssl/binding.py b/src/cryptography/hazmat/bindings/openssl/binding.py index aa072b4c..7943962f 100644 --- a/src/cryptography/hazmat/bindings/openssl/binding.py +++ b/src/cryptography/hazmat/bindings/openssl/binding.py @@ -10,6 +10,19 @@ import threading from cryptography.hazmat.bindings._openssl import ffi, lib +@ffi.callback("int (*)(unsigned char *, int)", error=-1) +def _osrandom_rand_bytes(buf, size): + signed = ffi.cast("char *", buf) + result = os.urandom(size) + signed[0:size] = result + return 1 + + +@ffi.callback("int (*)(void)") +def _osrandom_rand_status(): + return 1 + + class Binding(object): """ OpenSSL API wrapper. @@ -29,19 +42,6 @@ class Binding(object): def __init__(self): self._ensure_ffi_initialized() - @ffi.callback("int (*)(unsigned char *, int)", error=-1) - @staticmethod - def _osrandom_rand_bytes(buf, size): - signed = ffi.cast("char *", buf) - result = os.urandom(size) - signed[0:size] = result - return 1 - - @ffi.callback("int (*)(void)") - @staticmethod - def _osrandom_rand_status(): - return 1 - _osrandom_method = ffi.new( "RAND_METHOD *", dict(bytes=_osrandom_rand_bytes, pseudorand=_osrandom_rand_bytes, -- cgit v1.2.3