mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 08:08:00 +02:00
use C language hashcash program to generate cash from client
This commit is contained in:
@@ -2,15 +2,11 @@
|
|||||||
|
|
||||||
from chocolate_protocol_pb2 import chocolatemessage
|
from chocolate_protocol_pb2 import chocolatemessage
|
||||||
import M2Crypto
|
import M2Crypto
|
||||||
import urllib2, os, sys, time, random, sys, hashlib, hashcash
|
import urllib2, os, sys, time, random, sys, hashlib
|
||||||
# It is OK to use the upstream M2Crypto here instead of our modified
|
# It is OK to use the upstream M2Crypto here instead of our modified
|
||||||
# version.
|
# version.
|
||||||
# hashcash.py here should be a symlink to ../server-ca/hashcash.py
|
|
||||||
|
|
||||||
difficulty = 20
|
difficulty = 23 # bits of hashcash to generate
|
||||||
# TODO: unfortunately, the C hashcash implementation seems to be about
|
|
||||||
# 2^6 times faster than the native Python implementation, so
|
|
||||||
# calibrating the difficulty is a bit of a problem.
|
|
||||||
|
|
||||||
def sha256(m):
|
def sha256(m):
|
||||||
return hashlib.sha256(m).hexdigest()
|
return hashlib.sha256(m).hexdigest()
|
||||||
@@ -66,6 +62,8 @@ def make_request(m, csr):
|
|||||||
m.request.timestamp = int(time.time())
|
m.request.timestamp = int(time.time())
|
||||||
m.request.csr = csr
|
m.request.csr = csr
|
||||||
m.request.clientpuzzle = hashcash.mint(server, difficulty)
|
m.request.clientpuzzle = hashcash.mint(server, difficulty)
|
||||||
|
hashcash_command = "hashcash -P -m -b %d -r %s" % (difficulty, server)
|
||||||
|
m.request.clientpuzzle = subprocess.check_output(hashcash_command.split(), shell=False).rstrip()
|
||||||
|
|
||||||
def sign(key, m):
|
def sign(key, m):
|
||||||
m.request.sig = rsa_sign(key, ("(%d) (%s) (%s)" % (m.request.timestamp, m.request.recipient, m.request.csr)))
|
m.request.sig = rsa_sign(key, ("(%d) (%s) (%s)" % (m.request.timestamp, m.request.recipient, m.request.csr)))
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../server-ca/hashcash.py
|
|
||||||
@@ -11,7 +11,7 @@ from google.protobuf.message import DecodeError
|
|||||||
MaximumSessionAge = 100 # seconds, to demonstrate session timeout
|
MaximumSessionAge = 100 # seconds, to demonstrate session timeout
|
||||||
MaximumChallengeAge = 600 # to demonstrate challenge timeout
|
MaximumChallengeAge = 600 # to demonstrate challenge timeout
|
||||||
|
|
||||||
difficulty = 20 # bits of hashcash required with new requests
|
difficulty = 23 # bits of hashcash required with new requests
|
||||||
|
|
||||||
try:
|
try:
|
||||||
chocolate_server_name = open("SERVERNAME").read().rstrip()
|
chocolate_server_name = open("SERVERNAME").read().rstrip()
|
||||||
|
|||||||
Reference in New Issue
Block a user