|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.rsa.jsafe.JSAFE_Object
com.rsa.jsafe.JSAFE_Recode
The JSAFE_Recode class changes the encoding of data from
binary to ASCII and vice versa. Crypto-J currently supports Base64-encoding.
This class can instantiate the classes that create and verify
signatures, and it defines the functionality.
See Overview of Crypto-J for background and reference material on using and understanding Crypto-J.
Copyright © RSA Security Inc., 1997-2005. All rights reserved.
| Constructor Summary | |
JSAFE_Recode()
|
|
| Method Summary | |
void |
clearSensitiveData()
Clears sensitive data from an object. |
byte[] |
decodeFinal()
Finalizes the decoding and strips the padding, if necessary. |
abstract int |
decodeFinal(byte[] partOut,
int outOffset)
Finalizes the process and decodes any leftover bytes. |
abstract void |
decodeInit()
Initializes this object to perform decoding. |
byte[] |
decodeUpdate(byte[] partIn,
int inOffset,
int partInLen)
Decodes the first |
abstract int |
decodeUpdate(byte[] partIn,
int inOffset,
int partInLen,
byte[] partOut,
int outOffset)
Decodes the first |
byte[] |
encodeFinal()
Finalizes the encoding process and encodes any leftover bytes. |
abstract int |
encodeFinal(byte[] partOut,
int outOffset)
Finalizes the encoding, appending the padding if necessary. |
abstract void |
encodeInit()
Initializes this object to encode. |
byte[] |
encodeUpdate(byte[] partIn,
int inOffset,
int partInLen)
Encodes the input data. |
abstract int |
encodeUpdate(byte[] partIn,
int inOffset,
int partInLen,
byte[] partOut,
int outOffset)
Encodes the first |
abstract String |
getAlgorithm()
Returns the standard recode algorithm name. |
abstract int[] |
getAlgorithmParameters()
Returns a new |
getDevice()
Returns the name of the device of record. |
|
String[] |
getDeviceList()
Returns a |
static JSAFE_Recode |
getInstance(String transformation,
String device)
Builds an object that performs the |
abstract int |
getOutputBufferSize(int inputLen)
Returns the maximum size (in bytes) that an output buffer should be
to hold the results of an encode or a decode ( |
| Methods inherited from class com.rsa.jsafe.JSAFE_Object |
clone, overwrite, overwrite |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public JSAFE_Recode()
| Method Detail |
public static JSAFE_Recode getInstance(String transformation,
String device)
throws JSAFE_UnimplementedException,
JSAFE_InvalidParameterException
transformation on the
given device.
The value of transformation is as follows:
| transformation Value | Description |
| "Base64- | Where s is the encoded line size (default is 76). (0 < s <= 76, s must be a multiple of 4). |
The value of device is as follows: "choice1[/choice2[...[/choicen]]]".
The device values are:
Crypto-J tries to instantiate a class using the first choice. If it cannot, it tries the other choices. The following example performs Base64-encoding or recoding without inserted CR or LF breaks, using Java.
JSAFE_Recode recode =
JSAFE_Recode.getInstance
("Base64-0", "Java");
The following example performs Base64-encoding using the default encoded
line size of 76 characters, using Java.
JSAFE_Recode recode =
JSAFE_Recode.getInstance
("Base64", "Java");
transformation - The representation of the desired operation
(for example, "Base64").device - A list of devices used to build the object
(for example, "Java", "Native/Java").
JSAFE_Recode object that performs the
transformation.
JSAFE_UnimplementedException - If the device or devices cannot
perform the designated algorithm.
JSAFE_InvalidParameterException - If the specified
transformation contains parameters that do not work.public String getDevice()
public String[] getDeviceList()
String array that describes all the
devices used to execute the transformation. Because
a transformation often consists of component
algorithms, the implementation can consist of several component
Objects. A device can perform one or more of the algorithms,
but it may let Java or another device perform one or more. For
example, because padding is not time-consuming, a device might
let the Crypto-J implementation perform padding. Returns the
names of the devices used by each component.
String array that describes the device used for a
specific component.public abstract String getAlgorithm()
String that describes the recode algorithm.public abstract int[] getAlgorithmParameters()
int array containing the algorithm's parameters.
For example, if the underlying algorithm is Base64-76,
the return value is an array of length 1, containing the
encoded line size. If the algorithm is Base64, the return
value is a zero-element array because no arguments are specified.
This may be an array of length 0.
int array containing the parameters of the
algorithm.public abstract int getOutputBufferSize(int inputLen)
Update and
Final). The computation includes the length of any unprocessed
data. However, the actual output may be smaller than the reported value.
Given the length of input bytes (inputLen).
inputLen - The length of the input in bytes.
int that indicates the size of the output.
If the object has not been initialized yet,
this method returns -1.
public abstract void encodeInit()
throws JSAFE_InvalidUseException
JSAFE_InvalidUseException - If the object cannot be initialized.
public byte[] encodeUpdate(byte[] partIn,
int inOffset,
int partInLen)
throws JSAFE_InvalidUseException
partInLen bytes in the array partIn, beginning
at inOffset. It returns the result in the byte
array partOut.
partIn - The data to encode.inOffset - The offset into partIn where the data begins.partInLen - The length of the data to encode.
byte array containing the encoded data.
JSAFE_InvalidUseException - If the object is not
initialized to encode.
public abstract int encodeUpdate(byte[] partIn,
int inOffset,
int partInLen,
byte[] partOut,
int outOffset)
throws JSAFE_InvalidUseException
partInLen bytes in the array
partIn, beginning at inOffset.
It returns the result in the byte array partOut,
beginning at outOffset.
partIn - The data to encode.inOffset - The offset into partIn where the data begins.partInLen - The length of the data to encode.partOut - The buffer where the output is placed.outOffset - The offset into partOut where the writing
begins.
JSAFE_InvalidUseException - If the object is not
initialized to encode.
public byte[] encodeFinal()
throws JSAFE_InvalidUseException,
JSAFE_InputException
byte array.
A Final method must be called before reusing an object
to encode or to decode.
byte array containing the encoded data.
JSAFE_InvalidUseException - If the object is not
initialized to encode.
JSAFE_InputException - If the input was not padded.
public abstract int encodeFinal(byte[] partOut,
int outOffset)
throws JSAFE_InvalidUseException
byte array partOut,
beginning at outOffset. The return value is the number of
bytes placed in the output buffer. A Final method
must be called before reusing an object to encode or to decode.
partOut - The buffer where the output is placed.outOffset - The offset into partOut where the writing
begins.
JSAFE_InvalidUseException - If the object is not
initialized to encode.
public abstract void decodeInit()
throws JSAFE_InvalidUseException
JSAFE_InvalidUseException - If the object cannot be initialized.
public byte[] decodeUpdate(byte[] partIn,
int inOffset,
int partInLen)
throws JSAFE_InvalidUseException,
JSAFE_InputException
partInLen bytes in the array
partIn, beginning at inOffset.
Decodes the input data.
Returns the result in a new byte array.
partIn - The data to decode.inOffset - The offset into partIn where the data begins.partInLen - The length of the data to decode.
byte array containing the encoded data.
JSAFE_InvalidUseException - If the object is not
initialized to decode.
JSAFE_InputException
public abstract int decodeUpdate(byte[] partIn,
int inOffset,
int partInLen,
byte[] partOut,
int outOffset)
throws JSAFE_InvalidUseException,
JSAFE_InputException
partInLen bytes in the array
partIn, beginning at inOffset.
Decodes the input data.
Returns the result in the byte array partOut,
beginning at outOffset.
The return value is the number of bytes placed in the output buffer.
partIn - The data to decode.inOffset - The offset into partIn where the data begins.partInLen - The length of the data to decode.partOut - The buffer where the output is placed.outOffset - The offset into partOut where the writing
begins.
JSAFE_InvalidUseException - If the object is not
initialized to decode.
JSAFE_InputException
public byte[] decodeFinal()
throws JSAFE_InvalidUseException,
JSAFE_InputException
byte array.
If there are no output bytes, it returns a zero-length array.
A Final method must be called before reusing an object
to encode or decode.
byte array containing the decoded data.
JSAFE_InvalidUseException - If the object is not
initialized to decode.
JSAFE_InputException - If the input could not be unpadded.
public abstract int decodeFinal(byte[] partOut,
int outOffset)
throws JSAFE_InvalidUseException,
JSAFE_InputException
byte array
partOut, beginning at outOffset.
The return value is the number of bytes
actually placed in the output buffer. If there are no output bytes,
returns null. A Final method must be
called before reusing the object to encode or decode.
partOut - The buffer where the output is placed.outOffset - The offset into partOut where the writing
begins.
JSAFE_InvalidUseException - If the object is not
initialized to decode.
JSAFE_InputException - If the input could not be unpadded.public void clearSensitiveData()
clearSensitiveData(),
an Init (not a ReInit) method is
called to perform other operations with the object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||