Skip to content

Commit

Permalink
Phase 1 of SHA256 support
Browse files Browse the repository at this point in the history
- new variable "digestalg" which defaults to "sha1", but allows "sha256"
  for those who want to sign using this
- Addresses #953
  • Loading branch information
PeterSurda committed Mar 2, 2017
1 parent 405a06c commit 53657db
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/highlevelcrypto.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from binascii import hexlify
from bmconfigparser import BMConfigParser
import pyelliptic
from pyelliptic import arithmetic as a, OpenSSL
def makeCryptor(privkey):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 53657db

Please sign in to comment.