Node:Signature Example, Previous:The ISignatureCodec Interface, Up:Signatures



Signature Example

     ISignature dss = SignatureFactory.getInstance("DSS");
     Map attrib = new HashMap();
     attrib.put(ISignature.SIGNER_KEY, privateDsaKey);
     dss.setupSign(attrib);
     
     dss.update(message, 0, message.length);
     Object sig = dss.sign();
     
     ISignatureCodec codec = new DSSSignatureRawCodec();
     byte[] encoded = codec.encodeSignature(sig);
     
     Object sig2 = codec.decodeSignature(encoded);
     
     attrib.clear();
     attrib.put(ISignature.VERIFIER_KEY, publicDsaKey);
     dss.setupVerify(attrib);
     
     dss.update(message, 0, message.length);
     boolean valid = dss.verify(sig);
     
diagrams/sign_verify_seq_diag.png
Figure 15: Signature sequence diagram