diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index 50f13cce..4a24fe20 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -1,4 +1,5 @@ from binascii import hexlify +from bmconfigparser import BMConfigParser import pyelliptic from pyelliptic import arithmetic as a, OpenSSL def makeCryptor(privkey): @@ -35,8 +36,17 @@ def sign(msg,hexPrivkey): # upgrade PyBitmessage gracefully. # https://github.com/yann2192/pyelliptic/pull/33 # More discussion: https://github.com/yann2192/pyelliptic/issues/32 - return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.digest_ecdsa_sha1) # SHA1 - #return makeCryptor(hexPrivkey).sign(msg, digest_alg=OpenSSL.EVP_sha256) # SHA256. We should switch to this eventually. + digestAlg = BMConfigParser().safeGet('bitmessagesettings', 'digestalg', 'sha1') + 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 def verify(msg,sig,hexPubkey): # As mentioned above, we must upgrade gracefully to use SHA256. So