Skip to content
Liesware edited this page Jan 29, 2019 · 4 revisions

Digital signatures video

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 socket
import json
import os,binascii

def sending(message):
	ip = '127.0.0.1'
	port = 6613
	BUFFER_SIZE = 65536
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.connect((ip, port))
	s.send(message)
	data = s.recv(BUFFER_SIZE)
	s.close()
	return data

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"}
You can’t perform that action at this time.