|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.Utils
public class Utils
Some basic utility methods.
Method Summary | |
---|---|
static long |
copy(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 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 AlgorithmID |
createOaepAlgorithmID(AlgorithmID hashAlgID)
Creates an RSA-OAEP AlgorithmID for the given hash algorithm. |
static AlgorithmID |
createOaepAlgorithmID(AlgorithmID hashAlgID,
AlgorithmID pSourceID,
byte[] label)
Creates an RSA-OAEP AlgorithmID with the supplied parameters (hash algorithm id, PSource algorithm and label). |
static AlgorithmID |
createPssAlgorithmID(AlgorithmID hashAlgID)
Creates an RSA-PSS AlgorithmID for the given hash algorithm. |
static AlgorithmID |
createPssAlgorithmID(AlgorithmID hashID,
int saltLength)
Creates an RSA-PSS AlgorithmID with the supplied parameters (hash algorithm id and salt length). |
static double |
getIaikProviderVersion()
Gets the version number of the IAIK-JCE provider used for this demos. |
static int |
getShakeOutputLen(AlgorithmID shakeID)
Gets the value of the output length parameter of the given SHAKE-LEN Extendable Output Function (XOF) algorithm identifier id as specified by NIST FIPS PUB 202. |
static boolean |
isClassAvailable(java.lang.String className)
Check if the class with the specified name is available |
static SigningCertificate |
makeSigningCertificate(java.security.cert.Certificate[] certs,
PolicyInformation[] policies,
boolean includeIssuerSerial)
Creates an ESS SigningCertificate for the given X.509 certificates and policy informations. |
static SigningCertificate |
makeSigningCertificate(java.security.cert.Certificate[] certs,
PolicyInformation[] policies,
boolean includeIssuerSerial,
SecurityProvider securityProvider)
Creates an ESS SigningCertificate for the given X.509 certificates and policy informations. |
static SigningCertificate |
makeSigningCertificate(ESSCertID[] certIDs,
PolicyInformation[] policies)
Creates an ESS SigningCertificate for the given certIDs and policy informations. |
static SigningCertificateV2 |
makeSigningCertificateV2(java.security.cert.Certificate[] certs,
AlgorithmID hashAlgorithm,
PolicyInformation[] policies,
boolean includeIssuerSerial)
Creates an ESS SigningCertificateV2 for the given X.509 certificates and policy informations. |
static SigningCertificateV2 |
makeSigningCertificateV2(java.security.cert.Certificate[] certs,
AlgorithmID hashAlgorithm,
PolicyInformation[] policies,
boolean includeIssuerSerial,
SecurityProvider securityProvider)
Creates an ESS SigningCertificateV2 for the given X.509 certificates and policy informations. |
static SigningCertificateV2 |
makeSigningCertificateV2(ESSCertIDv2[] certIDs,
PolicyInformation[] policies)
Creates an ESS SigningCertificateV2 for the given certIDs and policy informations. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SigningCertificate makeSigningCertificate(java.security.cert.Certificate[] certs, PolicyInformation[] policies, boolean includeIssuerSerial) throws CMSException
certs
- the certificates to be identifiedpolicies
- the PolicyInformation terms to be includedincludeIssuerSerial
- whether to set the issuerSerial field for
for the ESSCertIDs to be created
CMSException
public static SigningCertificate makeSigningCertificate(java.security.cert.Certificate[] certs, PolicyInformation[] policies, boolean includeIssuerSerial, SecurityProvider securityProvider) throws CMSException
certs
- the certificates to be identifiedpolicies
- the PolicyInformation terms to be includedincludeIssuerSerial
- whether to set the issuerSerial field for
for the ESSCertIDs to be createdsecurityProvider
- the SecurityProvider to be used to calculate an SHA-1
hash from the encoded certificates required for the ESSCertID
objects of the SigningCertificate by using the SecurityProvider
method getHash()
which may be overriden by an application, if required.
CMSException
public static SigningCertificate makeSigningCertificate(ESSCertID[] certIDs, PolicyInformation[] policies)
certIDs
- the ESSCertIDs to be includedpolicies
- the PolicyInformation terms to be included
public static SigningCertificateV2 makeSigningCertificateV2(java.security.cert.Certificate[] certs, AlgorithmID hashAlgorithm, PolicyInformation[] policies, boolean includeIssuerSerial) throws CMSException
certs
- the certificates to be identifiedhashAlgorithm
- the hash algorithm to be used for cert hash
calculation (default: SHA-256)policies
- the PolicyInformation terms to be includedincludeIssuerSerial
- whether to set the issuerSerial field for
for the ESSCertIDv2 objects to be created
CMSException
public static SigningCertificateV2 makeSigningCertificateV2(java.security.cert.Certificate[] certs, AlgorithmID hashAlgorithm, PolicyInformation[] policies, boolean includeIssuerSerial, SecurityProvider securityProvider) throws CMSException
certs
- the certificates to be identifiedhashAlgorithm
- the hash algorithm to be used for cert hash
calculation (default: SHA-256)policies
- the PolicyInformation terms to be includedincludeIssuerSerial
- whether to set the issuerSerial field for
for the ESSCertIDv2 objects to be createdsecurityProvider
- the SecurityProvider to be used to calculate the hash
values from the encoded certificates required for the ESSCertIDv2
objects of the SigningCertificateV2 by using the SecurityProvider
method getHash()
which may be overriden by an application, if required.
CMSException
public static SigningCertificateV2 makeSigningCertificateV2(ESSCertIDv2[] certIDs, PolicyInformation[] policies)
certIDs
- the ESSCertIDv2 objects to be includedpolicies
- the PolicyInformation terms to be included
public 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 long copy(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 java.lang.String printIndented(java.lang.String msg, boolean indentFirst)
msg
- the (multi line) message to be printed
public 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 line
public 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 boolean isClassAvailable(java.lang.String className)
className
- the name of the class to be checked for availability
true
if the class with the given name is available;
false
if it is not availablepublic static int getShakeOutputLen(AlgorithmID shakeID)
id-shake128-len OBJECT IDENTIFIER ::= { hashAlgs 17 } id-shake256-len OBJECT IDENTIFIER ::= { hashAlgs 18 } ShakeOutputLen ::= INTEGER -- Output length in bits Alg-SHAKE128-LEN ALGORITHM ::= { OID id-shake128-len PARMS ShakeOutputLen } Alg-SHAKE256-LEN ALGORITHM ::= { OID id-shake256-len PARMS ShakeOutputLen }
shakeID
- the SHAKE-LEN algorithm id
-1
if it is not set or
cannot be determined because the parameter is not an ASN.1 INTEGER or because
the given AlgorithmID does not present a id-shake128-len or id-shake256-len
algorithm idpublic static double getIaikProviderVersion()
public static AlgorithmID createPssAlgorithmID(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 used
java.security.InvalidAlgorithmParameterException
- if the PSS parameters cannot be created/set
java.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 createPssAlgorithmID(AlgorithmID hashID, int saltLength) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException
hashID
- the hash algorithm to be usedsaltLength
- the salt length to be used
java.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/set
java.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 createOaepAlgorithmID(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 used
java.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/set
java.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 createOaepAlgorithmID(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 parameter
java.security.InvalidAlgorithmParameterException
- if the parameters cannot be created/set
java.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
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |