Skip to Content
Java Security
book

Java Security

by Scott Oaks
May 1998
Intermediate to advanced
469 pages
14h 57m
English
O'Reilly Media, Inc.
Content preview from Java Security

Implementing a Signature Class

Now that we’ve seen how to use the Signature class, we’ll look at how to implement our own class. The techniques we’ll see here should be very familiar from our other examples of implementing an engine in the security provider architecture. In particular, since in 1.2 the Signature class extends its own SPI, we can implement a single class that extends the Signature class.

To construct our subclass, we must use the following constructor:

protected Signature(String algorithm)

This is the only constructor of the Signature class, so all subclasses of this class must use this constructor. The string passed to the constructor is the name that will be registered with the security provider.

Once we’ve constructed our engine object, we must implement the following methods in it:

protected abstract void engineInitVerify(PublicKey pk)

Initialize the object to prepare it to verify a digital signature. If the public key does not support the correct algorithm or is otherwise corrupted, an InvalidKeyException is thrown.

protected abstract void engineInitSign(PrivateKey pk)

Initialize the object to prepare it to create a digital signature. If the private key does not support the correct algorithm or is otherwise corrupted, an InvalidKeyException is thrown.

protected abstract void engineUpdate(byte b) , protected abstract void engineUpdate(byte b[], int off, int len)

Add the given bytes to the data that is being accumulated for the signature. These methods are called by ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Security Handbook

Java Security Handbook

Jamie Jaworski, Paul J. Perrone, Venkata S.R. Krishna Chaganti

Publisher Resources

ISBN: 1565924037Supplemental ContentCatalog PageErrata