New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surya/core 9290/py triplesec v4 #19
Changes from 6 commits
6e71636
8469613
d5aadd9
6cbafdd
4a1469f
39abe26
e45478e
67dd846
ae42431
810b889
04426fe
125b493
31649d0
fa11c57
582e3c8
8b81e46
6e5555d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pycryptodome | ||
scrypt | ||
six | ||
pysha3 | ||
twofish | ||
salsa20 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[tox] | ||
envlist = py26,py27,py33 | ||
envlist = py27,py36 | ||
|
||
[testenv] | ||
deps = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import sys | ||
from six.moves import zip | ||
from collections import namedtuple | ||
import Crypto.Hash.keccak | ||
if sys.version_info > (3, 2): | ||
if 'sha3_512' not in hashlib.algorithms_available: | ||
import sha3 | ||
|
@@ -82,6 +83,30 @@ def copy(self): | |
return copy | ||
sha3_512 = lambda s=b'': new_sha3_512(s) | ||
|
||
class new_keccak(object): | ||
block_size = 72 | ||
digest_size = 64 | ||
|
||
def __init__(self, string=b''): | ||
self._obj = Crypto.Hash.keccak.new(digest_bits=512) | ||
self.input = b"" | ||
self.input += string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, you mean this.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it can be called with some of the MAC key data in the HMAC construction, and therefore might be passing a MAC key around. That ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I usually assume that anything in the processes' memory is safe. But I saw a lot of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was an extra precaution and likely not ineffective since with interpreted languages, you never really know what happens to memory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That makes sense. I got rid of this custom stuff entirely. And I finally figured out what caused the sudden change: pysha3 upgraded to 1.0 and changed the default sha3 function, but we weren't version locked so tests started failing (which I just now did). Still using the library since it provides keccak which the python stdlib doesn't. |
||
self._obj.update(string) | ||
|
||
def digest(self): | ||
return self._obj.digest() | ||
|
||
def hexdigest(self): | ||
return self._obj.hexdigest() | ||
|
||
def update(self, string): | ||
self.input += string | ||
return self._obj.update(string) | ||
|
||
def copy(self): | ||
return new_keccak(self.input) | ||
keccak = lambda s=b'': new_keccak(s) | ||
|
||
def win32_utf8_argv(): | ||
"""Uses shell32.GetCommandLineArgvW to get sys.argv as a list of UTF-8 | ||
strings. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is storing this okay (used in
copy
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Holding onto an empty string?