Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## rice.p2p.util
Class SecurityUtils

    java.lang.Object
      rice.p2p.util.SecurityUtils

public class SecurityUtils
extends java.lang.Object

This class contains a large number of static methods for performing security-related primitives, such as encrypt, decrypt, etc...

Version:
  $Id: SecurityUtils.java 2514 2005-05-26 22:14:24Z amislove $
Author:
  amislove

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` DESCRIBE THE FIELD
`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_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 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 java.lang.Object` | `deserialize(byte[] data)` Utility method for deserializing an object from a byte[]
`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, int offset, int length)` Utility method for encrypting a block of data with symmetric encryption.
`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

### ASYMMETRIC_ALGORITHM

    public static final java.lang.String ASYMMETRIC_ALGORITHM

  The name of the asymmetric cipher to use.

  See Also:
    Constant Field Values

### DEPRECATED_ASYMMETRIC_ALGORITHM

    public static final java.lang.String DEPRECATED_ASYMMETRIC_ALGORITHM

  DESCRIBE THE FIELD

  See Also:
    Constant Field Values

### SYMMETRIC_ALGORITHM

    public static final java.lang.String SYMMETRIC_ALGORITHM

  The name of the symmetric cipher to use.

  See Also:
    Constant Field Values

### ASYMMETRIC_GENERATOR

    public static final java.lang.String ASYMMETRIC_GENERATOR

  The name of the asymmetric generator to use.

  See Also:
    Constant Field Values

### SYMMETRIC_GENERATOR

    public static final java.lang.String SYMMETRIC_GENERATOR

  The name of the symmetric cipher to use.

  See Also:
    Constant Field Values

### SIGNATURE_ALGORITHM

    public static final java.lang.String SIGNATURE_ALGORITHM

  The name of the signature algorithm to use.

  See Also:
    Constant Field Values

### SYMMETRIC_KEY_LENGTH

    public static final int SYMMETRIC_KEY_LENGTH

  The length of the symmetric keys

  See Also:
    Constant Field Values

### HASH_ALGORITHM

    public static final java.lang.String HASH_ALGORITHM

  The name of the hash function.

  See Also:
    Constant Field Values

### HMAC_ALGORITHM

    public static final java.lang.String HMAC_ALGORITHM

  The name of the hmac function.

  See Also:
    Constant Field Values

### APOP_ALGORITHM

    public static final java.lang.String APOP_ALGORITHM

  The name of the apop function.

  See Also:
    Constant Field Values

### HMAC_KEY_LENGTH

    public static final int HMAC_KEY_LENGTH

  The length of hmac keys

  See Also:
    Constant Field Values

### HMAC_IPAD_BYTE

    public static final byte HMAC_IPAD_BYTE

  The ipad of hmac keys, as defined in RFC 2195

  See Also:
    Constant Field Values

### HMAC_OPAD_BYTE

    public static final byte HMAC_OPAD_BYTE

  The opad of hmac keys, as defined in RFC 2195

  See Also:
    Constant Field Values

### HMAC_IPAD

    public static final byte[] HMAC_IPAD

  The ipad byte array for use in hmac

### HMAC_OPAD

    public static final byte[] HMAC_OPAD

  The opad byte array for use in hmac

Method Detail

### serialize

    public static byte[] serialize(java.lang.Object o)
                            throws java.io.IOException

  Utility method for serializing an object to a byte[].

  Parameters:
    `o` - The object to serialize
  Returns:
    The byte[] of the object
  Throws:
    `java.io.IOException` - If serialization does not happen properly

### deserialize

    public static java.lang.Object deserialize(byte[] data)
                                        throws java.io.IOException,
                                               java.lang.ClassNotFoundException

  Utility method for deserializing an object from a byte[]

  Parameters:
    `data` - The data to deserialize
  Returns:
    The object
  Throws:
    `java.io.IOException` - If deserialization does not happen properly
    `java.lang.ClassNotFoundException` - If the deserialized class is not found

### hash

    public static byte[] hash(byte[] input)
                       throws java.lang.SecurityException

  Utility method for determining the hash of a byte[] using a secure hashing algorithm.

  Parameters:
    `input` - The input
  Returns:
    The hash value
  Throws:
    `java.lang.SecurityException` - If the hashing does not happen properly

