|
||||||||||
PREV CLASS (src) NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.security.Util
Various security related utilities like MessageDigest factories, SecureRandom access, password hashing. This product includes software developed by Tom Wu and Eugene Jhong for the SRP Distribution (http://srp.stanford.edu/srp/).
Field Summary | |
static java.lang.String |
BASE16_ENCODING
|
static java.lang.String |
BASE64_ENCODING
|
Constructor Summary | |
Util()
|
Method Summary | |
static java.lang.Object |
accessSealedObject(java.lang.String cipherAlgorithm,
java.lang.Object key,
byte[] cipherIV,
java.lang.Object obj)
|
static byte[] |
calculatePasswordHash(java.lang.String username,
char[] password,
byte[] salt)
Cacluate the SRP RFC2945 password hash = H(salt | H(username | ':' | password)) where H = SHA secure hash. |
static byte[] |
calculateVerifier(java.lang.String username,
char[] password,
byte[] salt,
java.math.BigInteger N,
java.math.BigInteger g)
Calculate x = H(s | H(U | ':' | password)) verifier v = g^x % N described in RFC2945. |
static byte[] |
calculateVerifier(java.lang.String username,
char[] password,
byte[] salt,
byte[] Nb,
byte[] gb)
Calculate x = H(s | H(U | ':' | password)) verifier v = g^x % N described in RFC2945. |
static java.security.MessageDigest |
copy(java.security.MessageDigest md)
|
static java.lang.Object |
createCipher(java.lang.String cipherAlgorithm)
|
static java.lang.String |
createPasswordHash(java.lang.String hashAlgorithm,
java.lang.String hashEncoding,
java.lang.String hashCharset,
java.lang.String username,
java.lang.String password)
Calculate a password hash using a MessageDigest. |
static java.lang.String |
createPasswordHash(java.lang.String hashAlgorithm,
java.lang.String hashEncoding,
java.lang.String hashCharset,
java.lang.String username,
java.lang.String password,
DigestCallback (src) callback)
Calculate a password hash using a MessageDigest. |
static java.lang.Object |
createSealedObject(java.lang.String cipherAlgorithm,
java.lang.Object key,
byte[] cipherIV,
java.io.Serializable data)
|
static java.lang.Object |
createSecretKey(java.lang.String cipherAlgorithm,
java.lang.Object key)
Use reflection to create a javax.crypto.spec.SecretKeySpec to avoid an explicit reference to SecretKeySpec so that the JCE is not needed unless the SRP parameters indicate that encryption is needed. |
static java.lang.String |
encodeBase16(byte[] bytes)
Hex encoding of hashes, as used by Catalina. |
static java.lang.String |
encodeBase64(byte[] bytes)
BASE64 encoder implementation. |
static byte[] |
fromb64(java.lang.String str)
|
static byte[] |
generateSeed(int numBytes)
Returns the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself. |
static java.util.Random |
getPRNG()
|
static boolean |
hasUnlimitedCrypto()
From Appendix E of the JCE ref guide, the xaximum key size allowed by the "Strong" jurisdiction policy files allows a maximum Blowfish cipher size of 128 bits. |
static void |
init()
|
static void |
init(byte[] prngSeed)
|
static java.security.MessageDigest |
newDigest()
|
static void |
nextBytes(byte[] bytes)
Generates random bytes and places them into a user-supplied byte array. |
static double |
nextDouble()
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence. |
static long |
nextLong()
Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence. |
static byte[] |
sessionKeyHash(byte[] number)
Perform an interleaved even-odd hash on the byte string |
static java.lang.String |
tob64(byte[] buffer)
|
static byte[] |
trim(byte[] in)
Treat the input as the MSB representation of a number, and lop off leading zero elements. |
static byte[] |
xor(byte[] b1,
byte[] b2,
int length)
|
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 BASE64_ENCODING
public static final java.lang.String BASE16_ENCODING
Constructor Detail |
public Util()
Method Detail |
public static void init() throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static void init(byte[] prngSeed) throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException
public static java.security.MessageDigest newDigest()
public static java.security.MessageDigest copy(java.security.MessageDigest md)
public static java.util.Random getPRNG()
public static double nextDouble()
public static long nextLong()
public static void nextBytes(byte[] bytes)
public static byte[] generateSeed(int numBytes)
public static byte[] calculatePasswordHash(java.lang.String username, char[] password, byte[] salt)
public static byte[] calculateVerifier(java.lang.String username, char[] password, byte[] salt, byte[] Nb, byte[] gb)
public static byte[] calculateVerifier(java.lang.String username, char[] password, byte[] salt, java.math.BigInteger N, java.math.BigInteger g)
public static byte[] sessionKeyHash(byte[] number)
public static byte[] trim(byte[] in)
public static byte[] xor(byte[] b1, byte[] b2, int length)
public static java.lang.String encodeBase16(byte[] bytes)
public static java.lang.String encodeBase64(byte[] bytes)
public static java.lang.String createPasswordHash(java.lang.String hashAlgorithm, java.lang.String hashEncoding, java.lang.String hashCharset, java.lang.String username, java.lang.String password)
hashAlgorithm
- - the MessageDigest algorithm namehashEncoding
- - either base64 or hex to specify the type of
encoding the MessageDigest as a string.hashCharset
- - the charset used to create the byte[] passed to the
MessageDigestfrom the password String. If null the platform default is
used.username
- - ignored in default versionpassword
- - the password string to be hashed
public static java.lang.String createPasswordHash(java.lang.String hashAlgorithm, java.lang.String hashEncoding, java.lang.String hashCharset, java.lang.String username, java.lang.String password, DigestCallback (src) callback)
hashAlgorithm
- - the MessageDigest algorithm namehashEncoding
- - either base64 or hex to specify the type of
encoding the MessageDigest as a string.hashCharset
- - the charset used to create the byte[] passed to the
MessageDigestfrom the password String. If null the platform default is
used.username
- - ignored in default versionpassword
- - the password string to be hashedcallback
- - the callback used to allow customization of the hash
to occur. The preDigest method is called before the password is added
and the postDigest method is called after the password has been added.
public static java.lang.String tob64(byte[] buffer)
public static byte[] fromb64(java.lang.String str) throws java.lang.NumberFormatException
java.lang.NumberFormatException
public static boolean hasUnlimitedCrypto()
public static java.lang.Object createSecretKey(java.lang.String cipherAlgorithm, java.lang.Object key) throws java.security.KeyException
java.security.KeyException
public static java.lang.Object createCipher(java.lang.String cipherAlgorithm) throws java.security.GeneralSecurityException
cipherAlgorithm
-
java.security.GeneralSecurityException
public static java.lang.Object createSealedObject(java.lang.String cipherAlgorithm, java.lang.Object key, byte[] cipherIV, java.io.Serializable data) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
public static java.lang.Object accessSealedObject(java.lang.String cipherAlgorithm, java.lang.Object key, byte[] cipherIV, java.lang.Object obj) throws java.security.GeneralSecurityException
java.security.GeneralSecurityException
|
||||||||||
PREV CLASS (src) NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |