Coherence
Search…
⌃K

DSA

In order to understand hex and type parameters read Hash

DSA

spec
Description: Public-key cryptosystem
Problem: Discrete logarithm problem
Uses: Digital signatures
  • It only supports "type":"string"

How to ???

import requests
import json
import os,binascii
def sending(message):
url = 'http://127.0.0.1:6613/'
response = requests.post(url, data=message)
print response.content
return response.content
def dsa(data_js, bits):
req=json.loads(data_js)
req["length"]=bits
print "Send gen parameters : \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ=json.loads(data_js_n)
print "Recived dsa gen: \n"+(json.dumps(answ)) +"\n\n\n"
json_s=json_v='{ "version": 1 , "algorithm":"DSA", "type":"string","plaintext": "Hello world!", "hex":0,"privkey": "" ,"operation":"sign"}'
req=json.loads(json_s)
req["privkey"]=answ["privkey"]
print "Send sign : \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ_1=json.loads(data_js_n)
print "Recived sign done: \n"+(json.dumps(answ_1)) +"\n\n\n"
json_v='{ "version": 1 , "algorithm":"DSA", "type":"string","plaintext": "Hello world!", "hex":0,"pubkey": "" ,"sign":"","operation":"verify"}'
req=json.loads(json_v)
req["pubkey"]=answ["pubkey"]
req["sign"]=answ_1["sign"]
print "Send verify : \n " + json.dumps(req) +"\n"
data_js_n=sending(json.dumps(req))
answ_2=json.loads(data_js_n)
print "Recived verify done: \n"+(json.dumps(answ_2)) +"\n\n\n"
dsa_gen='{ "version": 1 , "algorithm":"DSA", "operation":"gen", "length": 0 }'
dsa(dsa_gen,1024)
In this example we generate a DSA key (1024 bits), we sign "Hello world!" and validate it.
Json to generate
{"operation": "gen", "version": 1, "length": INT, "algorithm": "DSA"}
  • Length can be 1024, 2048 and 3072
Json to sign string
{"algorithm": "DSA", "plaintext": "your string", "hex": BOOL, "version": 1, "operation": "sign", "type": "string", "privkey": "your private key"}
Json to validate string
{"algorithm": "DSA", "plaintext": "Hello world", "pubkey": "your hex pubkey", "hex": 0, "sign": "your hex signature", "version": 1, "operation": "verify", "type": "string"}
Last modified 1yr ago