### apop

    public static byte[] apop(byte[] challenge,
                              byte[] password)
                       throws java.lang.SecurityException

  Utility method for determining the apop of a challenge and password using a secure hashing algorithm.

  Parameters:
    `password` - The password
    `challenge` - The challengr
  Returns:
    The hash value
  Throws:
    `java.lang.SecurityException` - If the hashing does not happen properly

### hmac

    public static byte[] hmac(byte[] key,
                              byte[] text)
                       throws java.lang.SecurityException

  Utility method for determining the hmac of a byte[] and key using a secure hashing algorithm.

  Parameters:
    `text` - The text
    `key` - The key
  Returns:
    The hmac value
  Throws:
    `java.lang.SecurityException` - If the hmacing does not happen properly

### encryptSymmetric

    public static byte[] encryptSymmetric(byte[] data,
                                          byte[] key)
                                   throws java.lang.SecurityException

  Utility method for encrypting a block of data with symmetric encryption.

  Parameters:
    `data` - The data
    `key` - The key
  Returns:
    The ciphertext
  Throws:
    `java.lang.SecurityException` - If the encryption does not happen properly

### encryptSymmetric

    public static byte[] encryptSymmetric(byte[] data,
                                          byte[] key,
                                          int offset,
                                          int length)
                                   throws java.lang.SecurityException

  Utility method for encrypting a block of data with symmetric encryption.

  Parameters:
    `data` - The data
    `key` - The key
    `offset` - The offset into the data
    `length` - The length of data to write
  Returns:
    The ciphertext
  Throws:
    `java.lang.SecurityException` - If the encryption does not happen properly

### decryptSymmetric

    public static byte[] decryptSymmetric(byte[] data,
                                          byte[] key)
                                   throws java.lang.SecurityException

  Utility method for decrypting some data with symmetric encryption.

  Parameters:
    `data` - The data to decrypt
    `key` - The key
  Returns:
    The decrypted data
  Throws:
    `java.lang.SecurityException` - If the decryption does not happen properly

### sign

    public static byte[] sign(byte[] data,
                              java.security.PrivateKey key)
                       throws java.lang.SecurityException

  Utility method for signing a block of data with the a private key

  Parameters:
    `data` - The data
    `key` - The key to use to sign
  Returns:
    The signature
  Throws:
    `java.lang.SecurityException` - If the signing does not happen properly

### verify

    public static boolean verify(byte[] data,
                                 byte[] sig,
                                 java.security.PublicKey key)
                          throws java.lang.SecurityException

  Utility method for verifying a signature

  Parameters:
    `data` - The data to verify
    `sig` - The proposed signature
    `key` - The key to verify against
  Returns:
    Whether or not the sig matches.
  Throws:
    `java.lang.SecurityException` - If the verification does not happen properly

### encryptAsymmetric

    public static byte[] encryptAsymmetric(byte[] data,
                                           java.security.PublicKey key)
                                    throws java.lang.SecurityException

  Encrypts the given byte[] using the provided public key. TO DO: Check length of input

  Parameters:
    `data` - The data to encrypt
    `key` - The key to encrypt with
  Returns:
    The encrypted data
  Throws:
    `java.lang.SecurityException` - If the encryption does not happen properly

### decryptAsymmetric

    public static byte[] decryptAsymmetric(byte[] data,
                                           java.security.PrivateKey key)
                                    throws java.lang.SecurityException

  Decrypts the given byte[] using the provided private key. TO DO: Check length of input

  Parameters:
    `data` - The data to decrypt
    `key` - The private key to use
  Returns:
    The decrypted data
  Throws:
    `java.lang.SecurityException` - If the decryption does not happen properly

### generateKeySymmetric

    public static byte[] generateKeySymmetric()

  Utility method which will generate a non-weak DES key for applications to use.

  Returns:
    A new, random DES key

### generateKeyAsymmetric

    public static java.security.KeyPair generateKeyAsymmetric()

  Utility method which will generate a non-weak DES key for applications to use.

  Returns:
    A new, random DES key

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Rice Pastry API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2005 - Rice Pastry.