|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rice.p2p.util.SecurityUtils
public class SecurityUtils
This class contains a large number of static methods for performing security-related primitives, such as encrypt, decrypt, etc...
Field Summary | |
---|---|
static java.lang.String |
APOP_ALGORITHM
The name of the apop function. |
static java.lang.String |
ASYMMETRIC_ALGORITHM
The name of the asymmetric cipher to use. |
static java.lang.String |
ASYMMETRIC_GENERATOR
The name of the asymmetric generator to use. |
static java.lang.String |
DEPRECATED_ASYMMETRIC_ALGORITHM
|
static java.lang.String |
HASH_ALGORITHM
The name of the hash function. |
static java.lang.String |
HMAC_ALGORITHM
The name of the hmac function. |
static byte[] |
HMAC_IPAD
The ipad byte array for use in hmac |
static byte |
HMAC_IPAD_BYTE
The ipad of hmac keys, as defined in RFC 2195 |
static int |
HMAC_KEY_LENGTH
The length of hmac keys |
static byte[] |
HMAC_OPAD
The opad byte array for use in hmac |
static byte |
HMAC_OPAD_BYTE
The opad of hmac keys, as defined in RFC 2195 |
static java.lang.String |
SIGNATURE_ALGORITHM
The name of the signature algorithm to use. |
static java.lang.String |
SYMMETRIC_ALGORITHM
The name of the symmetric cipher to use. |
static java.lang.String |
SYMMETRIC_GENERATOR
The name of the symmetric cipher to use. |
static int |
SYMMETRIC_IV_LENGTH
The length of the symmetric keys |
static int |
SYMMETRIC_KEY_LENGTH
The length of the symmetric keys |
Method Summary | |
---|---|
static byte[] |
apop(byte[] challenge,
byte[] password)
Utility method for determining the apop of a challenge and password using a secure hashing algorithm. |
static java.security.PrivateKey |
decodePrivateKey(byte[] data)
Utility method which will decode a previously encoded private key |
static java.security.PublicKey |
decodePublicKey(byte[] data)
Utility method which will decode a previously encoded public key |
static byte[] |
decryptAsymmetric(byte[] data,
java.security.PrivateKey key)
Decrypts the given byte[] using the provided private key. |
static byte[] |
decryptSymmetric(byte[] data,
byte[] key)
Utility method for decrypting some data with symmetric encryption. |
static byte[] |
decryptSymmetric(byte[] data,
byte[] key,
byte[] iv)
Utility method for decrypting some data with symmetric encryption. |
static java.lang.Object |
deserialize(byte[] data)
Utility method for deserializing an object from a byte[] |
static byte[] |
encodePrivateKey(java.security.PrivateKey key)
Utility method which will encode a private key |
static byte[] |
encodePublicKey(java.security.PublicKey key)
Utility method which will encode a public key |
static byte[] |
encryptAsymmetric(byte[] data,
java.security.PublicKey key)
Encrypts the given byte[] using the provided public key. |
static byte[] |
encryptSymmetric(byte[] data,
byte[] key)
Utility method for encrypting a block of data with symmetric encryption. |
static byte[] |
encryptSymmetric(byte[] data,
byte[] key,
byte[] iv)
Utility method for encrypting a block of data with symmetric encryption. |
static byte[] |
encryptSymmetric(byte[] data,
byte[] key,
int offset,
int length)
Utility method for encrypting a block of data with symmetric encryption. |
static byte[] |
encryptSymmetric(byte[] data,
byte[] key,
int offset,
int length,
byte[] iv)
Utility method for encrypting a block of data with symmetric encryption. |
static byte[] |
generateIVSymmetric()
Utility method which will generate a random intialization vector for applications to use. |
static java.security.KeyPair |
generateKeyAsymmetric()
Utility method which will generate a non-weak DES key for applications to use. |
static byte[] |
generateKeySymmetric()
Utility method which will generate a non-weak DES key for applications to use. |
static byte[] |
hash(byte[] input)
Utility method for determining the hash of a byte[] using a secure hashing algorithm. |
static byte[] |
hmac(byte[] key,
byte[] text)
Utility method for determining the hmac of a byte[] and key using a secure hashing algorithm. |
static byte[] |
serialize(java.lang.Object o)
Utility method for serializing an object to a byte[]. |
static byte[] |
sign(byte[] data,
java.security.PrivateKey key)
Utility method for signing a block of data with the a private key |
static boolean |
verify(byte[] data,
byte[] sig,
java.security.PublicKey key)
Utility method for verifying a signature |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ASYMMETRIC_ALGORITHM
public static final java.lang.String DEPRECATED_ASYMMETRIC_ALGORITHM
public static final java.lang.String SYMMETRIC_ALGORITHM
public static final java.lang.String ASYMMETRIC_GENERATOR
public static final java.lang.String SYMMETRIC_GENERATOR
public static final java.lang.String SIGNATURE_ALGORITHM
public static final int SYMMETRIC_KEY_LENGTH
public static final int SYMMETRIC_IV_LENGTH
public static final java.lang.String HASH_ALGORITHM
public static final java.lang.String HMAC_ALGORITHM
public static final java.lang.String APOP_ALGORITHM
public static final int HMAC_KEY_LENGTH
public static final byte HMAC_IPAD_BYTE
public static final byte HMAC_OPAD_BYTE
public static final byte[] HMAC_IPAD
public static final byte[] HMAC_OPAD
Method Detail |
---|
public static byte[] serialize(java.lang.Object o) throws java.io.IOException
o
- The object to serialize
java.io.IOException
- If serialization does not happen properlypublic static java.lang.Object deserialize(byte[] data) throws java.io.IOException, java.lang.ClassNotFoundException
data
- The data to deserialize
java.io.IOException
- If deserialization does not happen properly
java.lang.ClassNotFoundException
- If the deserialized class is not foundpublic static byte[] hash(byte[] input) throws java.lang.SecurityException
input
- The input
java.lang.SecurityException
- If the hashing does not happen properlypublic static byte[] apop(byte[] challenge, byte[] password) throws java.lang.SecurityException
password
- The passwordchallenge
- The challengr
java.lang.SecurityException
- If the hashing does not happen properlypublic static byte[] hmac(byte[] key, byte[] text) throws java.lang.SecurityException
text
- The textkey
- The key
java.lang.SecurityException
- If the hmacing does not happen properlypublic static byte[] encryptSymmetric(byte[] data, byte[] key) throws java.lang.SecurityException
data
- The datakey
- The key
java.lang.SecurityException
- If the encryption does not happen properlypublic static byte[] encryptSymmetric(byte[] data, byte[] key, byte[] iv) throws java.lang.SecurityException
data
- The datakey
- The keyiv
- The initialization vector
java.lang.SecurityException
- If the encryption does not happen properlypublic static byte[] encryptSymmetric(byte[] data, byte[] key, int offset, int length) throws java.lang.SecurityException
data
- The datakey
- The keyoffset
- The offset into the datalength
- The length of data to writeiv
- The initialization vector
java.lang.SecurityException
- If the encryption does not happen properlypublic static byte[] encryptSymmetric(byte[] data, byte[] key, int offset, int length, byte[] iv) throws java.lang.SecurityException
data
- The datakey
- The keyoffset
- The offset into the datalength
- The length of data to writeiv
- The initialization vector
java.lang.SecurityException
- If the encryption does not happen properlypublic static byte[] decryptSymmetric(byte[] data, byte[] key) throws java.lang.SecurityException
data
- The data to decryptkey
- The key
java.lang.SecurityException
- If the decryption does not happen properlypublic static byte[] decryptSymmetric(byte[] data, byte[] key, byte[] iv) throws java.lang.SecurityException
data
- The data to decryptkey
- The keyiv
- The initialization vector
java.lang.SecurityException
- If the decryption does not happen properlypublic static byte[] sign(byte[] data, java.security.PrivateKey key) throws java.lang.SecurityException
data
- The datakey
- The key to use to sign
java.lang.SecurityException
- If the signing does not happen properlypublic static boolean verify(byte[] data, byte[] sig, java.security.PublicKey key) throws java.lang.SecurityException
data
- The data to verifysig
- The proposed signaturekey
- The key to verify against
java.lang.SecurityException
- If the verification does not happen properlypublic static byte[] encryptAsymmetric(byte[] data, java.security.PublicKey key) throws java.lang.SecurityException
data
- The data to encryptkey
- The key to encrypt with
java.lang.SecurityException
- If the encryption does not happen properlypublic static byte[] decryptAsymmetric(byte[] data, java.security.PrivateKey key) throws java.lang.SecurityException
data
- The data to decryptkey
- The private key to use
java.lang.SecurityException
- If the decryption does not happen properlypublic static byte[] generateKeySymmetric()
public static byte[] encodePublicKey(java.security.PublicKey key)
key
- The key to encode
public static java.security.PublicKey decodePublicKey(byte[] data) throws java.lang.SecurityException
data
- The previously encoded key
java.lang.SecurityException
public static byte[] encodePrivateKey(java.security.PrivateKey key)
key
- The key to encode
public static java.security.PrivateKey decodePrivateKey(byte[] data) throws java.lang.SecurityException
data
- The previously encoded key
java.lang.SecurityException
public static byte[] generateIVSymmetric()
public static java.security.KeyPair generateKeyAsymmetric()
|
Rice Pastry API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |