blob: 90d699378b4d63a8a71cb3275abda0d6981b3699 [file] [log] [blame]
Stuart McCulloch26e7a5a2011-10-17 10:31:43 +00001package aQute.libg.cryptography;
2
3import java.io.*;
4import java.security.*;
5
6
7public class Verifier extends OutputStream {
8 final Signature signature;
9 final Digest d;
10
11 Verifier(Signature s, Digest d) {
12 this.signature = s;
13 this.d = d;
14 }
15
16 @Override
17 public void write( byte[] buffer, int offset, int length) throws IOException {
18 try {
19 signature.update(buffer, offset, length);
20 } catch (SignatureException e) {
21 throw new IOException(e);
22 }
23 }
24
25 @Override
26 public void write( int b) throws IOException {
27 try {
28 signature.update((byte) b);
29 } catch (SignatureException e) {
30 throw new IOException(e);
31 }
32 }
33
34 public boolean verify() throws Exception {
35 return signature.verify(d.digest());
36 }
37
38}