|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.security.KeyGenerator
Key generation toolbox.
Details: KeyGenerator
contains a variety of functions for generating keys.
Constructor Summary | |
KeyGenerator()
|
Method Summary | |
static byte[] |
compressBits(byte[] ipbSrc,
int inSrcLen,
byte[] opbDest,
int inDestLen)
Compresses bit vector. |
static byte[] |
getInterleavedHash(java.io.InputStream iopIn,
java.lang.String isAlgorithm,
int inMultiplicity)
Generates extended hash. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public KeyGenerator()
Method Detail |
public static byte[] getInterleavedHash(java.io.InputStream iopIn, java.lang.String isAlgorithm, int inMultiplicity) throws java.io.IOException
Details: getInterleavedHash generates an "extended hash" by computing several hashes at once and concatenating them together. The data to be hashed is supplied by iopIn, and the number of simultaneous subhashes to compute is given by inMultiplicity. Each subhash takes its turn drawing bytes, one at a time, from iopIn until it runs out of bytes. The resulting hashes are then concatenated together. The hash function is given by isAlgorithm. Any hash algorithm supported by java.security.MessageDigest
is supported by this function. For most Java installations, this includes "SHA" and "MD5".
iopIn
- the input dataisAlgorithm
- the hash functioninMultiplicity
- number of simultaneous subhashespublic static byte[] compressBits(byte[] ipbSrc, int inSrcLen, byte[] opbDest, int inDestLen)
Details: compressBits compresses the given bit vector (ipbSrc, inSrcLen) into a bit vector of the requested size (inDesLen). The result is stored in the supplied destination array (opbDest), if one is given, or in the return value.
The compression is achieved by linearly mapping each bit in the source vector to the destination vector, by means of the following scaling function:
dest_index = source_index * dest_size / source_size
(using integer arithmatic)
Before the mapping is applied, the destination vector is filled with zeros. Then, for each bit in the source vector that is set to 1, the mapped bit in the destination vector is toggled.
If a destination array is not supplied (i.e., obpDest == null
), then one is created automatically and returned.
ibpSrc and opbDest are given in bits, not bytes. Bit zero in ipbSrc is the least significant bit of ipbSrc [inSrcLen - 1]. Similarly, bit zero in opbDest, if supplied, will be the least significant bit of opbDest [inDestLen - 1]. Extra bits in ibpSrc are ignored, and unused bits in opbDest are set to zero.
ipbSrc
- the source vectorinSrcLen
- length of source vectorobpDest
- destination for resultinDestLen
- length to compress to
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |