Date: Mon, 9 Feb 1998 10:02:27 -0800 (PST)
From: Jan Luehe <Jan.Luehe@Eng>
Subject: Re: Cipher or CipherSpi?
To: java-security@web1.javasoft.com, rsodre@solar.com.br
Rodrigo:
> To implement a provider, the first step is implement the
> criptographic algoritm classes. For example, if I want to prove an MD5 class
> I must do it in the following way:
>
> class MyMD5Class extends Message Digest {
> ...
> }
>
> and inside defining the methods starting by "engine" (remembring that
> MessageDigest is a subclass of MessageDigestSpi, wich defines a group of
> methods started by "engine").
>
> So, my doubt: if I want to prove a class that implements RSA, wich
> class should I extend: Chipher or CipherSpi? (Cipher isn't a class of
> CipherSpi).
As a provider, you always subclass off of an (abstract) Spi class.
The already updated and to-be-published "How to Become a Provider"
document will tell you this (in JDK1.2 beta3).
There is no hierarchical relationship between an API ("engine")
class and its corresponding Spi class, i.e., they both extend off of
Object.
There are 3 exceptions to this rule, namely all the engine classes
in the JDK that existed before JDK 1.2: MessageDigest, Signature,
and KeyPairGenerator. In those cases, the API class extends off of the
corresponding Spi class, in order not to break backwards compatibility
(there may be providers out there who already subclassed off of
MessageDigest or Signature or KeyPairGenerator, and we want their
implementations to continue to work).
In all the new engine classes (including all the engine classes
in JCE 1.2), all the API classes are concrete, all the Spi classes
are abstract, providers extend off of the Spi class, the
"getInstance" method instantiates a provider's implementation
(which is an instance of the Spi class) and encapsulates that
instance in an instance of the corresponding API class, which is then
returned to the user.
Jan