def ct_seal(sfd): print "CTSEAL message: " myargs = { KEY_MYNICK: "frlfrl", KEY_BLOB: "this is a message to say yay!!!!", KEY_CHANNEL: "#prout" } acblob = ac_msg(ACMSG_TYPE_CRYPTO, ACMSG_SUBTYPE_CTSEAL, myargs) sfd.send(acblob) rcvblob = sfd.recv(4096) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_ctr = ac_pb2.acCipherTextMessageResponse() ac_ctr.ParseFromString(ac_msg_test.blob) print "CTR message type:" print ac_ctr.type print "CTR message bada:" print ac_ctr.bada print "CTR message error_code:" print ac_ctr.error_code print "CTR message blob:" print ac_ctr.blob return ac_ctr.blob
def ct_open(sfd): print "CTOPEN message: " myargs = { KEY_PEERNICK: "rlfrl", KEY_BLOB: DATA_BLOB, KEY_CHANNEL: "#prout" } acblob = ac_msg(ACMSG_TYPE_CRYPTO, ACMSG_SUBTYPE_CTOPEN, myargs) sfd.send(acblob) rcvblob = sfd.recv(4096) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_ctr = ac_pb2.acCipherTextMessageResponse() ac_ctr.ParseFromString(ac_msg_test.blob) print "CTR message type:" print ac_ctr.type print "CTR message bada:" print ac_ctr.bada print "CTR message error_code:" print ac_ctr.error_code print "CTR message blob:" print ac_ctr.blob return ac_ctr.blob
def pk_list(sfd): print "LIST RUNNING DAEMON PUBLIC KEYS" #myargs = { KEY_NICK:"frlfrl" } myargs = None acblob = ac_msg(ACMSG_TYPE_PK, ACMSG_SUBTYPE_PKLIST, myargs) sfd.send(acblob) rcvblob = sfd.recv(4096) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type if ac_msg_test.type == ac_pb2.ArseneCryptoMessage.AC_ERROR: print "Request Error!" print ac_msg_test.blob return 1 ac_pkr = ac_pb2.acPublicKeyMessageResponse() ac_pkr.ParseFromString(ac_msg_test.blob) print "PKR message type:" print ac_pkr.type print "PKR message bada:" print ac_pkr.bada print "PKR message error_code:" print ac_pkr.error_code print "PKR do we have public keys?!" print ac_pkr.public_keys print "HOW MANY PUB KEYS!?" print len(ac_pkr.public_keys) for t in ac_pkr.public_keys: print t.nick + ":" + t.pubkey + ":" + str(t.timestamp) + ":" + str( datetime.datetime.fromtimestamp(t.timestamp)) print binascii.hexlify(t.fp) return 0
def kx_recvkey(sfd): print "KXUNPACK message: " + DATA_BLOB myargs = { KEY_MYNICK: "frlfrl", KEY_PEERNICK: "yondaime", KEY_CHANNEL: "#prout", KEY_BLOB: DATA_BLOB } acblob = ac_msg(ACMSG_TYPE_KEX, ACMSG_SUBTYPE_KXUNPACK, myargs) sfd.send(acblob) rcvblob = sfd.recv(4096) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_kxr = ac_pb2.acKeyExchangeMessageResponse() ac_kxr.ParseFromString(ac_msg_test.blob) print "KXR message type:" print ac_kxr.type print "KXR message bada:" print ac_kxr.bada print "KXR message error_code:" print ac_kxr.error_code
def pk_addpubkey(sfd): print "ADD A PUBKEY" myargs = { KEY_NICK: "frlfrl", KEY_HOST: KEY_YAHOST_DATA, KEY_SERVER: KEY_SERVER_DATA, KEY_BLOB: "IpPlkHjaehHIva58t9UOk92x3HIa9mzG9wWzt8i/Tlpzpj/W64+iNiAAAP//3ukNnQ==" } acblob = ac_msg(ACMSG_TYPE_PK, ACMSG_SUBTYPE_PKADD, myargs) sfd.send(acblob) rcvblob = sfd.recv(2048) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_pkr = ac_pb2.acPublicKeyMessageResponse() ac_pkr.ParseFromString(ac_msg_test.blob) print "PKR message type:" print ac_pkr.type print "PKR message bada:" print ac_pkr.bada print "PKR message error_code:" print ac_pkr.error_code print "KEY FP:" print binascii.hexlify(ac_pkr.blob)
def pk_getmypubkey(sfd): print "GET MY PUBLIC KEY" myargs = {KEY_NICK: "youpiya"} acblob = ac_msg(ACMSG_TYPE_PK, ACMSG_SUBTYPE_PKGET, myargs) sfd.send(acblob) rcvblob = sfd.recv(2048) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_pkr = ac_pb2.acPublicKeyMessageResponse() ac_pkr.ParseFromString(ac_msg_test.blob) print "PKR message type:" print ac_pkr.type print "PKR message bada:" print ac_pkr.bada print "PKR message error_code:" print ac_pkr.error_code print "PKR do we have public keys?!" print ac_pkr.public_keys print "HOW MANY PUB KEYS!?" print len(ac_pkr.public_keys) for t in ac_pkr.public_keys: print t.nick + ":" + t.pubkey + ":" + str(t.timestamp) + ":" + str( datetime.datetime.fromtimestamp(t.timestamp)) print binascii.hexlify(t.fp) return 0
def pk_getnewpair(sfd): # # GET NEW KEYPAIR MESSAGE # print "GENERATE NEW KEYPAIR MESSAGE" #myargs = { KEY_NICK:"yondaime", KEY_HOST:KEY_HOST_DATA, KEY_SERVER:KEY_SERVER_DATA, KEY_BLOB:"ddskjdkdjsakjdasksa" } myargs = { KEY_NICK: "yondaime", KEY_HOST: KEY_HOST_DATA, KEY_SERVER: "", KEY_BLOB: "ddskjdkdjsakjdasksa" } acblob = ac_msg(ACMSG_TYPE_PK, ACMSG_SUBTYPE_PKGEN, myargs) sfd.send(acblob) rcvblob = sfd.recv(2048) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_pkr = ac_pb2.acPublicKeyMessageResponse() ac_pkr.ParseFromString(ac_msg_test.blob) print "PKR message type:" print ac_pkr.type print "PKR message bada:" print ac_pkr.bada print "PKR message error_code:" print "%d" % ac_pkr.error_code return 0
def ac_msg(type=ACMSG_TYPE_PK, subtype=ACMSG_SUBTYPE_PKGEN, args=None): acmsg = ac_pb2.ArseneCryptoMessage() if type == ACMSG_TYPE_PK: acmsg.type = ac_pb2.ArseneCryptoMessage.AC_PK acmsg.blob = ac_pk_msg(subtype, args) elif type == ACMSG_TYPE_KEX: acmsg.type = ac_pb2.ArseneCryptoMessage.AC_KEX acmsg.blob = ac_kex_msg(subtype, args) elif type == ACMSG_TYPE_CRYPTO: acmsg.type = ac_pb2.ArseneCryptoMessage.AC_CRYPTO acmsg.blob = ac_crypto_msg(subtype, args) elif type == ACMSG_TYPE_PING: ac_ping_msg(subtype, args) else: print "invalid message build" ret_blob = acmsg.SerializeToString() return ret_blob
def pk_del(sfd): print "DEL message" #myargs = { KEY_NICK:"frlfrl" } myargs = None # { KEY_NICK:"frlfrl" } acblob = ac_msg(ACMSG_TYPE_PK, ACMSG_SUBTYPE_PKDEL, myargs) sfd.send(acblob) rcvblob = sfd.recv(4096) ac_msg_test = ac_pb2.ArseneCryptoMessage() ac_msg_test.ParseFromString(rcvblob) print "message type:" print ac_msg_test.type ac_pkr = ac_pb2.acPublicKeyMessageResponse() ac_pkr.ParseFromString(ac_msg_test.blob) print "PKR message type:" print ac_pkr.type print "PKR message bada:" print ac_pkr.bada print "PKR message error_code:" print ac_pkr.error_code