|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.security.crypto.util.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 byte[] |
generateKeyID(PublicKey key) Generate public key identifier bytes to use, for example, in a SubjectKeyIDExtension or AuthorityKeyIDExtension . |
static byte[] |
getIV(AlgorithmIdentifier algID) |
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) Wraps a raw private key in a PrivateKeyInfo structure. |
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) Deprecated. Use the version of signASN1 which does not take a RandomBitsSource argument. |
static ASN1Sequence |
signatureAlgID(PrivateKey key) Deprecated. |
static ASN1Sequence |
subjectPublicKeyInfo(PublicKey pk) Wraps a raw public key in a SubjectPublicKeyInfo structure. |
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 set.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)
public static ASN1Sequence makeAlgID(ASN1ObjectID id)
public static ASN1Sequence signatureAlgID(PrivateKey key) throws java.io.IOException
java.io.IOException
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
signASN1
which does not take a RandomBitsSource
argument.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
|
Oracle Security Developer Tools Crypto Java API Reference 10g Release 2 (10.1.2.0.2) B15565-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |