Welcome to the "trac"-ing site of openpgp4u!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 39 for trunk/lib

Show
Ignore:
Timestamp:
06/10/06 13:13:13 (2 years ago)
Author:
nahi
Message:

added Signature#verify.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/pgp/packet/signature.rb

    r18 r39  
    105105  def unhashedsubpacket 
    106106    @unhashedsubpacket 
     107  end 
     108 
     109  def verify(pubkey, target) 
     110    packed_decoded_hash = MPI.to_bytes(pubkey.decrypt(@signature)) 
     111    decoded_hash = PKeyAlgorithm.decode_hash(@pkey_algorithm, pubkey.nbits,  
     112      @hash_algorithm, packed_decoded_hash) 
     113 
     114    hashed_body = dump_version + dump_signature_type + dump_pkey_algorithm + 
     115      dump_hash_algorithm + dump_hashedsubpacket 
     116    calced_hash = calc_hash(target + dump_hash_magic(hashed_body)) 
     117 
     118    decoded_hash == calced_hash 
    107119  end 
    108120