-
Enhancement
-
Resolution: Won't Fix
-
P3
-
None
-
jce1.2fcs
-
generic
-
generic
Name: krC82822 Date: 02/03/2001
java version "1.2.2-RC2"
Classic VM (build 1.2.2-RC2-K, green threads, javacomp)
The following classes function in similar ways, but have slightly different APIs
that cause some inconvenience:
java.security.Signature
java.crypto.Cipher
Signature, by necessity, has two modes: SIGN and VERIFY. Cipher also has two
modes: ENCRYPT and DECRYPT. Strangely, the two classes use different ways of
selecting modes: Signature uses different initialization methods, initSign and
initVerify. Cipher uses a "mode" flag in its init() method.
It would be more intuitive for Cipher to have initEncrypt and initDecrypt
methods. This also avoids confusing this meaning of "mode" with the alogrithm
mode (CBC, ECB, etc).
Signature also lacks the convenience of Cipher's one-step final operations. It
would be helpful if Signature had methods like the following:
byte[] sign(byte[] input);
byte[] sign(byte[] input, int offset, int length);
int sign(byte[] input, int inputOffset, int length,
byte[] output, int outputOffset);
boolean verify(byte[] signature, byte[] input);
boolean verify(byte[] signature, byte[] input, int offset, int length);
Note that java.security.MessageDigest and java.crypto.Mac are also missing some
of these convenience methods. Adding these methods makes these classes easier
and more intuitive to use.
(Review ID: 105599)
======================================================================