public class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_JVM_DATA_MODEL |
Modifier and Type | Method and Description |
---|---|
static X509Certificate[] |
arrangeCertificateChain(X509Certificate[] certArray,
boolean topdown)
Tries to construct a certificate chain from an array of certificates.
|
static byte[] |
Base64Decode(byte[] in)
Decodes a Base64 encoded byte array.
|
static byte[] |
Base64Encode(byte[] in)
Encodes a binary byte array into Base64.
|
static int[] |
bubbleSort(int[] a)
Sort the given array of ints in ascending order and return it.
|
static long[] |
bubbleSort(long[] a)
Sort the given array of longs in ascending order and return it.
|
static int |
calculateHashCode(byte[] value)
Creates an integer suitable for hash table indexing.
|
static void |
compareTables(java.lang.String text,
int[] T0,
int[] T1) |
static X509Certificate |
convertCertificate(java.security.cert.Certificate certificate)
This method converts a Certificate object into an IAIK X509Certificate
object.
|
static X509Certificate[] |
convertCertificateChain(java.security.cert.Certificate[] certificateChain)
This method converts an array of Certificate objects into an array of IAIKX
X509Certificate objects.
|
static byte[] |
convertEndian32(byte[] in)
Convert between little and big endian 32 bit formats.
|
static AttributeCertificate |
convertToAttributeCertificate(java.security.cert.Certificate certificate)
This method converts a attribute Certificate object into an IAIK
AttributeCertificate object.
|
static AttributeCertificate[] |
convertToAttributeCertificateChain(java.security.cert.Certificate[] certificateChain)
This method converts an array of Certificates into an array of
AttributeCertificates.
|
static void |
copyStream(java.io.InputStream source,
java.io.OutputStream destination,
byte[] buffer)
Reads all data (until EOF is reached) from the given source to the
destination stream.
|
static X509Certificate[] |
createCertificateChain(X509Certificate userCertificate,
java.security.cert.Certificate[] certs)
Creates a certificate chain that starts with the given user certificate.
|
static AlgorithmID |
createRsaOaepAlgorithmID(AlgorithmID hashAlgID)
Creates an RSA-OAEP AlgorithmID for the given hash algorithm.
|
static AlgorithmID |
createRsaOaepAlgorithmID(AlgorithmID hashAlgID,
AlgorithmID pSourceID,
byte[] label)
Creates an RSA-OAEP AlgorithmID with the supplied parameters (hash algorithm id,
PSource algorithm and label).
|
static RSAOaepParameterSpec |
createRsaOaepParameters(AlgorithmID hashAlgID)
Creates RSA-OAEP parameters for the given hash algorithm.
|
static RSAOaepParameterSpec |
createRsaOaepParameters(AlgorithmID hashAlgID,
AlgorithmID pSourceID,
byte[] label)
Creates RSA-OAEP parameters for the given hash algorithm id,
PSource algorithm and label.
|
static AlgorithmID |
createRsaPssAlgorithmID(AlgorithmID hashAlgID)
Creates an RSA-PSS AlgorithmID for the given hash algorithm.
|
static AlgorithmID |
createRsaPssAlgorithmID(AlgorithmID hashAlgID,
int saltLength)
Creates an RSA-PSS AlgorithmID with the supplied parameters (hash algorithm id,
salt length).
|
static RSAPssParameterSpec |
createRsaPssParameters(AlgorithmID hashAlgID)
Creates RSA PSS parameters for the given hash algorithm id.
|
static RSAPssParameterSpec |
createRsaPssParameters(AlgorithmID hashAlgID,
int saltLength)
Creates RSA PSS parameters for the given hash algorithm id and salt length).
|
static byte[] |
decodeByteArray(java.lang.String st)
Decode base64 encoded data from the given string and return it as a byte
array.
|
static int[] |
decodeIntArray(java.lang.String st)
Decode base64 encoded data from the given string and return it as an int
array.
|
static java.security.Key |
decodeKey(int keyType,
java.lang.String keyAlgorithm,
byte[] encodedKey)
Construct a key object from and encoded key.
|
static X509Certificate[] |
decodePkiPath(byte[] pkiPath)
Parses a certificate array from a DER encoded PKI path.
|
static byte[] |
encodeAsPkiPath(X509Certificate[] certificates,
boolean sort)
Returns the given certificates as DER encoded PKI path.
|
static java.lang.String |
encodeByteArray(byte[] b)
Encodes a byte array in base64 and return it as a string.
|
static java.lang.String |
encodeIntArray(int[] a)
Encode an int array in base64 and return it as a string.
|
static void |
fillArray(byte[] array,
java.io.InputStream is)
This method tries to fill the given array with data read from the
InputStream.
|
static byte[] |
fromBase64String(java.lang.String base64)
Decodes a Base64 encoded data given as String.
|
static java.lang.String |
fromBooleanArray(boolean[] bits)
Converts the given array of boolean values into a string of zeros and ones.
|
static java.io.BufferedReader |
getASCIIReader(java.io.InputStream in)
Gets a reader that returns data from the stream assuming ASCII encoding is
used.
|
static java.io.PrintWriter |
getASCIIWriter(java.io.OutputStream out)
Gets a writer that writes data to the stream in ASCII encoding is used.
|
static java.io.PrintWriter |
getASCIIWriter(java.io.OutputStream out,
boolean autoflush)
Gets a writer that writes data to the stream in ASCII encoding is used.
|
static int |
getCharFromUTF8Array(int[] encoding)
Converts the given array of UTF-8 octets into a character.
|
static char[] |
getCharsFromUTF8Encoding(byte[] enc)
Decodes an UTF-8 encoded byte array and returns the result as char array.
|
static char[] |
getCharsFromUTF8Encoding(byte[] enc,
boolean skipInvalidCharacters)
Decodes an UTF-8 encoded byte array and returns the result as char array.
|
static boolean |
getDefaultRFC2253StringEscaping()
|
static int |
getDigestLength(AlgorithmID hashAlgID)
Tries to determine the length of the digest value produced by the given
hash algorithm.
|
static int |
getDigestLength(java.lang.String digestAlg)
Tries to determine the length of the digest value produced by the given
hash algorithm.
|
static int |
getJVMDataMode()
Returns the bit mode of the underlying JVM.
|
static int |
getKeyLength(java.security.PrivateKey key)
Gets the modulus length of a private key.
|
static int |
getKeyLength(java.security.PublicKey key)
Gets the modulus length of a public key.
|
static java.lang.String |
getRawCipherName(java.lang.String transformation)
Tries to get the raw name of the cipher specified by the given
transformation string.
|
static java.lang.String |
getRFC2253String(char[] str)
Returns a UTF-8 String representation according to RFC 2253.
|
static java.lang.String |
getRFC2253String(char[] str,
boolean strictEscaping)
Returns a UTF-8 String representation according to RFC 2253.
|
static java.lang.String |
getRFC2253String(java.lang.String str)
Returns a UTF-8 String representation according to RFC 2253.
|
static java.lang.String |
getRFC2253String(java.lang.String str,
boolean strictEscaping)
Returns a UTF-8 String representation according to RFC 2253.
|
static RSAPrivateKey |
getRSAPrivateKey(java.security.Key key)
Convert a key to an IAIK RSAPrivateKey.
|
static RSAPublicKey |
getRSAPublicKey(java.security.Key key)
Convert a key to an IAIK RSAPublicKey.
|
static java.security.AlgorithmParameters |
getSignatureParameters(java.security.Signature signature)
Gets the parametes from a Signature engine.
|
static java.lang.String |
getStringFromUTF8Encoding(byte[] enc)
Decodes an UTF-8 encoded byte array and returns the result as string.
|
static java.lang.String |
getStringFromUTF8Encoding(byte[] enc,
boolean skipInvalidCharacters)
Decodes an UTF-8 encoded byte array and returns the result as string.
|
static byte[] |
getUTF8EncodingFromCharArray(char[] str)
UTF-8 encodes the given char array.
|
static byte[] |
getUTF8EncodingFromString(java.lang.String str)
UTF-8 encodes the given string.
|
static java.util.Vector |
getVector(java.lang.Object[] array)
This method converts an array to a Vector.
|
static boolean |
loadClass(java.lang.String name,
boolean createInstance)
Tries to dynamically load a class.
|
static java.lang.String |
printIndented(java.lang.String msg,
boolean indentFirst)
Creates a new String from the given (multi line) message where each line is
indented with a space " " token.
|
static java.lang.String |
printIndented(java.lang.String msg,
boolean indentFirst,
java.lang.String indentToken)
Creates a new String from the given (multi line) message where each line is
indented with the given indent token.
|
static void |
printIndented(java.lang.String msg,
boolean indentFirst,
java.lang.StringBuffer buf)
Prints the given (multi line) message indented to the supplied
StringBuffer.
|
static void |
printIndented(java.lang.String msg,
boolean indentFirst,
java.lang.String indentToken,
java.lang.StringBuffer buf)
Prints the given (multi line) message indented to the supplied
StringBuffer.
|
static void |
printTable(java.lang.String text,
byte[] table) |
static void |
printTable(java.lang.String text,
int[] table) |
static ACRL[] |
readACRLChain(java.io.InputStream is)
Tries to read a attribute crl list from the given input stream.
|
static AttributeCertificate[] |
readAttributeCertificateChain(java.io.InputStream is)
Tries to read an attribute certificate chain from the given input stream.
|
static X509Certificate[] |
readCertificateChain(java.io.InputStream is)
Tries to read a certificate chain from the given input stream.
|
static X509CRL[] |
readCRLChain(java.io.InputStream is)
Tries to read a crl list from the given input stream.
|
static byte[] |
readFile(java.lang.String fileName)
Reads the content of a file into a byte array.
|
static X509Certificate[] |
readPkiPath(java.io.InputStream in)
Parses a certificate array from a DER encoded PKI path read from the given
inputstream.
|
static byte[] |
readStream(java.io.InputStream in)
Reads the contents of the stream into a byte array.
|
static byte[] |
resizeArray(byte[] array,
int len)
Resizes a byte array to the specified length.
|
static java.lang.Object[] |
resizeArray(java.lang.Object[] array,
int len)
Resizes an array of objects to the specified length.
|
static void |
reverseArray(java.lang.Object[] array,
int off,
int len)
Reverses the order of the objects in the given array.
|
static void |
saveToFile(byte[] array,
java.lang.String fileName)
Saves the content of the given byte array to a file.
|
static void |
setDefaultRFC2253StringEscaping(boolean strict)
|
static void |
setEncoding(java.lang.String encoding)
Sets the encoding to be used by ASN.1 String types for String - byte
conversion.
|
static void |
setSignatureParameters(java.security.Signature signature,
java.security.spec.AlgorithmParameterSpec params,
java.lang.String paramsName)
Sets the parametes for a Signature engine.
|
static java.lang.Object[] |
toArray(java.util.Vector aVector)
This method converts a Vector to an array.
|
static java.lang.Object[] |
toArray(java.util.Vector aVector,
java.lang.Class cls)
This method converts a Vector to an array.
|
static byte[] |
toASCIIBytes(java.lang.String s)
Convert the String to a byte[] in the ASCII encoding.
|
static java.lang.String |
toASCIIString(byte[] bytes)
Convert the bytes to a String using the ASCII encoding.
|
static java.lang.String |
toASCIIString(byte[] bytes,
int ofs,
int cnt)
Convert the bytes to a String using the ASCII encoding.
|
static java.lang.String |
toBase64String(byte[] in)
Encodes a binary byte array into Base64 and returns the result as String.
|
static boolean[] |
toBooleanArray(java.lang.String bits)
Transforms the characters of the given bit string into boolean values and
returns the given string as an array of boolean values.
|
static int |
toByte(char c,
int radix)
Convert the given char to an int.
|
static byte[] |
toByteArray(int i)
Converts an integer to a byte array in big endian order.
|
static byte[] |
toByteArray(long l)
Converts a long integer to a byte array in big endian order.
|
static byte[] |
toByteArray(java.lang.String s)
Convert the given string with hex values to a byte array.
|
static byte[] |
toPemArray(AttributeCertificate cert)
Convert the given attribute certificate to a PEM style base64 encoded byte
array.
|
static byte[] |
toPemArray(byte[] data,
java.lang.String beginEndName)
Convert the given data to a PEM style base64 encoded byte array.
|
static byte[] |
toPemArray(java.security.cert.Certificate cert)
Convert the given Certificate to a PEM style base64 encoded byte array.
|
static byte[] |
toPemArray(java.security.cert.Certificate[] cert)
Convert the given Certificate to a PEM style base64 encoded byte array.
|
static byte[] |
toPemArray(CertificateRequest request)
Convert the given Certificate request to a PEM style base64 encoded byte
array.
|
static byte[] |
toPemArray(java.security.PrivateKey privKey)
Converts the given private key to a PEM style base64 encoded byte array.
|
static byte[] |
toPemArray(java.security.cert.X509CRL crl)
Convert the given CRL to a PEM style base64 encoded byte array.
|
static java.lang.String |
toPemString(AttributeCertificate cert)
Convert the given attribute certificate to a PEM style base64 encoded
string.
|
static java.lang.String |
toPemString(byte[] data,
java.lang.String beginEndName)
Convert the given data to a PEM style base64 encoded string.
|
static java.lang.String |
toPemString(java.security.cert.Certificate cert)
Convert the given Certificate to a PEM style base64 encoded string.
|
static java.lang.String |
toPemString(CertificateRequest request)
Convert the given Certificate request to a PEM style base64 encoded string.
|
static java.lang.String |
toPemString(java.security.PrivateKey privKey)
Convert the given private key to a PEM style base64 encoded string.
|
static java.lang.String |
toPemString(java.security.cert.X509CRL crl)
Convert the given CRL to a PEM style base64 encoded string.
|
static java.lang.String |
toSourceCodeString(byte[] s)
Formats a byte array so that the string it represents can be inserted in a
Java source code.
|
static java.lang.String |
toString(byte b)
Converts a byte into a hexadecimal string.
|
static java.lang.String |
toString(byte[] byteArray)
Converts a byte array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(byte[] byteArray,
int off,
int len)
Converts the specified subsequence of the given byte array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(byte[] byteArray,
int off,
int len,
java.lang.String delimiter)
Converts the specified subsequence of the given byte array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(byte[] byteArray,
java.lang.String delimiter)
Converts a byte array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(int i)
Converts an int into a hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(int[] intArray)
Converts an integer array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(int[] intArray,
int off,
int len)
Converts the specified subsequence of the given integer array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(int[] intArray,
int off,
int len,
java.lang.String delimiter)
Converts the specified subsequence of the given integer array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(int[] intArray,
java.lang.String delimiter)
Converts an integer array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(int i,
java.lang.String delimiter)
Converts an int into a hexadecimal string of the format: 01:23:34:56...,
where : denotes the
delimiter . |
static java.lang.String |
toString(long l)
Converts an int into a hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(long[] longArray)
Converts a long integer array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(long[] longArray,
int off,
int len)
Converts the specified subsequence of the given long integer array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(long[] longArray,
int off,
int len,
java.lang.String delimiter)
Converts the specified subsequence of the given long array into a
hexadecimal string of the format: 01:23:34:56...
|
static java.lang.String |
toString(long[] longArray,
java.lang.String delimiter)
Converts a long integer array into a hexadecimal string of the format:
01:23:34:56...
|
static java.lang.String |
toString(long l,
java.lang.String delimiter)
Converts an int into a hexadecimal string of the format: 01:23:34:56...,
where : gets replaced by
delimiter
Uses big endian byte order. |
static void |
waitKey()
Wait for the user to press the return key on System.in.
|
void |
writePkiPath(X509Certificate[] certificates,
boolean sort,
java.io.OutputStream os)
Writes the given certificates as DER encoded PKI path to the given output
stream.
|
public static final int DEFAULT_JVM_DATA_MODEL
public static void setDefaultRFC2253StringEscaping(boolean strict)
Name
,
RDN
, AVA
objects.strict
- whether to escape non printable ASCII (< 0x21 or > 0x7e) and
non-ASCII characters by an hexadecimal representation of their
UTF-8 encoding (default: strict)public static boolean getDefaultRFC2253StringEscaping()
Name
,
RDN
, AVA
objects.public static boolean loadClass(java.lang.String name, boolean createInstance)
The class to be loaded has to be specified by its name (including the whole package hierarchy), e.g.:
For actually creating a new instance of the requested class - some implementations of the Java-VM only execute the static part of a class if a new instance is created - set theUtil.loadClass("iaik.test.testdemo.Test1", true);
createInstance
parameter to true
.name
- the name of the class to load (e.g. "iaik.Test")createInstance
- if set to true
a new instance of the specified class
is created;true
, if the class has been loaded successfully and a
new instance has been created (if desired); false
otherwisepublic static byte[] readFile(java.lang.String fileName) throws java.io.IOException
fileName
- the name of the file to readjava.io.IOException
- if an IO error occurspublic static byte[] readStream(java.io.InputStream in) throws java.io.IOException
in
- the input stream to be readjava.io.IOException
- if an error occurs while reading the streampublic static void copyStream(java.io.InputStream source, java.io.OutputStream destination, byte[] buffer) throws java.io.IOException
source
- The stream providing the data.destination
- The stream that takes the data. If this is null, all data from
source will be read and discarded.buffer
- The buffer to use for forwarding. If it is null, the method
allocates a buffer.java.io.IOException
- If reading from the source or writing to the destination
fails.public static void saveToFile(byte[] array, java.lang.String fileName) throws java.io.IOException
array
- the byte array supplying the data to be written to the filefileName
- the name of the file to which the data shall be writtenjava.io.IOException
- if an I/O error occurspublic static java.lang.String toString(byte b)
For instance:
byte b = ...; System.out.println(Util.toString(b));
b
- the byte to convertpublic static java.lang.String toString(byte[] byteArray, int off, int len)
Starting at off
, len
bytes will be converted and
returned as hexadecimal string, e.g.:
byte[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
byteArray
- the byte array containing the dataoff
- the offset indicating the start position within the given byte
array; the following len
bytes will be converted into
a hexadecimal stringlen
- how many bytes shall be writtenpublic static java.lang.String toString(byte[] byteArray, int off, int len, java.lang.String delimiter)
Starting at off
, len
bytes will be converted and
returned as hexadecimal string, e.g.:
byte[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
byteArray
- the byte array containing the dataoff
- the offset indicating the start position within the given byte
array; the following len
bytes will be converted into
a hexadecimal stringlen
- how many bytes shall be writtendelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static java.lang.String toString(byte[] byteArray)
For instance:
byte[] arr = ...; System.out.println(Util.toString(arr));
byteArray
- the byte array containing the datapublic static java.lang.String toString(byte[] byteArray, java.lang.String delimiter)
For instance:
byte[] arr = ...; System.out.println(Util.toString(arr));
byteArray
- the byte array containing the datadelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static java.lang.String toString(int i)
For instance:
int i = ...; System.out.println(Util.toString(i));
i
- the int to convertpublic static java.lang.String toString(int i, java.lang.String delimiter)
delimiter
.
For instance:
int i = ...; System.out.println(Util.toString(i));
i
- the int to convertpublic static java.lang.String toString(int[] intArray, int off, int len, java.lang.String delimiter)
Starting at off
, len
integers will be converted
and returned as hexadecimal string, e.g.:
int[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
intArray
- the integer array containing the dataoff
- the offset indicating the start position within the given integer
array; the following len
integers will be converted
into a hexadecimal stringlen
- how many integers shall be writtendelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static java.lang.String toString(int[] intArray, int off, int len)
Starting at off
, len
integers will be converted
and returned as hexadecimal string, e.g.:
int[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
intArray
- the integer array containing the dataoff
- the offset indicating the start position within the given integer
array; the following len
integers will be converted
into a hexadecimal stringlen
- how many integers shall be writtenpublic static java.lang.String toString(int[] intArray)
For instance:
int[] arr = ...; System.out.println(Util.toString(arr));
intArray
- the integer array containing the datapublic static java.lang.String toString(int[] intArray, java.lang.String delimiter)
For instance:
int[] arr = ...; System.out.println(Util.toString(arr));
intArray
- the integer array containing the datadelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static java.lang.String toString(long l)
public static java.lang.String toString(long l, java.lang.String delimiter)
delimiter
Uses big endian byte order.public static java.lang.String toString(long[] longArray, int off, int len, java.lang.String delimiter)
Starting at off
, len
long integers will be
converted and returned as hexadecimal string, e.g.:
long[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
longArray
- the long integer array containing the dataoff
- the offset indicating the start position within the given long
integer array; the following len
long integers will
be converted into a hexadecimal stringlen
- how many long integers shall be writtendelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static java.lang.String toString(long[] longArray, int off, int len)
Starting at off
, len
integers will be converted
and returned as hexadecimal string, e.g.:
long[] arr = ...; System.out.println(Util.toString(arr, 0, 3));
longArray
- the long integer array containing the dataoff
- the offset indicating the start position within the given long
integer array; the following len
long integers will
be converted into a hexadecimal stringlen
- how many long integers shall be writtenpublic static java.lang.String toString(long[] longArray)
For instance:
long[] arr = ...; System.out.println(Util.toString(arr));
longArray
- the long integer array containing the datapublic static java.lang.String toString(long[] longArray, java.lang.String delimiter)
For instance:
long[] arr = ...; System.out.println(Util.toString(arr));
longArray
- the integer array containing the datadelimiter
- the delimiter to be used for separating the hex values, e.g. ":"
(specify "" for not using a delimiter)public static byte[] Base64Encode(byte[] in)
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
This method may be used for Base64 encoding some already DER encoded ASN1 object to get the PEM (Base64 DER) encoding, e.g.:
ASN1 asn1 = ...; //DER encode the ASN1 data structure just created: byte[] der_array = asn1.toByteArray(); //Base64 encode the DER encoded byte array just created to get the //PEM encoding: byte[] pem_array = Util.Base64Encode(der_array);
in
- the binary data to be Base64 encodedpublic static byte[] Base64Decode(byte[] in) throws Base64Exception
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
For instance:
byte[] data = ...; byte[] encoded_data = Util.Base64Encode(data); byte[] decoded_data = Util.Base64Decode(encoded_data);
in
- the Base64 encoded data to be decodedBase64Exception
- if there occurs an error while decodingpublic static java.lang.String toBase64String(byte[] in)
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
This method may be used for Base64 encoding some already DER encoded ASN1 object to get the PEM (Base64 DER) encoding, e.g.:
ASN1 asn1 = ...; //DER encode the ASN1 data structure just created: byte[] der_array = asn1.toByteArray(); //Base64 encode the DER encoded byte array just created to get the //PEM encoding: byte[] pem_array = Util.Base64Encode(der_array);
in
- the binary data to be Base64 encodedpublic static byte[] fromBase64String(java.lang.String base64) throws Base64Exception
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
For instance:
byte[] data = ...; byte[] encoded_data = Util.Base64Encode(data); byte[] decoded_data = Util.Base64Decode(encoded_data);
base64
- the Base64 encoded data string to be decodedBase64Exception
- if there occurs an error while decodingpublic static byte[] resizeArray(byte[] array, int len)
If len
is smaller than the array size some bytes are lost.
array
- the array to resizelen
- the new length of the arraypublic static java.lang.Object[] resizeArray(java.lang.Object[] array, int len)
If len
is smaller than the array size some entries are lost.
array
- the array to resizelen
- the new length of the arraypublic static void reverseArray(java.lang.Object[] array, int off, int len)
array
- the array to be "reversed"off
- the start offset into the arraylen
- the number of objects to be involved in the reversing operation,
starting at offpublic static void fillArray(byte[] array, java.io.InputStream is) throws java.io.IOException
array
- the array to fillis
- the InputStream to read fromjava.io.IOException
public static java.util.Vector getVector(java.lang.Object[] array)
array
- the array to convertpublic static java.lang.Object[] toArray(java.util.Vector aVector)
aVector
- the Vector to convertpublic static java.lang.Object[] toArray(java.util.Vector aVector, java.lang.Class cls)
AType[] test = (AType[]) Util.toArray(aVector, AType.class);Without using the specified class a ClassCastException would occur.
aVector
- the Vector to convertcls
- specifies the type of the elementspublic static void waitKey()
public static int toByte(char c, int radix)
public static byte[] toByteArray(java.lang.String s)
public static byte[] toByteArray(int i)
i
- the integer to be convertedpublic static byte[] toByteArray(long l)
l
- the long to be convertedpublic static byte[] decodeByteArray(java.lang.String st) throws java.lang.RuntimeException
java.lang.RuntimeException
public static java.lang.String encodeByteArray(byte[] b)
decodeByteArray
. Base64Encode
for getting the raw base64
encoded byte array.b
- the byte array to be encodedpublic static int[] decodeIntArray(java.lang.String st) throws java.lang.RuntimeException
java.lang.RuntimeException
public static java.lang.String encodeIntArray(int[] a)
public static java.lang.String fromBooleanArray(boolean[] bits)
bits
- the array of boolean values to be convertedpublic static boolean[] toBooleanArray(java.lang.String bits)
bits
- the string of bits to be transformed into booleanspublic static java.lang.String toSourceCodeString(byte[] s)
s
- the byte array to be formattedpublic static java.lang.String toPemString(java.security.cert.Certificate cert)
-----BEGIN CERTIFICATE----- BASE64DATA -----END CERTIFICATE-----In case of a CertificateEncodingException
null
will be
returned (should never occur with the IAIK JCE).cert
- the certificate to be PEM encodednull
if an
error occurspublic static java.lang.String toPemString(AttributeCertificate cert)
-----BEGIN ATTRIBUTE CERTIFICATE----- BASE64DATA -----END ATTRIBUTE CERTIFICATE-----In case of a CertificateEncodingException
null
will be
returned (should never occur with the IAIK JCE).cert
- the attribute certificate to be PEM encodednull
if an
error occurspublic static java.lang.String toPemString(java.security.cert.X509CRL crl)
-----BEGIN X509 CRL----- BASE64DATA -----END X509 CRL-----In case of a CRLException
null
will be returned (should never
occur with the IAIK JCE).crl
- the crl to be PEM encodednull
if an error
occurspublic static java.lang.String toPemString(java.security.PrivateKey privKey)
-----BEGIN PRIVATE KEY----- BASE64 ENCODED KEY -----END PRIVATE KEY-----If the key is a PKCS#8
EncryptedPrivateKeyInfo
the string will look like:
-----BEGIN ENCRYPTED PRIVATE KEY----- BASE64 ENCODED ENCRYPTED KEY -----END ENCRYPTED PRIVATE KEY-----
privKey
- the private key to be PEM encodednull
if an
error occurspublic static java.lang.String toPemString(CertificateRequest request)
-----BEGIN NEW CERTIFICATE REQUEST----- BASE64DATA -----END NEW CERTIFICATE REQUEST-----
request
- the certificate request to be PEM encodednull
if an error occurspublic static java.lang.String toPemString(byte[] data, java.lang.String beginEndName)
-----BEGIN PKCS7----- BASE64DATA -----END PKCS7-----
data
- the date to be PEM encodedbeginEndName
- the name that has to be insterted into the PEM start- and end-linenull
if an error occurspublic static byte[] toPemArray(java.security.cert.Certificate cert)
-----BEGIN CERTIFICATE----- BASE64DATA -----END CERTIFICATE-----In case of a CertificateEncodingException
null
will be
returned (should never occur with the IAIK JCE).cert
- the certificate to be PEM encodednull
if an
error occurspublic static byte[] toPemArray(java.security.cert.Certificate[] cert)
-----BEGIN CERTIFICATE----- BASE64DATA -----END CERTIFICATE-----In case of a CertificateEncodingException
null
will be
returned (should never occur with the IAIK JCE).cert
- the certificate to be PEM encodednull
if an
error occurspublic static byte[] toPemArray(AttributeCertificate cert)
-----BEGIN ATTRIBUTE CERTIFICATE----- BASE64DATA -----END ATTRIBUTE CERTIFICATE-----In case of a CertificateEncodingException
null
will be
returned (should never occur with the IAIK JCE).cert
- the attribute certificate to be PEM encodednull
if an
error occurspublic static byte[] toPemArray(java.security.cert.X509CRL crl)
-----BEGIN X509 CRL----- BASE64DATA -----END X509 CRL-----In case of a CRLException
null
will be returned (should never
occur with the IAIK JCE).crl
- the crl to be PEM encodednull
if an error
occurspublic static byte[] toPemArray(java.security.PrivateKey privKey)
The returned byte array will contain the byte representation of a PEM string that will look like:
-----BEGIN PRIVATE KEY----- BASE64 ENCODED KEY -----END PRIVATE KEY-----If the key is a PKCS#8
EncryptedPrivateKeyInfo
header and footer are:
-----BEGIN ENCRYPTED PRIVATE KEY----- BASE64 ENCODED ENCRYPTED KEY -----END ENCRYPTED PRIVATE KEY-----
privKey
- the private key to be PEM encodednull
if an
error occurspublic static byte[] toPemArray(CertificateRequest request)
-----BEGIN NEW CERTIFICATE REQUEST----- BASE64DATA -----END NEW CERTIFICATE REQUEST-----
request
- the certificate request to be PEM encodednull
if an
error occurspublic static byte[] toPemArray(byte[] data, java.lang.String beginEndName)
-----BEGIN PKCS7----- BASE64DATA -----END PKCS7-----
data
- the date to be PEM encodedbeginEndName
- the name that has to be insterted into the PEM start- and end-linenull
if an error occurspublic static long[] bubbleSort(long[] a)
public static int[] bubbleSort(int[] a)
public static X509Certificate[] convertCertificateChain(java.security.cert.Certificate[] certificateChain) throws java.security.cert.CertificateException
certificateChain
- the array of certificates to convertjava.security.cert.CertificateException
- if there occurs an error while parsing the certificate chainpublic static X509Certificate convertCertificate(java.security.cert.Certificate certificate) throws java.security.cert.CertificateException
certificate
- the certificate to convertjava.security.cert.CertificateException
- if there occurs an error while parsing the certificatepublic static AttributeCertificate[] convertToAttributeCertificateChain(java.security.cert.Certificate[] certificateChain) throws java.security.cert.CertificateException
certificateChain
- the array of certificates to convertjava.security.cert.CertificateException
- if there occurs an error while parsing the certificate chainpublic static AttributeCertificate convertToAttributeCertificate(java.security.cert.Certificate certificate) throws java.security.cert.CertificateException
certificate
- the certificate to convertjava.security.cert.CertificateException
- if there occurs an error while parsing the certificatepublic static X509Certificate[] arrangeCertificateChain(X509Certificate[] certArray, boolean topdown)
null
is
returned. This method builds the chain by checking issuer and subject and
testing the signatures.certArray
- an array of certificatestopdown
- if true the certificate chain will be returned with the
top-CA-certificate at index 0, otherwise with the
top-CA-certificate at the array's last index.null
if the array
did not contain a certificate chain.public static X509Certificate[] createCertificateChain(X509Certificate userCertificate, java.security.cert.Certificate[] certs) throws java.security.cert.CertificateException
userCertificate
this method tries to build a certificate chain
from the certs contained in the unsorted certs
array. If none
of the certificates of the certs
array does belong to the
certificate chain of the userCertificate
, the chain returned
by this method will consist of one element (the user certificate itself)
only.
userCertificate
- The user certificate.certs
- A list of assorted certificates which may be part of the chain.certs
arrayjava.security.cert.CertificateException
- if a certificate parsing error occurspublic static X509Certificate[] readCertificateChain(java.io.InputStream is) throws java.io.IOException
is
- the inputstream supplying the certificatesjava.io.IOException
- if an error occurs while reading/parsing the chainpublic static AttributeCertificate[] readAttributeCertificateChain(java.io.InputStream is) throws java.io.IOException
is
- the inputstream supplying the certificatesjava.io.IOException
- if an error occurs while reading/parsing the chainpublic static X509CRL[] readCRLChain(java.io.InputStream is) throws java.io.IOException
is
- the inputstream supplying the crlsjava.io.IOException
- if an error occurs while reading/parsing the chainpublic static ACRL[] readACRLChain(java.io.InputStream is) throws java.io.IOException
is
- the inputstream supplying the crlsjava.io.IOException
- if an error occurs while reading/parsing the chainpublic static X509Certificate[] decodePkiPath(byte[] pkiPath) throws java.security.cert.CertificateException
PkiPath ::= SEQUENCE OF CertificateNote that the certificates in a PKI path are ordered in a way that the certificate at index i has issued the certificate at index i+1. If you need the certificates in reversed order, you may use method
arrangeCertificateChain
to reorder the certificate array parsed from the
pki path:
// the DER encoded PKI path byte[] pkipath = ...; // parse the certificates from the pki path X509Certificate[] certs = Util.getCertificates(pkipath); // reorder (if required): X509Certificate[] newCerts = arrangeCertificateChain(certs, false);
pkiPath
- the DER encoded PKI path holding a SEQUENCE of X.509 certificatesjava.security.cert.CertificateException
- if the certificates cannot be parsed from the PKI pathpublic static X509Certificate[] readPkiPath(java.io.InputStream in) throws java.security.cert.CertificateException, java.io.IOException
PkiPath ::= SEQUENCE OF CertificateNote that the certificates in a PKI path are ordered in a way that the certificate at index i has issued the certificate at index i+1. If you need the certificates in reversed order, you may use method
arrangeCertificateChain
to reorder the certificate array parsed from the
pki path:
// the stream from which to read the DER encoded PKI path InputStream in = ...; // parse the certificates from the pki path X509Certificate[] certs = Util.getCertificates(in); // reorder (if required): X509Certificate[] newCerts = arrangeCertificateChain(certs, false);
in
- the stream from which to read the DER encoded PKI path holding a
SEQUENCE of X.509 certificatesjava.security.cert.CertificateException
- if the certificates cannot be parsed from the PKI pathjava.io.IOException
- if an error occurs when reading from the streampublic static byte[] encodeAsPkiPath(X509Certificate[] certificates, boolean sort) throws java.security.cert.CertificateException
PkiPath ::= SEQUENCE OF CertificateNote that the certificates in a PKI path are ordered in a way that the certificate at index i has issued the certificate at index i+1. When calling this method, you may supply an already ordered array of certificates, or you may set the
sort
flag to
true
so that the certificates are ordered by this method:
// the certificates to be encoded as pki path X509Certificate[] certificates = ...; // get the DER encoded PKI path byte[] pkipath = Util.getPkiPath(certificates, true);
certificates
- the certificates to be encoded as pki path (all the given
certificates have to belong to the same path)sort
- whether to sort the certificates before building the pki pathjava.security.cert.CertificateException
- if the pki path cannot be built because of an sorting or
encoding problempublic void writePkiPath(X509Certificate[] certificates, boolean sort, java.io.OutputStream os) throws java.security.cert.CertificateException, java.io.IOException
PkiPath ::= SEQUENCE OF CertificateNote that the certificates in a PKI path are ordered in a way that the certificate at index i has issued the certificate at index i+1. When calling this method, you may supply an already ordered array of certificates, or you may set the
sort
flag to
true
so that the certificates are ordered by this method:
// the certificates to be encoded as pki path X509Certificate[] certificates = ...; OutputStream os = ...; Util.writePkiPath(certificates, true, os);
certificates
- the certificates to be encoded as pki path (all the given
certificates have to belong to the same path)sort
- whether to sort the certificates before building the pki pathos
- the outputstream to which to write the DER encoded pik pathjava.security.cert.CertificateException
- if the pki path cannot be built because of an sorting or
encoding problemjava.io.IOException
- if an error occurs when writing to the streampublic static int getJVMDataMode()
public static byte[] getUTF8EncodingFromString(java.lang.String str) throws UTF8CodingException
str
- the string to be encodedUTF8CodingException
- if an coding error occurspublic static byte[] getUTF8EncodingFromCharArray(char[] str) throws UTF8CodingException
str
- the char array to be encodedUTF8CodingException
- if an coding error occurspublic static char[] getCharsFromUTF8Encoding(byte[] enc) throws UTF8CodingException
enc
- the UTF-8 encoding as byte arrayUTF8CodingException
- if an error occurs during the decoding processpublic static char[] getCharsFromUTF8Encoding(byte[] enc, boolean skipInvalidCharacters) throws UTF8CodingException
enc
- the UTF-8 encoding as byte arrayskipInvalidCharacters
- whether to skip invalid encoded characters (default:
false; invalid characters cause a UTF8CodingException)
UTF8CodingException
- if an error occurs during the decoding processpublic static java.lang.String getStringFromUTF8Encoding(byte[] enc) throws UTF8CodingException
enc
- the UTF-8 encoding as byte arrayUTF8CodingException
- if an error occurs during the decoding processpublic static java.lang.String getStringFromUTF8Encoding(byte[] enc, boolean skipInvalidCharacters) throws UTF8CodingException
enc
- the UTF-8 encoding as byte arrayskipInvalidCharacters
- whether to skip invalid encoded characters (default:
false; invalid characters cause a UTF8CodingException)
UTF8CodingException
- if an error occurs during the decoding processpublic static int getCharFromUTF8Array(int[] encoding) throws UTF8CodingException
Although this method actually only is used to parse an Unicode/UCS2 character from the given UTF-8 array, it also is able to parse an UCS4 character, and therefore returns a 32-but int rather than a 16-bit char. For UCS2 a cast to char may be made on the value returned by this method.
encoding
- the UTF-8 encoding as int arrayUTF8CodingException
- if an decoding error occurspublic static java.lang.String getRFC2253String(java.lang.String str) throws UTF8CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups. This implementation is also compliant with the updated standard RFC 4514, which obsoleted RFC 2253.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
str
- the string to be representedUTF8CodingException
- if an coding error occurspublic static java.lang.String getRFC2253String(java.lang.String str, boolean strictEscaping) throws UTF8CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups. This implementation is also compliant with the updated standard RFC 4514, which obsoleted RFC 2253.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
strictEscaping
is set to true
str
- the string to be representedstrictEscaping
- whether to escape non printable ASCII (< 0x21 or > 0x7e) and
non-ASCII characters by an hexadecimal representation of their
UTF-8 encodingUTF8CodingException
- if an coding error occurspublic static java.lang.String getRFC2253String(char[] str) throws UTF8CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups. This implementation is also compliant with the updated standard RFC 4514, which obsoleted RFC 2253.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
str
- the char array to be representedUTF8CodingException
- if an coding error occurspublic static java.lang.String getRFC2253String(char[] str, boolean strictEscaping) throws UTF8CodingException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups. This implementation is also compliant with the updated standard RFC 4514, which obsoleted RFC 2253.
The string representation returned by this method is based on the algorithm given in section 2.4 of RFC 2253 thereby applying the following escaping mechanisms:
strictEscaping
is set to true
str
- the char array to be representedstrictEscaping
- whether to escape non printable ASCII (< 0x21 or > 0x7e) and
non-ASCII characters by an hexadecimal representation of their
UTF-8 encodingUTF8CodingException
- if an coding error occurspublic static byte[] convertEndian32(byte[] in)
public static void setEncoding(java.lang.String encoding)
encoding
- the encoding to be usedpublic static java.lang.String toASCIIString(byte[] bytes, int ofs, int cnt)
public static java.lang.String toASCIIString(byte[] bytes)
public static byte[] toASCIIBytes(java.lang.String s)
public static java.io.BufferedReader getASCIIReader(java.io.InputStream in)
public static java.io.PrintWriter getASCIIWriter(java.io.OutputStream out)
public static java.io.PrintWriter getASCIIWriter(java.io.OutputStream out, boolean autoflush)
public static void compareTables(java.lang.String text, int[] T0, int[] T1)
public static void printTable(java.lang.String text, byte[] table)
public static void printTable(java.lang.String text, int[] table)
public static int calculateHashCode(byte[] value)
value
- the byte array for which a hash code shall be computedpublic static java.security.Key decodeKey(int keyType, java.lang.String keyAlgorithm, byte[] encodedKey) throws java.security.NoSuchAlgorithmException, java.security.InvalidKeyException
keyType
- the (Cipher) keyType (Cipher.SECRET_KEY, Cipher.PRIVATE_KEY
or Cipher.PUBLIC_KEY)keyAlgorithm
- the key algorithmencodedKey
- the encoded keyRawPrivateKey
or
RawPublicKey
is returnedjava.security.NoSuchAlgorithmException
- if no KeyFactory for the given keyAlgorithm
can be foundjava.security.InvalidKeyException
- if the key cannot be decodedpublic static RSAPublicKey getRSAPublicKey(java.security.Key key) throws java.security.InvalidKeyException
key
- the key object to be convertedjava.security.InvalidKeyException
- if the key is not a public RSA key or cannot be convertedpublic static RSAPrivateKey getRSAPrivateKey(java.security.Key key) throws java.security.InvalidKeyException
key
- the key object to be convertedjava.security.InvalidKeyException
- if the key is not a private RSA key or cannot be convertedpublic static int getKeyLength(java.security.PublicKey key)
key
- the public keypublic static int getKeyLength(java.security.PrivateKey key)
key
- the private keypublic static int getDigestLength(AlgorithmID hashAlgID)
hashAlgID
- the algorithm id of the hash algorithm for which to determine the
digest value lengthpublic static int getDigestLength(java.lang.String digestAlg)
digestAlg
- the (standard) name of the hash algorithm for which to determine
the digest value lengthpublic static void setSignatureParameters(java.security.Signature signature, java.security.spec.AlgorithmParameterSpec params, java.lang.String paramsName)
Signature.setParameter(AlgorithmParameterSpec paramSpec)
for
JDK versions > 1.2, and
Signature.setParameter(String param, Object value)
(via
reflection) for JDK 1.2.signature
- the Signature engine for which to set the parametersparams
- the parameters to be setparamsName
- the name for the parameters (for JDK 1.2)public static java.lang.String getRawCipherName(java.lang.String transformation)
public static java.lang.String printIndented(java.lang.String msg, boolean indentFirst)
msg
- the (multi line) message to be printedpublic static java.lang.String printIndented(java.lang.String msg, boolean indentFirst, java.lang.String indentToken)
msg
- the (multi line) message to be printedindentFirst
- whether to indent the first line or leave it unindentedindentToken
- the token which shall be printed in front of each linepublic static void printIndented(java.lang.String msg, boolean indentFirst, java.lang.StringBuffer buf)
msg
- the (multi line) message to be printedindentFirst
- whether to indent the first line or leave it unindentedbuf
- the StringBuffer to which to print the messagepublic static void printIndented(java.lang.String msg, boolean indentFirst, java.lang.String indentToken, java.lang.StringBuffer buf)
msg
- the (multi line) message to be printedindentFirst
- whether to indent the first line or leave it unindentedindentToken
- the token which shall be printed in front of each linebuf
- the StringBuffer to which to print the messagepublic static java.security.AlgorithmParameters getSignatureParameters(java.security.Signature signature)
Signature.getParameter(String param)
for JDK
versions < 1.4, and Signature.getParameters()
(via
reflection) for JDK versions >= 1.4.signature
- the Signature engine from which to get the parametespublic static RSAPssParameterSpec createRsaPssParameters(AlgorithmID hashAlgID) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
MGF1 will be used as mask generation function. The salt length value is set to the length of the output value of the hash algorithm.
hashAlgID
- the hash algorithm idjava.security.InvalidAlgorithmParameterException
- if the PSS parameters cannot be createdjava.security.NoSuchAlgorithmException
- if the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static RSAPssParameterSpec createRsaPssParameters(AlgorithmID hashAlgID, int saltLength) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
hashAlgID
- the hash algorithm idsaltLength
- the salt length (in number of bytes) to be used; if -1 the
output length of the hash algorithm is usedjava.security.InvalidAlgorithmParameterException
- if the PSS parameters cannot be createdjava.security.NoSuchAlgorithmException
- if the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static AlgorithmID createRsaPssAlgorithmID(AlgorithmID hashAlgID) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
MGF1 is used as mask generation function and the salt length value is set to the length of the output value of the hash algorithm.
hashAlgID
- the hash algorithm to be usedjava.security.InvalidAlgorithmParameterException
- if the PSS parameters cannot be created/setjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameters implementation
for RSA-PSS, or the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static AlgorithmID createRsaPssAlgorithmID(AlgorithmID hashAlgID, int saltLength) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
hashAlgID
- the hash algorithm to be usedsaltLength
- the salt length (in number of bytes) to be used; if -1 the
output length of the hash algorithm is usedjava.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/setjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameters implementation
for RSA-PSS, or the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static RSAOaepParameterSpec createRsaOaepParameters(AlgorithmID hashAlgID) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
MGF1 is used as mask generation function mask generation function, pSpecified as PSource algorithm and an empty string as label.
hashAlgID
- the hash algorithm to be usedjava.security.InvalidAlgorithmParameterException
- if the parameters cannot be createdjava.security.NoSuchAlgorithmException
- if the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static RSAOaepParameterSpec createRsaOaepParameters(AlgorithmID hashAlgID, AlgorithmID pSourceID, byte[] label) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
hashAlgID
- the hash algorithm to be usedpSourceID
- the PSource algorithmlabel
- the value of the PSource label parameterjava.security.InvalidAlgorithmParameterException
- if the parameters cannot be createdjava.security.NoSuchAlgorithmException
- if the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static AlgorithmID createRsaOaepAlgorithmID(AlgorithmID hashAlgID) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
MGF1 is used as mask generation function mask generation function, pSpecified as PSource algorithm and an empty string as label.
hashAlgID
- the hash algorithm to be usedjava.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/setjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameters implementation
for RSA-OAEP, or the given hash algorithm or the MGF1 mask
generation function is not supportedpublic static AlgorithmID createRsaOaepAlgorithmID(AlgorithmID hashAlgID, AlgorithmID pSourceID, byte[] label) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
hashAlgID
- the hash algorithm to be usedpSourceID
- the PSource algorithmlabel
- the value of the PSource label parameterjava.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/setjava.security.NoSuchAlgorithmException
- if there is no AlgorithmParameters implementation
for RSA-OAEP, or the given hash algorithm or the MGF1 mask
generation function is not supported