Skip to content

Commit

Permalink
added Signature#verify.
Browse files Browse the repository at this point in the history
  • Loading branch information
nahi committed Jun 10, 2006
1 parent 24815ec commit 5b3bbe6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/pgp/packet/signature.rb
Expand Up @@ -106,6 +106,18 @@ def unhashedsubpacket
@unhashedsubpacket
end

def verify(pubkey, target)
packed_decoded_hash = MPI.to_bytes(pubkey.decrypt(@signature))
decoded_hash = PKeyAlgorithm.decode_hash(@pkey_algorithm, pubkey.nbits,
@hash_algorithm, packed_decoded_hash)

hashed_body = dump_version + dump_signature_type + dump_pkey_algorithm +
dump_hash_algorithm + dump_hashedsubpacket
calced_hash = calc_hash(target + dump_hash_magic(hashed_body))

decoded_hash == calced_hash
end

private

def dump_body
Expand Down

0 comments on commit 5b3bbe6

Please sign in to comment.