Class BaseCodec
java.lang.Object
org.tinyradius.core.attribute.codec.BaseCodec
public abstract class BaseCodec
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description BaseCodec()
-
Method Summary
Modifier and Type Method Description byte[]
decode(byte[] data, byte[] requestAuth, java.lang.String sharedSecret)
Decodes the passed encoded attribute data and returns the cleartext form as bytesprotected abstract byte[]
decodeData(byte[] encodedData, byte[] auth, byte[] secret)
byte[]
encode(byte[] data, byte[] requestAuth, java.lang.String sharedSecret)
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, java.lang.String sharedSecret) throws RadiusPacketExceptionEncodes 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, java.lang.String sharedSecret) throws RadiusPacketExceptionDecodes 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
-