1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-26 07:41:33 +03:00

use C language hashcash program to generate cash from client

This commit is contained in:
Seth Schoen
2012-07-16 19:25:27 -07:00
parent bc7b55d0d6
commit 1b88b67544
3 changed files with 5 additions and 8 deletions

View File

@@ -2,15 +2,11 @@
from chocolate_protocol_pb2 import chocolatemessage
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
# version.
# hashcash.py here should be a symlink to ../server-ca/hashcash.py
difficulty = 20
# 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.
difficulty = 23 # bits of hashcash to generate
def sha256(m):
return hashlib.sha256(m).hexdigest()
@@ -66,6 +62,8 @@ def make_request(m, csr):
m.request.timestamp = int(time.time())
m.request.csr = csr
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):
m.request.sig = rsa_sign(key, ("(%d) (%s) (%s)" % (m.request.timestamp, m.request.recipient, m.request.csr)))

View File

@@ -1 +0,0 @@
../server-ca/hashcash.py

View File

@@ -11,7 +11,7 @@ from google.protobuf.message import DecodeError
MaximumSessionAge = 100 # seconds, to demonstrate session 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:
chocolate_server_name = open("SERVERNAME").read().rstrip()