Class BaseCodec
java.lang.Object
org.tinyradius.core.attribute.codec.BaseCodec
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Decodes the passed encoded attribute data and returns the cleartext form as bytesprotected abstract byte[]
decodeData
(byte[] encodedData, byte[] auth, byte[] secret) byte[]
Encodes plaintext dataprotected abstract byte[]
encodeData
(byte[] data, byte[] auth, byte[] secret) protected byte[]
md5
(byte[] a, byte[] b) protected static byte[]
pad16x
(byte[] val) protected static byte[]
xor16
(byte[] src1, int src1offset, byte[] src2)
-
Constructor Details
-
BaseCodec
public BaseCodec()
-
-
Method Details
-
encode
public byte[] encode(byte[] data, byte[] requestAuth, String sharedSecret) throws RadiusPacketException Encodes plaintext data- Parameters:
data
- the data to encryptrequestAuth
- packet authenticatorsharedSecret
- shared secret- Returns:
- the byte array containing the encrypted data
- Throws:
RadiusPacketException
- errors encoding attribute data
-
decode
public byte[] decode(byte[] data, byte[] requestAuth, String sharedSecret) throws RadiusPacketException Decodes the passed encoded attribute data and returns the cleartext form as bytes- Parameters:
data
- data to decrypt, excl. type/length/tagrequestAuth
- packet authenticatorsharedSecret
- shared secret- Returns:
- decrypted data
- Throws:
RadiusPacketException
- errors decoding attribute data
-
encodeData
protected abstract byte[] encodeData(byte[] data, byte[] auth, byte[] secret) - Parameters:
data
- data to encrypt, excl. derived/random generated data e.g. salt/length/paddingauth
- request authenticatorsecret
- shared secret- Returns:
- byte array representing salt+string
-
decodeData
protected abstract byte[] decodeData(byte[] encodedData, byte[] auth, byte[] secret) throws RadiusPacketException - Parameters:
encodedData
- byte array representing salt+stringauth
- request authenticatorsecret
- shared secret- Returns:
- password sub-field (excl. salt, length, padding)
- Throws:
RadiusPacketException
- error while decoding attribute data
-
xor16
protected static byte[] xor16(byte[] src1, int src1offset, byte[] src2) -
md5
protected byte[] md5(byte[] a, byte[] b) -
pad16x
protected static byte[] pad16x(byte[] val) - Parameters:
val
- byte array to pad- Returns:
- byte array containing input, padded size multiple of 16
-