public class DesStringToKey extends Object
Constructor and Description |
---|
DesStringToKey() |
Modifier and Type | Method and Description |
---|---|
protected byte[] |
calculateChecksum(byte[] data,
byte[] keyBytes)
Calculates the checksum as described in "String or Random-Data to
Key Transformation." An intermediate key is used to generate a DES CBC
"checksum" on the initial passphrase+salt.
|
protected byte[] |
characterEncodeString(String string)
Encodes string with UTF-8 encoding.
|
protected byte[] |
fanFold(byte[] paddedByteArray)
"The top bit of each octet (always zero if the password is plain
ASCII, as was assumed when the original specification was written) is
discarded, and the remaining seven bits of each octet form a
bitstring.
|
protected byte[] |
generateKey(String passPhrase)
Returns a DES symmetric key for the given input String.
|
protected int |
getBit(byte[] data,
int pos)
Gets a bit at a given position.
|
byte[] |
getKey(String passPhrase)
Returns a DES symmetric key for the given passphrase.
|
byte[] |
getKey(String password,
String realmName,
String userName)
Returns a DES symmetric key for the given input String components,
which will be concatenated in the order described in RFC's 1510 and 3961,
namely password+realm+username.
|
protected byte[] |
getStrongKey(byte[] secretKey)
If the secret key is weak, correct by exclusive OR'ing
with the constant 0xF0.
|
protected byte[] |
padString(byte[] encodedString)
Add padding to make an exact multiple of 8 bytes.
|
protected void |
setBit(byte[] data,
int pos,
int val)
Sets a bit at a given position.
|
protected byte[] |
setParity(byte[] in)
Set odd parity on an eight-byte array.
|
public DesStringToKey()
public byte[] getKey(String passPhrase)
passPhrase
- The passphrase to derive a symmetric DES key from.public byte[] getKey(String password, String realmName, String userName)
password
- The password.realmName
- The name of the realm.userName
- The username.protected byte[] generateKey(String passPhrase)
passPhrase
- The passphrase.protected byte[] setParity(byte[] in)
in
- The byte array to set parity on.protected int getBit(byte[] data, int pos)
data
- pos
- protected void setBit(byte[] data, int pos, int val)
data
- pos
- val
- protected byte[] fanFold(byte[] paddedByteArray)
paddedByteArray
- The padded byte array.protected byte[] calculateChecksum(byte[] data, byte[] keyBytes)
data
- The data to encrypt.keyBytes
- The bytes of the intermediate key.protected byte[] getStrongKey(byte[] secretKey)
secretKey
- The key to correct, if necessary.protected byte[] characterEncodeString(String string)
string
- The String to encode.protected byte[] padString(byte[] encodedString)
encodedString
- Copyright © 2003–2020 The Apache Software Foundation. All rights reserved.