Phase 1 of SHA256 support
- new variable "digestalg" which defaults to "sha1", but allows "sha256" for those who want to sign using this - Addresses #953
This commit is contained in:
parent
405a06c08a
commit
53657dba47
|
@ -1,4 +1,5 @@
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
|
from bmconfigparser import BMConfigParser
|
||||||
import pyelliptic
|
import pyelliptic
|
||||||
from pyelliptic import arithmetic as a, OpenSSL
|
from pyelliptic import arithmetic as a, OpenSSL
|
||||||
def makeCryptor(privkey):
|
def makeCryptor(privkey):
|
||||||
|
@ -35,8 +36,17 @@ def sign(msg,hexPrivkey):
|
||||||
# upgrade PyBitmessage gracefully.
|
# upgrade PyBitmessage gracefully.
|
||||||
# https://github.com/yann2192/pyelliptic/pull/33
|
# https://github.com/yann2192/pyelliptic/pull/33
|
||||||
# More discussion: https://github.com/yann2192/pyelliptic/issues/32
|
# More discussion: https://github.com/yann2192/pyelliptic/issues/32
|
||||||
return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.digest_ecdsa_sha1) # SHA1
|
digestAlg = BMConfigParser().safeGet('bitmessagesettings', 'digestalg', 'sha1')
|
||||||
#return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.EVP_sha256) # SHA256. We should switch to this eventually.
|
if digestAlg == "sha1":
|
||||||
|
# SHA1, this will eventually be deprecated
|
||||||
|
print "sha1"
|
||||||
|
return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.digest_ecdsa_sha1)
|
||||||
|
elif digestAlg == "sha256":
|
||||||
|
# SHA256. Eventually this will become the default
|
||||||
|
print "sha256"
|
||||||
|
return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.EVP_sha256)
|
||||||
|
else:
|
||||||
|
raise ValueError("Unknown digest algorithm %s" % (digestAlgo))
|
||||||
# Verifies with hex public key
|
# Verifies with hex public key
|
||||||
def verify(msg,sig,hexPubkey):
|
def verify(msg,sig,hexPubkey):
|
||||||
# As mentioned above, we must upgrade gracefully to use SHA256. So
|
# As mentioned above, we must upgrade gracefully to use SHA256. So
|
||||||
|
|
Reference in New Issue
Block a user