#!/usr/bin/env python

from cgitools import *
import cgi

s = ''
otp_str = os.getenv('QUERY_STRING')
if otp_str: 
	otp_str = unescape(otp_str)
	ks = getRSAkeys()
	if ks:
		e_pub, e_priv, n = ks
		otp_str = rsaStr(otp_str, e_priv, n, True, 8, True)
		s = otpStr(getSecStr(n=2, hex_str=True), otp_str)
if not s: s = getSecStr(n=2, hex_str=True)

print "Content-type:text/xml\n\n"
print '<data>%s</data>' % escape(s)

