Class BaseCodec

java.lang.Object
org.tinyradius.core.attribute.codec.BaseCodec

public abstract class BaseCodec extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    decode(byte[] data, byte[] requestAuth, String sharedSecret)
    Decodes the passed encoded attribute data and returns the cleartext form as bytes
    protected abstract byte[]
    decodeData(byte[] encodedData, byte[] auth, byte[] secret)
     
    byte[]
    encode(byte[] data, byte[] requestAuth, String sharedSecret)
    Encodes plaintext data
    protected 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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 encrypt
      requestAuth - packet authenticator
      sharedSecret - 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/tag
      requestAuth - packet authenticator
      sharedSecret - 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/padding
      auth - request authenticator
      secret - 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+string
      auth - request authenticator
      secret - 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