diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-18 15:16:29 -0800 | 
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-11-18 15:16:29 -0800 | 
| commit | 04b8330d0a719b7f312207e7098c44f55a25fe39 (patch) | |
| tree | 2a0f6a261eec36b74cf512f64ad023e794c74d46 /cryptography | |
| parent | 41b148725fd688016098ecab51956b08fb890439 (diff) | |
| download | cryptography-04b8330d0a719b7f312207e7098c44f55a25fe39.tar.gz cryptography-04b8330d0a719b7f312207e7098c44f55a25fe39.tar.bz2 cryptography-04b8330d0a719b7f312207e7098c44f55a25fe39.zip | |
Use an instruction that is more likely to be constant time on a modern x86 CPU
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/primitives/padding.py | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/cryptography/hazmat/primitives/padding.py b/cryptography/hazmat/primitives/padding.py index f1c64f4d..bc7a768d 100644 --- a/cryptography/hazmat/primitives/padding.py +++ b/cryptography/hazmat/primitives/padding.py @@ -28,7 +28,7 @@ _lib = _ffi.verify("""  /* 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) { -    return -(a >> (sizeof(uint8_t) * 8 - 1)); +    return (1 - (a >> (sizeof(uint8_t) * 8 - 1))) - 1;  }  /* This returns 0xFF if a < b else 0x00, but does so in a constant time | 
