Class DigestUtil
- java.lang.Object
-
- org.wildfly.security.sasl.digest._private.DigestUtil
-
public final class DigestUtil extends Object
- Author:
- Peter Skopek.
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTH_METHODstatic StringHASH_algorithmstatic StringHMAC_algorithmstatic StringQOP_AUTHstatic StringQOP_AUTH_CONFstatic StringQOP_AUTH_INTstatic String[]QOP_VALUESstatic StringSECURITY_MARK
-
Constructor Summary
Constructors Constructor Description DigestUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]computeHMAC(byte[] kc, int sequenceNumber, Mac mac, byte[] message, int offset, int len)static byte[]convertToHexBytesWithLeftPadding(int input, int totalLength)Converts input to HEX and pad it from left with zeros to totalLength.static SecretKeycreate3desSecretKey(byte[] keyBits)Create 3des secret key according to http://www.cryptosys.net/3des.html.static SecretKeycreateDesSecretKey(byte[] keyBits)Create DES secret key according to http://www.cryptosys.net/3des.html.static intdecodeByteOrderedInteger(byte[] buf, int offset, int len)static byte[]digestResponse(MessageDigest messageDigest, byte[] H_A1, byte[] nonce, int nonce_count, byte[] cnonce, String authzid, String qop, String digest_uri, boolean auth)Method to produce digest-response: response-value = HEX( KD ( HEX(H(A1)), { nonce-value, ":" nc-value, ":", cnonce-value, ":", qop-value, ":", HEX(H(A2)) }))static byte[]H_A1(MessageDigest messageDigest, byte[] digest_urp, byte[] nonce, byte[] cnonce, String authzid, Charset responseCharset)Calculates H(A1).static voidintegerByteOrdered(int num, byte[] buf, int offset, int len)static StringmessageDigestAlgorithm(String digestAlgorithm)static StringpasswordAlgorithm(String digestAlgorithm)
-
-
-
Field Detail
-
QOP_AUTH
public static final String QOP_AUTH
- See Also:
- Constant Field Values
-
QOP_AUTH_INT
public static final String QOP_AUTH_INT
- See Also:
- Constant Field Values
-
QOP_AUTH_CONF
public static final String QOP_AUTH_CONF
- See Also:
- Constant Field Values
-
QOP_VALUES
public static final String[] QOP_VALUES
-
AUTH_METHOD
public static final String AUTH_METHOD
- See Also:
- Constant Field Values
-
SECURITY_MARK
public static final String SECURITY_MARK
- See Also:
- Constant Field Values
-
HASH_algorithm
public static final String HASH_algorithm
- See Also:
- Constant Field Values
-
HMAC_algorithm
public static final String HMAC_algorithm
- See Also:
- Constant Field Values
-
-
Method Detail
-
H_A1
public static byte[] H_A1(MessageDigest messageDigest, byte[] digest_urp, byte[] nonce, byte[] cnonce, String authzid, Charset responseCharset)
Calculates H(A1).- Parameters:
messageDigest-digest_urp-nonce-cnonce-authzid-responseCharset-- Returns:
-
digestResponse
public static byte[] digestResponse(MessageDigest messageDigest, byte[] H_A1, byte[] nonce, int nonce_count, byte[] cnonce, String authzid, String qop, String digest_uri, boolean auth)
Method to produce digest-response: response-value = HEX( KD ( HEX(H(A1)), { nonce-value, ":" nc-value, ":", cnonce-value, ":", qop-value, ":", HEX(H(A2)) }))
-
convertToHexBytesWithLeftPadding
public static byte[] convertToHexBytesWithLeftPadding(int input, int totalLength)Converts input to HEX and pad it from left with zeros to totalLength.- Parameters:
input- to be converted to HEXtotalLength- length of returned array of bytes- Returns:
-
computeHMAC
public static byte[] computeHMAC(byte[] kc, int sequenceNumber, Mac mac, byte[] message, int offset, int len) throws SaslException- Throws:
SaslException
-
integerByteOrdered
public static void integerByteOrdered(int num, byte[] buf, int offset, int len)
-
decodeByteOrderedInteger
public static int decodeByteOrderedInteger(byte[] buf, int offset, int len)
-
createDesSecretKey
public static SecretKey createDesSecretKey(byte[] keyBits) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException
Create DES secret key according to http://www.cryptosys.net/3des.html.- Parameters:
keyBits-- Returns:
- Throws:
NoSuchAlgorithmExceptionInvalidKeyExceptionInvalidKeySpecException
-
create3desSecretKey
public static SecretKey create3desSecretKey(byte[] keyBits) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException
Create 3des secret key according to http://www.cryptosys.net/3des.html.- Parameters:
keyBits-- Returns:
- Throws:
NoSuchAlgorithmExceptionInvalidKeyExceptionInvalidKeySpecException
-
-