aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-18 14:54:05 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-18 14:54:05 -0800
commitccfa8894432831126095f4d7a3691c2add25d873 (patch)
tree79dd35870bbca0e290fc671c1fd3793760f69c30
parent740e43079dbc62ca7f5918284e90be386133f21b (diff)
downloadcryptography-ccfa8894432831126095f4d7a3691c2add25d873.tar.gz
cryptography-ccfa8894432831126095f4d7a3691c2add25d873.tar.bz2
cryptography-ccfa8894432831126095f4d7a3691c2add25d873.zip
Removed usage of stdbool for Windows which doesn't have C99
-rw-r--r--cryptography/hazmat/primitives/constant_time.py11
-rw-r--r--cryptography/hazmat/primitives/padding.py6
2 files changed, 7 insertions, 10 deletions
diff --git a/cryptography/hazmat/primitives/constant_time.py b/cryptography/hazmat/primitives/constant_time.py
index a8351504..6502803e 100644
--- a/cryptography/hazmat/primitives/constant_time.py
+++ b/cryptography/hazmat/primitives/constant_time.py
@@ -20,17 +20,16 @@ import six
_ffi = cffi.FFI()
_ffi.cdef("""
-bool Cryptography_constant_time_bytes_eq(uint8_t *, size_t, uint8_t *, size_t);
+uint8_t Cryptography_constant_time_bytes_eq(uint8_t *, size_t, uint8_t *,
+ size_t);
""")
_lib = _ffi.verify("""
-#include <stdbool.h>
-
-bool Cryptography_constant_time_bytes_eq(uint8_t *a, size_t len_a, uint8_t *b,
- size_t len_b) {
+uint8_t Cryptography_constant_time_bytes_eq(uint8_t *a, size_t len_a,
+ uint8_t *b, size_t len_b) {
size_t i = 0;
uint8_t mismatch = 0;
if (len_a != len_b) {
- return false;
+ return 0;
}
for (i = 0; i < len_a; i++) {
mismatch |= a[i] ^ b[i];
diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py
index cfa90db9..97298277 100644
--- a/cryptography/hazmat/primitives/padding.py
+++ b/cryptography/hazmat/primitives/padding.py
@@ -21,11 +21,9 @@ from cryptography.hazmat.primitives import interfaces
_ffi = cffi.FFI()
_ffi.cdef("""
-bool Cryptography_check_pkcs7_padding(const uint8_t *, uint8_t);
+uint8_t Cryptography_check_pkcs7_padding(const uint8_t *, uint8_t);
""")
_lib = _ffi.verify("""
-#include <stdbool.h>
-
/* Returns the value of the input with the most-significant-bit copied to all
of the bits. */
static uint8_t Cryptography_DUPLICATE_MSB_TO_ALL(uint8_t a) {
@@ -39,7 +37,7 @@ static uint8_t Cryptography_constant_time_lt(uint8_t a, uint8_t b) {
return Cryptography_DUPLICATE_MSB_TO_ALL(a);
}
-bool Cryptography_check_pkcs7_padding(const uint8_t *data, uint8_t block_len) {
+uint8_t Cryptography_check_pkcs7_padding(const uint8_t *data, uint8_t block_len) {
uint8_t i;
uint8_t pad_size = data[block_len - 1];
uint8_t mismatch = 0;