blob: 5506ece456f4e52a365e01e3507579cb457ef9b2 [file] [log] [blame]
Stuart McCullochbb014372012-06-07 21:57:32 +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.getLocalizedMessage());
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.getLocalizedMessage());
31 }
32 }
33
34 public boolean verify() throws Exception {
35 return signature.verify(d.digest());
36 }
37
38}