Skip to content

Commit

Permalink
validate ECDSA input length
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Kraitsberg committed Sep 11, 2019
1 parent 094c214 commit 6cf8597
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/mpc_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,20 @@ def run_generate(cryptoType, size):

def run_sign(inShare, cryptoType):
print(cryptoType + " signing...")
if not args.data_file:
sys.exit("Input data missing")
with open(args.data_file, "rb") as f:
inData = f.read()

if cryptoType == 'ECDSA':
if len(inData) > 32:
sys.exit("Input too long. Data should be hashed before ECDSA signing.")
obj = mpc_crypto.Ecdsa(peer, inShare)
elif cryptoType == 'EDDSA':
obj = mpc_crypto.Eddsa(peer, inShare)
else:
sys.exit("Sign not supported for " + cryptoType)

if not args.data_file:
sys.exit("Input data missing")
with open(args.data_file, "rb") as f:
inData = f.read()
with obj:
obj.initSign(inData)
exec_mpc_exchange(obj)
Expand Down

0 comments on commit 6cf8597

Please sign in to comment.