aboutsummaryrefslogtreecommitdiffstats
path: root/src/_cffi_src/openssl
diff options
context:
space:
mode:
authorGlyph <glyph@twistedmatrix.com>2015-06-26 22:08:44 -0700
committerGlyph <glyph@twistedmatrix.com>2015-06-26 22:08:44 -0700
commitb51d246eb6ccaed7920ba6dd6a816f74d1158c16 (patch)
treeec8c1c20f55da6e19df03f83cf82eb17c705b54c /src/_cffi_src/openssl
parentb3d37a5d485bcd295d1933d638180e9cd5d23478 (diff)
downloadcryptography-b51d246eb6ccaed7920ba6dd6a816f74d1158c16.tar.gz
cryptography-b51d246eb6ccaed7920ba6dd6a816f74d1158c16.tar.bz2
cryptography-b51d246eb6ccaed7920ba6dd6a816f74d1158c16.zip
remove remaining vestiges, make adding twice work
Diffstat (limited to 'src/_cffi_src/openssl')
-rw-r--r--src/_cffi_src/openssl/osrandom_engine.py31
-rw-r--r--src/_cffi_src/openssl/src/osrandom_engine.c167
-rw-r--r--src/_cffi_src/openssl/src/osrandom_engine.h6
3 files changed, 0 insertions, 204 deletions
diff --git a/src/_cffi_src/openssl/osrandom_engine.py b/src/_cffi_src/openssl/osrandom_engine.py
deleted file mode 100644
index a8479b07..00000000
--- a/src/_cffi_src/openssl/osrandom_engine.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-from __future__ import absolute_import, division, print_function
-
-import os
-
-with open(os.path.join(
- os.path.dirname(__file__), "src/osrandom_engine.h"
-)) as f:
- INCLUDES = f.read()
-
-TYPES = """
-static const char *const Cryptography_osrandom_engine_name;
-static const char *const Cryptography_osrandom_engine_id;
-"""
-
-FUNCTIONS = """
-int Cryptography_add_osrandom_engine(void);
-"""
-
-MACROS = """
-"""
-
-with open(os.path.join(
- os.path.dirname(__file__), "src/osrandom_engine.c"
-)) as f:
- CUSTOMIZATIONS = f.read()
-
-CONDITIONAL_NAMES = {}
diff --git a/src/_cffi_src/openssl/src/osrandom_engine.c b/src/_cffi_src/openssl/src/osrandom_engine.c
deleted file mode 100644
index 27894712..00000000
--- a/src/_cffi_src/openssl/src/osrandom_engine.c
+++ /dev/null
@@ -1,167 +0,0 @@
-static const char *Cryptography_osrandom_engine_id = "osrandom";
-static const char *Cryptography_osrandom_engine_name = "osrandom_engine";
-
-#if defined(_WIN32)
-static HCRYPTPROV hCryptProv = 0;
-
-static int osrandom_init(ENGINE *e) {
- if (hCryptProv > 0) {
- return 1;
- }
- if (CryptAcquireContext(&hCryptProv, NULL, NULL,
- PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static int osrandom_rand_bytes(unsigned char *buffer, int size) {
- if (hCryptProv == 0) {
- return 0;
- }
-
- if (!CryptGenRandom(hCryptProv, (DWORD)size, buffer)) {
- ERR_put_error(
- ERR_LIB_RAND, 0, ERR_R_RAND_LIB, "osrandom_engine.py", 0
- );
- return 0;
- }
- return 1;
-}
-
-static int osrandom_finish(ENGINE *e) {
- if (CryptReleaseContext(hCryptProv, 0)) {
- hCryptProv = 0;
- return 1;
- } else {
- return 0;
- }
-}
-
-static int osrandom_rand_status(void) {
- if (hCryptProv == 0) {
- return 0;
- } else {
- return 1;
- }
-}
-#else
-static int urandom_fd = -1;
-
-static int osrandom_finish(ENGINE *e);
-
-static int osrandom_init(ENGINE *e) {
- if (urandom_fd > -1) {
- return 1;
- }
- urandom_fd = open("/dev/urandom", O_RDONLY);
- if (urandom_fd > -1) {
- int flags = fcntl(urandom_fd, F_GETFD);
- if (flags == -1) {
- osrandom_finish(e);
- return 0;
- } else if (fcntl(urandom_fd, F_SETFD, flags | FD_CLOEXEC) == -1) {
- osrandom_finish(e);
- return 0;
- }
- return 1;
- } else {
- return 0;
- }
-}
-
-static int osrandom_rand_bytes(unsigned char *buffer, int size) {
- ssize_t n;
- while (size > 0) {
- do {
- n = read(urandom_fd, buffer, (size_t)size);
- } while (n < 0 && errno == EINTR);
- if (n <= 0) {
- ERR_put_error(
- ERR_LIB_RAND, 0, ERR_R_RAND_LIB, "osrandom_engine.py", 0
- );
- return 0;
- }
- buffer += n;
- size -= n;
- }
- return 1;
-}
-
-static int osrandom_finish(ENGINE *e) {
- int n;
- do {
- n = close(urandom_fd);
- } while (n < 0 && errno == EINTR);
- urandom_fd = -1;
- if (n < 0) {
- return 0;
- } else {
- return 1;
- }
-}
-
-static int osrandom_rand_status(void) {
- if (urandom_fd == -1) {
- return 0;
- } else {
- return 1;
- }
-}
-#endif
-
-/* This replicates the behavior of the OpenSSL FIPS RNG, which returns a
- -1 in the event that there is an error when calling RAND_pseudo_bytes. */
-static int osrandom_pseudo_rand_bytes(unsigned char *buffer, int size) {
- int res = osrandom_rand_bytes(buffer, size);
- if (res == 0) {
- return -1;
- } else {
- return res;
- }
-}
-
-static RAND_METHOD osrandom_rand = {
- NULL,
- osrandom_rand_bytes,
- NULL,
- NULL,
- osrandom_pseudo_rand_bytes,
- osrandom_rand_status,
-};
-
-/* Returns 1 if successfully added, 2 if engine has previously been added,
- and 0 for error. */
-int Cryptography_add_osrandom_engine(void) {
- ENGINE *e;
- e = ENGINE_by_id(Cryptography_osrandom_engine_id);
- if (e != NULL) {
- ENGINE_free(e);
- return 2;
- } else {
- ERR_clear_error();
- }
-
- e = ENGINE_new();
- if (e == NULL) {
- return 0;
- }
- if(!ENGINE_set_id(e, Cryptography_osrandom_engine_id) ||
- !ENGINE_set_name(e, Cryptography_osrandom_engine_name) ||
- !ENGINE_set_RAND(e, &osrandom_rand) ||
- !ENGINE_set_init_function(e, osrandom_init) ||
- !ENGINE_set_finish_function(e, osrandom_finish)) {
- ENGINE_free(e);
- return 0;
- }
- if (!ENGINE_add(e)) {
- ENGINE_free(e);
- return 0;
- }
- if (!ENGINE_free(e)) {
- return 0;
- }
-
- return 1;
-}
diff --git a/src/_cffi_src/openssl/src/osrandom_engine.h b/src/_cffi_src/openssl/src/osrandom_engine.h
deleted file mode 100644
index 11a3159e..00000000
--- a/src/_cffi_src/openssl/src/osrandom_engine.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifdef _WIN32
-#include <Wincrypt.h>
-#else
-#include <fcntl.h>
-#include <unistd.h>
-#endif
1 #define ACPI_NEXT_OP_UPWARD 2 #define ACPI_WALK_NON_METHOD 0 #define ACPI_WALK_METHOD 1 #define ACPI_WALK_METHOD_RESTART 2 #define ACPI_WALK_CONST_REQUIRED 3 #define ACPI_WALK_CONST_OPTIONAL 4 struct acpi_walk_state { u8 data_type; /* To differentiate various internal objs MUST BE FIRST!*/\ acpi_owner_id owner_id; /* Owner of objects created during the walk */ u8 last_predicate; /* Result of last predicate */ u8 current_result; /* */ u8 next_op_info; /* Info about next_op */ u8 num_operands; /* Stack pointer for Operands[] array */ u8 return_used; u8 walk_type; u16 opcode; /* Current AML opcode */ u8 scope_depth; u8 reserved1; u32 arg_count; /* push for fixed or var args */ u32 aml_offset; u32 arg_types; u32 method_breakpoint; /* For single stepping */ u32 user_breakpoint; /* User AML breakpoint */ u32 parse_flags; u32 prev_arg_types; u8 *aml_last_while; struct acpi_namespace_node arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ union acpi_operand_object **caller_return_desc; union acpi_generic_state *control_state; /* List of control states (nested IFs) */ struct acpi_namespace_node *deferred_node; /* Used when executing deferred opcodes */ struct acpi_namespace_node local_variables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ struct acpi_namespace_node *method_call_node; /* Called method Node*/ union acpi_parse_object *method_call_op; /* method_call Op if running a method */ union acpi_operand_object *method_desc; /* Method descriptor if running a method */ struct acpi_namespace_node *method_node; /* Method node if running a method. */ union acpi_parse_object *op; /* Current parser op */ union acpi_operand_object *operands[ACPI_OBJ_NUM_OPERANDS+1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ const struct acpi_opcode_info *op_info; /* Info on current opcode */ union acpi_parse_object *origin; /* Start of walk [Obsolete] */ union acpi_operand_object **params; struct acpi_parse_state parser_state; /* Current state of parser */ union acpi_operand_object *result_obj; union acpi_generic_state *results; /* Stack of accumulated results */ union acpi_operand_object *return_desc; /* Return object, if any */ union acpi_generic_state *scope_info; /* Stack of nested scopes */ union acpi_parse_object *prev_op; /* Last op that was processed */ union acpi_parse_object *next_op; /* next op to be processed */ acpi_parse_downwards descending_callback; acpi_parse_upwards ascending_callback; struct acpi_thread_state *thread; struct acpi_walk_state *next; /* Next walk_state in list */ }; /* Info used by acpi_ps_init_objects */ struct acpi_init_walk_info { u16 method_count; u16 device_count; u16 op_region_count; u16 field_count; u16 buffer_count; u16 package_count; u16 op_region_init; u16 field_init; u16 buffer_init; u16 package_init; u16 object_count; struct acpi_table_desc *table_desc; }; /* Info used by acpi_ns_initialize_devices */ struct acpi_device_walk_info { u16 device_count; u16 num_STA; u16 num_INI; struct acpi_table_desc *table_desc; }; /* TBD: [Restructure] Merge with struct above */ struct acpi_walk_info { u32 debug_level; u32 owner_id; u8 display_type; }; /* Display Types */ #define ACPI_DISPLAY_SUMMARY 0 #define ACPI_DISPLAY_OBJECTS 1 struct acpi_get_devices_info { acpi_walk_callback user_function; void *context; char *hid; }; union acpi_aml_operands { union acpi_operand_object *operands[7]; struct { struct acpi_object_integer *type; struct acpi_object_integer *code; struct acpi_object_integer *argument; } fatal; struct { union acpi_operand_object *source; struct acpi_object_integer *index; union acpi_operand_object *target; } index; struct { union acpi_operand_object *source; struct acpi_object_integer *index; struct acpi_object_integer *length; union acpi_operand_object *target; } mid; }; #endif