|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchapter2.Utils
chapter3.Utils
public class Utils
General utilities for the third chapter examples.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static javax.crypto.spec.IvParameterSpec |
createCtrIvForAES(int messageNumber,
java.security.SecureRandom random)
Create an IV suitable for using with AES in CTR mode. |
static javax.crypto.SecretKey |
createKeyForAES(int bitLength,
java.security.SecureRandom random)
Create a key for use with AES. |
static byte[] |
toByteArray(java.lang.String string)
Convert the passed in String to a byte array by taking the bottom 8 bits of each character it contains. |
static java.lang.String |
toString(byte[] bytes)
Convert a byte array of 8 bit characters into a String. |
static java.lang.String |
toString(byte[] bytes,
int length)
Convert a byte array of 8 bit characters into a String. |
Methods inherited from class chapter2.Utils |
---|
toHex, toHex |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static javax.crypto.SecretKey createKeyForAES(int bitLength, java.security.SecureRandom random) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
bitLength
- random
-
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
public static javax.crypto.spec.IvParameterSpec createCtrIvForAES(int messageNumber, java.security.SecureRandom random)
The IV will be composed of 4 bytes of message number, 4 bytes of random data, and a counter of 8 bytes.
messageNumber
- the number of the message.random
- a source of randomness
public static java.lang.String toString(byte[] bytes, int length)
bytes
- the array containing the characterslength
- the number of bytes to process
public static java.lang.String toString(byte[] bytes)
bytes
- the array containing the characters
public static byte[] toByteArray(java.lang.String string)
string
- the string to be converted
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |