示例#1
0
	tmp.close()

	invoice_cp = ConfigParser()
	invoice_cp.read(tools.TMP_FILE)
	os.remove(tools.TMP_FILE)
	tools.check_config(invoice_cp, tools.STRCT_INVOICE)
	return invoice_cp

if __name__ == "__main__":
	try:
		real_drawer = sys.argv[1]
	except IndexError:
		print("You must give a customer name.", file=sys.stderr)
		exit(1)
	try:
		signed_inv = tools.read_stdin()
	except ParsingError:
		print(tool.SELLER_SIGN_ERROR, file=sys.stderr)
		exit(1)

	invoice = check_invoice(signed_inv)

	drawer = invoice[tools.SCT_I_INVOICE][tools.OPT_I_BUYER]
	total = invoice[tools.SCT_I_INVOICE][tools.OPT_I_TOTAL]
	payee = invoice[tools.SCT_I_INVOICE][tools.OPT_I_SELLER]
	transac_id = invoice[tools.SCT_I_INVOICE][tools.OPT_I_TRANS_ID]

	if drawer != real_drawer:
		print(NOT_FOR_ME, file=sys.stderr)
		exit(1)
示例#2
0
	seller_puk_sing_fname = os.path.join(tools.DIR_BANK,
										 tools.DIR_SELLER,
										 tools.FILE_PUB_SIGN)

	seller_puk = tools.decode_public_key(seller_puk_sing_fname,
										 bank_prk_fname,
										 tools.ROLE_BANK)

	seller_puk = RSA(int(seller_puk[tools.SCT_K_KEY][tools.OPT_K_N]),
					 e=int(seller_puk[tools.SCT_K_KEY][tools.OPT_K_E]))

	# Read the seller's signature from stdin and retreive the cheque's
	# signature generated by the drawee
	try:
		seller_sign = tools.read_stdin()
	except ParsingError:
		print(tools.SELLER_SIGN_ERROR, file=sys.stderr)
		exit(1)

	drawee_sign = decode_sign(seller_sign[tools.ROLE_SELLER][tools.OPT_S_SIGN],
							  seller_puk)

	# Decode the cheque
	drawee = drawee_sign.sections()[0]
	drawee_puk_sing_fname = os.path.join(tools.DIR_CUSTOMERS,
										 drawee,
										 tools.FILE_PUB_SIGN)

	drawee_puk = tools.decode_public_key(drawee_puk_sing_fname,
										 bank_prk_fname,