def sign(): if request.method == 'POST': key = request.form['key'].strip() if 'upload' in request.query_string: file = request.files['file'] return render_template('sign.html', xml=file.read(), signed='', key=key, is_valid=True) key = request.form['key'].strip() xml = request.form['xml'].strip() signed = request.form['signed'].strip() is_valid = False if 'verify' in request.query_string: is_valid = jbelt.verify(signed) elif key and xml: signed = jbelt.sign(xml, keys=jbelt.calc_keys(base64.b64decode(key))) is_valid = jbelt.verify(signed) return render_template('sign.html', xml=xml, signed=signed, key=key, is_valid=is_valid) else: return render_template('sign.html', xml='', signed='', key=base64.b64encode( str(jbelt.genKeys()['priv'])))
def sign(): if request.method == "POST": key = request.form["key"].strip() if "upload" in request.query_string: file = request.files["file"] return render_template("sign.html", xml=file.read(), signed="", key=key, is_valid=True) key = request.form["key"].strip() xml = request.form["xml"].strip() signed = request.form["signed"].strip() is_valid = False if "verify" in request.query_string: is_valid = jbelt.verify(signed) elif key and xml: signed = jbelt.sign(xml, keys=jbelt.calc_keys(base64.b64decode(key))) is_valid = jbelt.verify(signed) return render_template("sign.html", xml=xml, signed=signed, key=key, is_valid=is_valid) else: return render_template("sign.html", xml="", signed="", key=base64.b64encode(str(jbelt.genKeys()["priv"])))
def test_key_calc(self): keys = jbelt.genKeys() self.assertEqual(jbelt.calc_keys(keys['priv']).getPublic().getBytes(), keys['pub'])