Date: Mon, 12 Jan 1998 10:05:38 -0800 (PST)
From: Jan Luehe <Jan.Luehe@Eng>
Subject: Re: JCE Query : How to Initialize Cipher for Encrypt/Decrypt
To: java-security@web1.javasoft.com, vgoenka@novell.com
Vishal:
> Couple of questions on usage of Cipher class :
>
> 1. The methods do not seem to take any parameter that may specify whether
> the Cipher has to be used for encryption or decryption.
All the "init()" methods take an "opmode" parameter of type "int", which
can be set to either ENCRYPT_MODE or DECRYPT_MODE.
ENCRYPT_MODE and DECRYPT_MODE are constants of the Cipher class.
> 2. Since all methods (except constructor) are final, it appears that the
> provider must extend CipherSpi.
This is correct.
> Does Cipher.getInstance() instantiates the
> Provider's CipherSpi and pass that as an argument to the Cipher constructor,
> or, does it instantiate the provider's Cipher (subclass of Cipher) and the
> subclass is expected to call super(providerCipherSpi, ....).
"getInstance()" does everything for you:
It creates an instance of the provider's implementation of CipherSpi
("SPI object"), creates an instance of Cipher ("API object"),
encapsulates the SPI object into the API object, and returns the
API object to the application.
All the methods of the API object are declared final, and are implemented
as to call the corresponding method of the encapsulated SPI object.
> I would appreciate if some more documentation on usage of JCE classes in
> general is made available. Source code would do too, but I guess that is not
> distributed right now ?
Source is not distributed currently.
The file "jce12-ea-dom/doc/guide/JceSpec.html" contains documentation
and user examples. We are currently working on a document that
explains how to become a provider for the JCE.
Jan