Class ChaosKeyImpl

  • All Implemented Interfaces:
    java.io.Serializable, java.security.Key, javax.crypto.SecretKey, javax.security.auth.Destroyable, ChaosKey


    public class ChaosKeyImpl
    extends java.lang.Object
    implements ChaosKey, javax.crypto.SecretKey
    Thanks Christian Pontesegger for the very good example on "Writing your own JCA extensions - a full cipher" at: "http://codeandme.blogspot.de/2013/07/writing-your-own-jca-extensions-full.html" and for the very good example on "Writing your own JCA extensions - a simple digest " at: "http://codeandme.blogspot.de/2013/06/writing-your-own-jca-extensions-simple.html"
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROVIDER_NAME  
    • Constructor Summary

      Constructors 
      Constructor Description
      ChaosKeyImpl​(double x0, double a, double s)
      Instantiates a new chaos key.
      ChaosKeyImpl​(int x0, int a, int s)
      Instantiates a new chaos key from the provided integer values.
      ChaosKeyImpl​(java.lang.String aSecret)
      Instantiates a new chaos key by calculating x0, a and s from the provided String.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getA​()
      Gets the a.
      java.lang.String getAlgorithm​()
      byte[] getEncoded​()
      java.lang.String getFormat​()
      double getS​()
      Gets the s.
      double getX0​()
      Gets the x0.
      protected static double toA​(int a)
      Creates a valid a double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
      protected static double toS​(int s)
      Creates a valid s double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
      protected static double toX0​(int x0)
      Creates a valid x0 double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
      protected static void validate​(double x0, double a, double s)
      Validates the given values whether them are in scope.
      • Methods inherited from interface javax.security.auth.Destroyable

        destroy, isDestroyed
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ChaosKeyImpl

        public ChaosKeyImpl​(java.lang.String aSecret)
        Instantiates a new chaos key by calculating x0, a and s from the provided String.
        Parameters:
        aSecret - The String from which to calculate x0, a and s.
      • ChaosKeyImpl

        public ChaosKeyImpl​(int x0,
                            int a,
                            int s)
        Instantiates a new chaos key from the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructor ChaosKeyImpl(double, double, double). You can use values in the range of Integer.MIN_VALUE and Integer.MAX_VALUE.
        Parameters:
        x0 - The value from which to calculate the valid x0 double.
        a - The value from which to calculate the valid a double.
        s - The value from which to calculate the valid s double.
      • ChaosKeyImpl

        public ChaosKeyImpl​(double x0,
                            double a,
                            double s)
        Instantiates a new chaos key.
        Parameters:
        x0 - the x0: (0 <= x0 <= 1 )
        a - the a: (a <= 3.57 <= 4 )
        s - the s: (s > Integer.MAX_VALUE)
    • Method Detail

      • getAlgorithm

        public java.lang.String getAlgorithm​()
        Specified by:
        getAlgorithm in interface java.security.Key
      • getFormat

        public java.lang.String getFormat​()
        Specified by:
        getFormat in interface java.security.Key
      • getEncoded

        public byte[] getEncoded​()
        Specified by:
        getEncoded in interface java.security.Key
      • getX0

        public double getX0​()
        Gets the x0.
        Specified by:
        getX0 in interface ChaosKey
        Returns:
        the x0
      • getA

        public double getA​()
        Gets the a.
        Specified by:
        getA in interface ChaosKey
        Returns:
        the a
      • getS

        public double getS​()
        Gets the s.
        Specified by:
        getS in interface ChaosKey
        Returns:
        the s
      • toX0

        protected static double toX0​(int x0)
        Creates a valid x0 double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        x0 - The integer as source for x0
        Returns:
        The x0 inside the valid scope.
      • toA

        protected static double toA​(int a)
        Creates a valid a double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        a - The integer as source for a
        Returns:
        The a inside the valid scope.
      • toS

        protected static double toS​(int s)
        Creates a valid s double from the provided integer (values from Integer.MIN_VALUE to Integer.MAX_VALUE are allowed.
        Parameters:
        s - The integer as source for s
        Returns:
        The s inside the valid scope.
      • validate

        protected static void validate​(double x0,
                                       double a,
                                       double s)
        Validates the given values whether them are in scope.
        Parameters:
        x0 - The x0 value to validate.
        a - The a value to validate.
        s - The s value to validate.