|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.util.CryptoUtils
public class CryptoUtils
A set of utility functions for convenient access to certain cryptographic operations.
Constructor Summary | |
---|---|
CryptoUtils() |
Method Summary | |
---|---|
static boolean |
checkKeyParity(SymmetricKey key, int parity) Check the least significant bit of each key byte for the parity indicated -- 1 for odd parity or 0 for even parity. |
static PrivateKey |
fromJCEPrivateKey(java.security.PrivateKey jceKey1) Convert a JCE private Key to an OSDT private key |
static PublicKey |
fromJCEPublicKey(java.security.PublicKey jceKey1) Convert a JCE Public Key to an OSDT Public key |
static byte[] |
generateKeyID(PublicKey key) Generate public key identifier bytes to use, for example, in a SubjectKeyIDExtension or AuthorityKeyIDExtension . |
static javax.crypto.Cipher |
getCipherInstance(java.security.Key key, java.lang.String algo) |
static byte[] |
getIV(AlgorithmIdentifier algID) |
static java.security.spec.AlgorithmParameterSpec |
getOEPAlgoSpec(java.lang.String digestAlg, java.lang.String mgfName, java.security.spec.AlgorithmParameterSpec paramspec, javax.crypto.spec.PSource ps, java.security.Key key) |
static java.security.Signature |
getSignatureInstance(java.lang.String algo, java.security.Key key) |
static KeyPair |
inputKeyPair(java.io.InputStream is) Reads a key pair from the given input stream. |
static PrivateKey |
inputPrivateKey(java.io.File f) Reads a private key from the given file. |
static PrivateKey |
inputPrivateKey(java.io.InputStream is) Reads a private key from the given input stream. |
static PublicKey |
inputSPKI(ASN1Sequence s) Constructs a PublicKey from a SubjectPublicKeyInfo structure. |
static PublicKey |
inputSPKI(byte[] data) Constructs a PublicKey from the bytes of a DER-encoded SubjectPublicKeyInfo structure. |
static PublicKey |
inputSPKI(java.io.InputStream is) Constructs a PublicKey from the bytes of a DER-encoded SubjectPublicKeyInfo structure in the given input stream. |
static boolean |
isDesPossiblyWeakKey(SymmetricKey key) Determines whether or not a given DES key is considered "possibly weak". |
static boolean |
isDesSemiWeakKey(SymmetricKey key) Determines whether or not a given DES key is considered "semi-weak". |
static boolean |
isDesWeakKey(SymmetricKey key) Determines whether or not a given DES key is considered "weak". |
static ASN1Sequence |
makeAlgID(ASN1ObjectID id) Wraps an OID in an algorithm identifier with null parameters. |
static Signature |
makeSignature(PrivateKey signingKey) |
static Signature |
makeSignature(PublicKey verificationKey) |
static ASN1Sequence |
privateKeyInfo(PrivateKey pk) Deprecated. Use Key.getEncoded() instead. |
static void |
setKeyParity(SymmetricKey key, int parity) Set the least significant bit of each key byte so that it has the parity indicated -- 1 for odd parity or 0 for even parity. |
static byte[] |
sign(byte[] data, PrivateKey key) Signs the given data. |
static byte[] |
sign(byte[] data, PrivateKey key, RandomBitsSource rbs) Signs the given data. |
static ASN1Sequence |
signASN1(ASN1Object o, PrivateKey key) |
static ASN1Sequence |
signASN1(ASN1Object o, PrivateKey privateKey, RandomBitsSource rbs) |
static ASN1Sequence |
subjectPublicKeyInfo(PublicKey pk) Wraps a raw public key in a SubjectPublicKeyInfo structure. |
static java.security.PrivateKey |
toJCEPrivateKey(PrivateKey osdtKey1) Convert an OSDT crypto PrivateKey to a JCE private Key |
static java.security.PublicKey |
toJCEPublicKey(PublicKey osdtKey1) Convert an OSDT crypto PublicKey to a JCE Public Key |
static boolean |
verifySignature(PublicKey key, byte[] docBytes, byte[] sigBytes) Verifies a given signature for a document, given the public key. |
static boolean |
verifySignedASN1(ASN1Sequence s, PublicKey key) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CryptoUtils()
Method Detail |
---|
public static PublicKey inputSPKI(byte[] data) throws java.io.IOException
PublicKey
from the bytes of a DER-encoded SubjectPublicKeyInfo structure.java.io.IOException
public static PublicKey inputSPKI(java.io.InputStream is) throws java.io.IOException
PublicKey
from the bytes of a DER-encoded SubjectPublicKeyInfo structure in the given input stream.java.io.IOException
public static PublicKey inputSPKI(ASN1Sequence s) throws java.io.IOException
PublicKey
from a SubjectPublicKeyInfo structure.java.io.IOException
public static PrivateKey inputPrivateKey(java.io.File f) throws java.io.IOException
A oracle.security.crypto.core.PrivateKey
is returned, after any necessary key format transformations have been appled (e.g., from CDSA or PKCS#1 format).
f
- The file containing the encoded private key.java.io.IOException
public static PrivateKey inputPrivateKey(java.io.InputStream is) throws java.io.IOException
A oracle.security.crypto.core.PrivateKey
is returned, after any necessary key format transformations have been applied (e.g., from CDSA or PKCS#1 format).
is
- the input streamjava.io.IOException
public static KeyPair inputKeyPair(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static byte[] generateKeyID(PublicKey key)
SubjectKeyIDExtension
or AuthorityKeyIDExtension
.public static void setKeyParity(SymmetricKey key, int parity)
1
for odd parity or 0
for even parity. This applies primarily to DES and DES-EDE keys.key
- The key for which parity is to be set.parity
- 1
for odd parity or 0
for even parity.public static boolean checkKeyParity(SymmetricKey key, int parity)
1
for odd parity or 0
for even parity. This applies primarily to DES and DES-EDE keys.key
- The key for which parity is to be checked.parity
- 1
for odd parity or 0
for even parity.true
if each byte has the specified parity, otherwise false
public static boolean isDesWeakKey(SymmetricKey key)
public static boolean isDesSemiWeakKey(SymmetricKey key)
public static boolean isDesPossiblyWeakKey(SymmetricKey key)
public static ASN1Sequence subjectPublicKeyInfo(PublicKey pk)
public static ASN1Sequence privateKeyInfo(PrivateKey pk)
Key.getEncoded()
instead.public static ASN1Sequence makeAlgID(ASN1ObjectID id)
public static Signature makeSignature(PrivateKey signingKey) throws SignatureException
SignatureException
public static Signature makeSignature(PublicKey verificationKey) throws AuthenticationException
AuthenticationException
public static byte[] sign(byte[] data, PrivateKey key) throws SignatureException
SignatureException
public static byte[] sign(byte[] data, PrivateKey key, RandomBitsSource rbs) throws SignatureException
SignatureException
public static ASN1Sequence signASN1(ASN1Object o, PrivateKey key) throws SignatureException
SignatureException
public static ASN1Sequence signASN1(ASN1Object o, PrivateKey privateKey, RandomBitsSource rbs) throws SignatureException
SignatureException
public static boolean verifySignature(PublicKey key, byte[] docBytes, byte[] sigBytes) throws AuthenticationException
key
- the public key of the signerdocBytes
- the bytes of the documentsigBytes
- the bytes of the signatureAuthenticationException
- if signature verification could not be performed, e.g., if the public key uses an unsupported algorithmpublic static boolean verifySignedASN1(ASN1Sequence s, PublicKey key)
public static byte[] getIV(AlgorithmIdentifier algID) throws AlgorithmIdentifierException
AlgorithmIdentifierException
public static java.security.PrivateKey toJCEPrivateKey(PrivateKey osdtKey1)
osdtKey1
- the key to convertjava.lang.IllegalArgumentException
- if there was a problem with the keypublic static PrivateKey fromJCEPrivateKey(java.security.PrivateKey jceKey1)
jceKey1
- the key to convertjava.lang.IllegalArgumentException
- if there was a problem with the keypublic static java.security.PublicKey toJCEPublicKey(PublicKey osdtKey1)
osdtKey1
- the key to convertjava.lang.IllegalArgumentException
- if there was a problem with the keypublic static PublicKey fromJCEPublicKey(java.security.PublicKey jceKey1)
jceKey1
- the key to convertjava.lang.IllegalArgumentException
- if there was a problem with the keypublic static java.security.Signature getSignatureInstance(java.lang.String algo, java.security.Key key) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
public static javax.crypto.Cipher getCipherInstance(java.security.Key key, java.lang.String algo) throws javax.crypto.NoSuchPaddingException, java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
javax.crypto.NoSuchPaddingException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
public static java.security.spec.AlgorithmParameterSpec getOEPAlgoSpec(java.lang.String digestAlg, java.lang.String mgfName, java.security.spec.AlgorithmParameterSpec paramspec, javax.crypto.spec.PSource ps, java.security.Key key) throws java.lang.ClassNotFoundException, java.lang.SecurityException, java.lang.NoSuchMethodException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.NoSuchFieldException, java.lang.InstantiationException, java.lang.reflect.InvocationTargetException
java.lang.ClassNotFoundException
java.lang.SecurityException
java.lang.NoSuchMethodException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
java.lang.NoSuchFieldException
java.lang.InstantiationException
java.lang.reflect.InvocationTargetException
|
Oracle Security Developer Tools Crypto Java API Reference 11g (11.1.1) E10668-02 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |