Package org.refcodes.security.alt.chaos
Class ChaosKeyImpl
- java.lang.Object
-
- org.refcodes.security.alt.chaos.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 providedString
.
-
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 fromInteger.MIN_VALUE
toInteger.MAX_VALUE
are allowed.protected static double
toS(int s)
Creates a valid s double from the provided integer (values fromInteger.MIN_VALUE
toInteger.MAX_VALUE
are allowed.protected static double
toX0(int x0)
Creates a valid x0 double from the provided integer (values fromInteger.MIN_VALUE
toInteger.MAX_VALUE
are allowed.protected static void
validate(double x0, double a, double s)
Validates the given values whether them are in scope.
-
-
-
Field Detail
-
PROVIDER_NAME
public static final java.lang.String PROVIDER_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ChaosKeyImpl
public ChaosKeyImpl(java.lang.String aSecret)
Instantiates a new chaos key by calculating x0, a and s from the providedString
.- Parameters:
aSecret
- TheString
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 constructorChaosKeyImpl(double, double, double)
. You can use values in the range ofInteger.MIN_VALUE
andInteger.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 interfacejava.security.Key
-
getFormat
public java.lang.String getFormat()
- Specified by:
getFormat
in interfacejava.security.Key
-
getEncoded
public byte[] getEncoded()
- Specified by:
getEncoded
in interfacejava.security.Key
-
toX0
protected static double toX0(int x0)
Creates a valid x0 double from the provided integer (values fromInteger.MIN_VALUE
toInteger.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 fromInteger.MIN_VALUE
toInteger.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 fromInteger.MIN_VALUE
toInteger.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.
-
-