diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-18 18:15:17 -0800 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-12-18 18:15:17 -0800 |
commit | 552b0424843c7c3be07bb6dfdf6e60f7cd5a760a (patch) | |
tree | f0ddd89cc60a6cba5d9252f989b3ebcb621210ba | |
parent | 740e43079dbc62ca7f5918284e90be386133f21b (diff) | |
parent | 41e604dceeb0290b43a348c10789e65af0cc60f7 (diff) | |
download | cryptography-552b0424843c7c3be07bb6dfdf6e60f7cd5a760a.tar.gz cryptography-552b0424843c7c3be07bb6dfdf6e60f7cd5a760a.tar.bz2 cryptography-552b0424843c7c3be07bb6dfdf6e60f7cd5a760a.zip |
Merge pull request #317 from alex/no-stdbool
Removed usage of stdbool for Windows which doesn't have C99
-rw-r--r-- | cryptography/hazmat/primitives/constant_time.py | 11 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/padding.py | 7 |
2 files changed, 8 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..e517dee0 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,8 @@ 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; |