def get_trace(self): """ Do not take any argument. Returns the next triplet (message, cipher, trace), where: - message is an ascii string containing a 64 bits clear message in hexadecimal, - cipher is an ascii string containing a 64 bits ciphered message in hexadecimal, - trace is a float vector containing a trace during the cipher operation. """ if self.__i == len( self.__dbd ): return None, None, None; # Error, since we have reached the last file trace_name= self.__dbd[self.__i] self.__i+= 1; try: cmd= "SELECT message,cryptogram,filecontent FROM "+self.__table+" WHERE filename = '"+trace_name+"'" self.__curs.execute( cmd ) one= self.__curs.fetchone() msg, crypt, raw_data= one if db_name=='pgdb': raw_data= db.unescape_bytea( raw_data ) return msg, crypt, parse_binary( str(raw_data) ) except db.DatabaseError, e: print e sys.exit(1)
def get_trace(self): """ Do not take any argument. Returns the next couple (message, trace), where: - message is an ascii string containing a 64 bits clear message in hexadecimal, - trace is a float vector containing a trace during the cipher operation. """ msg, crypt, raw_data= self.__curs.fetchone() if db_name=='pgdb': raw_data= db.unescape_bytea( raw_data ) return msg, crypt, parse_binary( str(raw_data) )
def get_file(self, filename): """ Returns the raw trace (header plus float vector) of <filename> """ try: cmd= "SELECT encode(data, 'escape') FROM "+self.__table+" WHERE filename = '"+filename+"'" self.__curs.execute( cmd ) raw_data= self.__curs.fetchone() if db_name=='pgdb': raw_data= db.unescape_bytea( raw_data ) return parse_binary( str(raw_data) ) except db.DatabaseError, e: print e sys.exit(1)