Code Monkey home page Code Monkey logo

streql's Introduction

Constant-time string comparison

https://travis-ci.org/PeterScott/streql.png

Sometimes you need to test strings for equality with an algorithm whose timing depends only on the length of the strings, and not on the contents of the strings themselves. If one of those strings is of constant width -- an HMAC, for example -- then it becomes a constant-time operation. This can be used to prevent some timing side-channel attacks, such as the critical vulnerability found in KeyCzar back in 2009.

This module offers a single function, equals(x, y), which takes two strings x and y and returns True if they are equal, and False if they are not. The time this function takes does not depend on what specific bytes are in these strings. Unicode strings are encoded as UTF-8 before being compared; it is recommended that you only use this on byte strings (str in Python 2, bytes in Python 3).

This works with Python 2 and 3, and PyPy. The license is Apache 2.0.

streql's People

Contributors

peterscott avatar

Stargazers

Victor Gavro avatar Artur Juraszek avatar Jamie Kuppens avatar Ayelet avatar Razzi Abuissa avatar Charlie avatar James Mishra avatar Ionel Cristian Mărieș avatar Joël Perras avatar Alicia Boya García avatar David Vincelli avatar  avatar Craig Patten avatar Demian Brecht avatar

Watchers

 avatar James Cloos avatar Dogestradamus avatar  avatar

streql's Issues

tests.py not included in PyPI

Hi,

The tarball which you provide on PyPI does not ship with tests.py, yet setup.py still references this file. Would you be able to either add tests.py, or remove the reference in setup.py?

Thanks for considering,

appleorange1

Compile Error on Win 7 x32 bit, Python 2.7

At first I was getting the "unable to find vcvarsall.bat" error, and after fixing that, I tried pip installing streql and got this error:

PS C:\Users\Lee> pip install streql
Downloading/unpacking streql
Downloading streql-3.0.2.tar.gz
Running setup.py (path:c:\users\lee\appdata\local\temp\pip_build_Lee\streql\setup.py) egg_info for package streql

Installing collected packages: streql
Running setup.py install for streql
building 'streql' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27
include -IC:\Python27\PC /Tcstreql.c /Fobuild\temp.win32-2.7\Release\streql.obj
streql.c
streql.c(7) : error C2143: syntax error : missing ';' before 'type'
streql.c(8) : error C2065: 'i' : undeclared identifier
streql.c(8) : error C2065: 'i' : undeclared identifier
streql.c(8) : warning C4018: '<' : signed/unsigned mismatch
streql.c(8) : error C2065: 'i' : undeclared identifier
streql.c(8) : error C2065: 'result' : undeclared identifier
streql.c(8) : error C2065: 'i' : undeclared identifier
streql.c(8) : error C2065: 'i' : undeclared identifier
streql.c(9) : error C2065: 'result' : undeclared identifier
streql.c(16) : error C2143: syntax error : missing ';' before 'type'
streql.c(19) : error C2065: 'equal' : undeclared identifier
streql.c(27) : error C2061: syntax error : identifier 'streql_methods'
streql.c(27) : error C2059: syntax error : ';'
streql.c(27) : error C3409: empty attribute block is not allowed
streql.c(27) : error C2513: '/global/ ' : no variable declared before '='
streql.c(51) : error C2065: 'streql_methods' : undeclared identifier
streql.c(51) : warning C4047: 'function' : 'PyMethodDef *' differs in levels of indirection from 'int'
streql.c(51) : warning C4024: 'Py_InitModule4' : different types for formal and actual parameter 2
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;file='c:\users\lee\appdat
a\local\temp\pip_build_Lee\streql\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('
\r\n', '\n'), file, 'exec'))" install --record c:\users\lee\appdata\local\temp\pip-h9hneu-record\install-record.txt
--single-version-externally-managed --compile:
running install

running build

running build_ext

building 'streql' extension

creating build

creating build\temp.win32-2.7

creating build\temp.win32-2.7\Release

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\incl
ude -IC:\Python27\PC /Tcstreql.c /Fobuild\temp.win32-2.7\Release\streql.obj

streql.c

streql.c(7) : error C2143: syntax error : missing ';' before 'type'

streql.c(8) : error C2065: 'i' : undeclared identifier

streql.c(8) : error C2065: 'i' : undeclared identifier

streql.c(8) : warning C4018: '<' : signed/unsigned mismatch

streql.c(8) : error C2065: 'i' : undeclared identifier

streql.c(8) : error C2065: 'result' : undeclared identifier

streql.c(8) : error C2065: 'i' : undeclared identifier

streql.c(8) : error C2065: 'i' : undeclared identifier

streql.c(9) : error C2065: 'result' : undeclared identifier

streql.c(16) : error C2143: syntax error : missing ';' before 'type'

streql.c(19) : error C2065: 'equal' : undeclared identifier

streql.c(27) : error C2061: syntax error : identifier 'streql_methods'

streql.c(27) : error C2059: syntax error : ';'

streql.c(27) : error C3409: empty attribute block is not allowed

streql.c(27) : error C2513: '/global/ ' : no variable declared before '='

streql.c(51) : error C2065: 'streql_methods' : undeclared identifier

streql.c(51) : warning C4047: 'function' : 'PyMethodDef *' differs in levels of indirection from 'int'

streql.c(51) : warning C4024: 'Py_InitModule4' : different types for formal and actual parameter 2

error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.