#NEWLINE# def _HashFile( self , fd ) : #NEWLINE# #INDENT# 'Look for the required hashes in the file.' #NEWLINE# hashes = fd . Get ( fd . Schema . HASH ) #NEWLINE# if hashes : #NEWLINE# #INDENT# found_all = True #NEWLINE# for ( fingerprint_type , hash_types ) in self . HASH_TYPES . iteritems ( ) : #NEWLINE# #INDENT# for hash_type in hash_types : #NEWLINE# #INDENT# if ( fingerprint_type == 'pecoff' ) : #NEWLINE# #INDENT# hash_type = ( 'pecoff_%s' % hash_type ) #NEWLINE# #UNINDENT# if ( not hashes . HasField ( hash_type ) ) : #NEWLINE# #INDENT# found_all = False #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not found_all ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# if found_all : #NEWLINE# #INDENT# return hashes #NEWLINE# #UNINDENT# #UNINDENT# fingerprinter = fingerprint . Fingerprinter ( fd ) #NEWLINE# if ( 'generic' in self . HASH_TYPES ) : #NEWLINE# #INDENT# hashers = self . _GetHashers ( self . HASH_TYPES [ 'generic' ] ) #NEWLINE# fingerprinter . EvalGeneric ( hashers = hashers ) #NEWLINE# #UNINDENT# if ( 'pecoff' in self . HASH_TYPES ) : #NEWLINE# #INDENT# hashers = self . _GetHashers ( self . HASH_TYPES [ 'pecoff' ] ) #NEWLINE# if hashers : #NEWLINE# #INDENT# fingerprinter . EvalPecoff ( hashers = hashers ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not hashes ) : #NEWLINE# #INDENT# hashes = fd . Schema . HASH ( ) #NEWLINE# #UNINDENT# for result in fingerprinter . HashIt ( ) : #NEWLINE# #INDENT# fingerprint_type = result [ 'name' ] #NEWLINE# for hash_type in self . HASH_TYPES [ fingerprint_type ] : #NEWLINE# #INDENT# if ( hash_type not in result ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( hash_type == 'SignedData' ) : #NEWLINE# #INDENT# for signed_data in result [ hash_type ] : #NEWLINE# #INDENT# hashes . signed_data . Append ( revision = signed_data [ 0 ] , cert_type = signed_data [ 1 ] , certificate = signed_data [ 2 ] ) #NEWLINE# #UNINDENT# continue #NEWLINE# #UNINDENT# if ( fingerprint_type == 'generic' ) : #NEWLINE# #INDENT# hashes . Set ( hash_type , result [ hash_type ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( fingerprint_type == 'pecoff' ) : #NEWLINE# #INDENT# hashes . Set ( ( 'pecoff_%s' % hash_type ) , result [ hash_type ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . error ( 'Unknown fingerprint_type %s.' , fingerprint_type ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# fd . Set ( hashes ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return hashes