java.lang.Object
org.refcodes.security.alt.chaos.ChaosKey
- All Implemented Interfaces:
Serializable,Key,SecretKey,Destroyable,org.refcodes.mixin.ChildAccessor<ChaosKey>,org.refcodes.mixin.Disposable,org.refcodes.mixin.EncodedAccessor
public class ChaosKey
extends Object
implements SecretKey, org.refcodes.mixin.EncodedAccessor, org.refcodes.mixin.ChildAccessor<ChaosKey>, org.refcodes.mixin.Disposable
The key holding the parameters for the chaos function. 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.ChildAccessor
org.refcodes.mixin.ChildAccessor.ChildBuilder<T,B extends org.refcodes.mixin.ChildAccessor.ChildBuilder<T, B>>, org.refcodes.mixin.ChildAccessor.ChildMutator<T>, org.refcodes.mixin.ChildAccessor.ChildProperty<T> Nested classes/interfaces inherited from interface org.refcodes.mixin.EncodedAccessor
org.refcodes.mixin.EncodedAccessor.EncodedBuilder<B extends org.refcodes.mixin.EncodedAccessor.EncodedBuilder<B>>, org.refcodes.mixin.EncodedAccessor.EncodedMutator, org.refcodes.mixin.EncodedAccessor.EncodedProperty -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of bytes required to store Astatic final doubleThe maximum valid A value.static final doubleThe minimum valid A value.static final intThe overall encoded length in bytes of theChaosKeyincluding theChaosOptions.static final StringThe name of the security provider.static final intThe number of bytes required to store Sstatic final longThe maximum valid S value (2^53-1 = MAX_SAFE_INTEGER when floating point is involved).static final longThe minimum valid S value (-2^53 = MIN_SAFE_INTEGER when floating point is involved).static final longThe maximum negative S value (S_NEGATIVE_MAXxS_POSITIVE_MIN= 256 possibilities, which is the range of values one byte can represent, which in turn is he atomic data to be encrypted / decrypted).static final longThe minimum positive S value (S_NEGATIVE_MAXxS_POSITIVE_MIN= 256 possibilities, which is the range of values one byte can represent, which in turn is he atomic data to be encrypted / decrypted).static final intThe number of bytes required to store Xstatic final doubleThe maximum valid X value.static final doubleThe minimum valid X value. -
Constructor Summary
ConstructorsConstructorDescriptionChaosKey(byte[] aEncoded) Instantiates theChaosKeyby reversing the result of thegetEncoded()operation where the byte array contains the values x0, a and s (excluding theChaosOptions).Instantiates theChaosKeyby reversing the result of thegetEncoded()operation where the byte array contains the values x0, a and s (including theChaosOptions.getEncoded()).ChaosKey(char[] aSecret) Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.ChaosKey(char[] aSecret, ChaosOptions aChaosOptions) Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.ChaosKey(char[] aSecret, ChaosOptions aChaosOptions, ChaosKey aChildKey) Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.ChaosKey(double x0, double a, long s) Instantiates a newChaosKeydirectly from the provided double values.Instantiates a newChaosKeydirectly from the provided double values.ChaosKey(double x0, double a, long s, ChaosOptions aChaosOptions) Instantiates a newChaosKeydirectly from the provided double values.ChaosKey(double x0, double a, long s, ChaosOptions aChaosOptions, ChaosKey aChildKey) Instantiates a newChaosKeydirectly from the provided double values.ChaosKey(int x0, int a, int s) Instantiates a newChaosKeyfrom the provided integer values.Instantiates a newChaosKeyfrom the provided integer values.ChaosKey(int x0, int a, int s, ChaosOptions aChaosOptions) Instantiates a newChaosKeyfrom the provided integer values.ChaosKey(int x0, int a, int s, ChaosOptions aChaosOptions, ChaosKey aChildKey) Instantiates a newChaosKeyfrom the provided integer values.ChaosKey(String aSecret, ChaosOptions aChaosOptions) ChaosKey(String aSecret, ChaosOptions aChaosOptions, ChaosKey aChildKey) -
Method Summary
Modifier and TypeMethodDescriptionprotected static longaddToS(long s, long aAddend) Adds a value to s so that a result exceedingS_MAXor {S_MINis wrapped around accordingly and any result inbetweenS_POSITIVE_MINandS_NEGATIVE_MAXis moved pastS_POSITIVE_MINorS_NEGATIVE_MAXaccordingly.static ChaosOptionsasCertificateOptions(File aCertFile) Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenFile.static ChaosOptionsasCertificateOptions(InputStream aInputStream) Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenInputStream.static ChaosOptionsasCertificateOptions(String aCertificate) Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenString.static ChaosKeycreateFromCertificate(File aCertFile) static ChaosKeycreateFromCertificate(File aCertFile, String aPassword) static ChaosKeycreateFromCertificate(InputStream aInputStream) Creates aChaosKey(chain) from the unsecured certificate retrieved from the givenInputStream.static ChaosKeycreateFromCertificate(InputStream aInputStream, String aPassword) Creates aChaosKey(chain) from the password protected certificate retrieved from the givenInputStream.static ChaosKeycreateFromCertificate(String aCertificate) Creates aChaosKey(chain) from the unsecured certificate.static ChaosKeycreateFromCertificate(String aCertificate, String aPassword) Creates aChaosKey(chain) from the password protected certificate.static ChaosKeycreateKeyChain(byte[] aEncodedChain) Creates aChaosKeyfrom the provided encoded chain representations (as oftoEncodedChain()) including all the nestedChaosKeychildren.static ChaosKeyCreates a randomChaosKey.static ChaosKeycreateRndKey(ChaosKey aChildKey) Creates a randomChaosKey.static ChaosKeycreateRndKey(ChaosOptions aChaosOptions) Creates a randomChaosKey.static ChaosKeycreateRndKey(ChaosOptions aChaosOptions, ChaosKey aChildKey) Creates a randomChaosKey.static ChaosKeycreateRndKeyChain(int aChainLength) Creates a randomChaosKeychain, where eachChaosKeyreferences a childChaosKey(as ofgetChild()) as defined by the provided chain length and eachChaosKeyin the chain is initialized by its unique random values.static ChaosKeycreateRndKeyChain(int aChainLength, ChaosOptions... aChaosOptions) Creates a randomChaosKeychain, where eachChaosKeyreferences a childChaosKey(as ofgetChild()) as defined by the provided chain length and eachChaosKeyin the chain is initialized by its unique random values.voiddestroy()voiddispose()booleanReturns true if all the passed object is of typeChaosKeyand all the attributes from theChaosKeyare equal to this instance's attributes (as ofgetX0(),getA()andgetS()as well asgetOptions()andgetChild()).protected intDetermines the number ofChaosKeychildren in a row which when applied produce output of the same length as the input was.protected static ChaosOptionsfromCertificateHead(String aCertificateHead) Extracts aChaosOptionsinstance from the provided certificate head.protected static ChaosOptionsfromCertificateTail(String aCertificateTail) Extracts aChaosOptionsinstance from the provided certificate tail.doublegetA()Gets the a.getChild()Returns the next outerChaosKey.byte[]Returns the key in its primary encoding format.static intReturns the length of thisChaosKeywhen represented as bytes (as ofgetEncoded()) (excluding theChaosOptions).Returns theChaosOptionsbeing used to enhance Chaos-based encryption by enabling various additional processing steps.longgetS()Gets the s.doublegetX0()Gets the x0.inthashCode()protected ChaosKeyDetermines the nextChaosKeychild (excluding this) which does not(!)protected static doubletoA(int a) Creates a valid a double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed.protected static doubletoA(long a) Creates a valid a double from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).Creates a certificate for encryption and decryption from thisChaosKey.toCertificate(int aLineWidth) Creates a certificate for encryption and decryption from thisChaosKey.toCertificate(String aPassword) Creates a password protected certificate for encryption and decryption from thisChaosKey.toCertificate(String aPassword, int aLineWidth) Creates a password protected certificate for encryption and decryption from thisChaosKey.toCertificate(String aPassword, ChaosOptions aChaosOptions) Creates password protected a certificate for encryption and decryption from thisChaosKey.toCertificate(String aPassword, ChaosOptions aChaosOptions, int aLineWidth) Creates password protected a certificate for encryption and decryption from thisChaosKey.protected static StringCreates a certificate head for an unsecured certificate.protected static StringtoCertificateHead(ChaosOptions aChaosOptions) Creates a certificate head from the providedChaosOptionsinstance for a password protected certificate.protected static StringCreates a certificate tail for an unsecured certificate.protected static StringtoCertificateTail(ChaosOptions aChaosOptions) Creates a certificate tail from the providedChaosOptionsinstance for a password protected certificate.byte[]Returns all encodedChaosKeyrepresentations including thisChaosKeyas well as all the nestedChaosKeychildren being their concatenatedgetEncoded()representation, the this being first and the bottom most child the last.protected static longtoS(int s) Creates a valid s double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed).protected static longtoS(long s) Creates a valid s long from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).toString()protected static doubletoX0(int x0) Creates a valid x0 double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed.protected static doubletoX0(long x0) Creates a valid x0 double from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).protected static voidvalidate(double x0, double a, double s) Validates the given values whether them are in scope.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.security.auth.Destroyable
isDestroyed
-
Field Details
-
PROVIDER_NAME
-
A_BYTES
public static final int A_BYTESThe number of bytes required to store A- See Also:
-
A_MAX
public static final double A_MAXThe maximum valid A value.- See Also:
-
A_MIN
public static final double A_MINThe minimum valid A value.- See Also:
-
S_BYTES
public static final int S_BYTESThe number of bytes required to store S- See Also:
-
S_MAX
public static final long S_MAXThe maximum valid S value (2^53-1 = MAX_SAFE_INTEGER when floating point is involved).- See Also:
-
S_MIN
public static final long S_MINThe minimum valid S value (-2^53 = MIN_SAFE_INTEGER when floating point is involved).- See Also:
-
S_NEGATIVE_MAX
public static final long S_NEGATIVE_MAXThe maximum negative S value (S_NEGATIVE_MAXxS_POSITIVE_MIN= 256 possibilities, which is the range of values one byte can represent, which in turn is he atomic data to be encrypted / decrypted).- See Also:
-
S_POSITIVE_MIN
public static final long S_POSITIVE_MINThe minimum positive S value (S_NEGATIVE_MAXxS_POSITIVE_MIN= 256 possibilities, which is the range of values one byte can represent, which in turn is he atomic data to be encrypted / decrypted).- See Also:
-
X_BYTES
public static final int X_BYTESThe number of bytes required to store X- See Also:
-
X_MAX
public static final double X_MAXThe maximum valid X value.- See Also:
-
X_MIN
public static final double X_MINThe minimum valid X value.- See Also:
-
ENCODED_LENGTH
public static final int ENCODED_LENGTHThe overall encoded length in bytes of theChaosKeyincluding theChaosOptions.- See Also:
-
-
Constructor Details
-
ChaosKey
public ChaosKey(byte[] aEncoded) Instantiates theChaosKeyby reversing the result of thegetEncoded()operation where the byte array contains the values x0, a and s (excluding theChaosOptions). The values use a big endian representation. The byte array being passed is to be of the size as returned bygetEncodedLength(). The number of bytes required by each value in the byte array are defined in the constants 8,A_BYTESandS_BYTESrespectively and in that order.- Parameters:
aEncoded- The encoded representation of the chaos key.
-
ChaosKey
public ChaosKey(double x0, double a, long s) Instantiates a newChaosKeydirectly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0- the x0: (0 <= x0 <= 1 )a- the a: (a <= 3.57 <= 4 )s- the s: (Integer.MAX_VALUE>= s >=Integer.MAX_VALUEAND 16 <= s <= -16)
-
ChaosKey
Instantiates a newChaosKeydirectly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0- the x0: (0 <= x0 <= 1 )a- the a: (a <= 3.57 <= 4 )s- the s: (Integer.MAX_VALUE>= s >=Integer.MAX_VALUEAND 16 <= s <= -16)aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption by enabling various additional processing steps.
-
ChaosKey
public ChaosKey(int x0, int a, int s) Instantiates a newChaosKeyfrom the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosKey(double, double, long). You can use values in the range ofInteger.MIN_VALUEandInteger.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.
-
ChaosKey
Instantiates a newChaosKeyfrom the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosKey(double, double, long). You can use values in the range ofInteger.MIN_VALUEandInteger.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.aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption by enabling various additional processing steps.
-
ChaosKey
public ChaosKey(char[] aSecret) Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.- Parameters:
aSecret- The char array (in contrast to aString, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.
-
ChaosKey
-
ChaosKey
Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.- Parameters:
aSecret- The char array (in contrast to aString, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption.
-
ChaosKey
- Parameters:
aSecret- TheStringfrom which to calculate x0, a and s.aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption.
-
ChaosKey
Instantiates a newChaosKeydirectly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0- the x0: (0 <= x0 <= 1 )a- the a: (a <= 3.57 <= 4 )s- the s: (Integer.MAX_VALUE>= s >=Integer.MAX_VALUEAND 16 <= s <= -16)aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
Instantiates a newChaosKeyfrom the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosKey(double, double, long). You can use values in the range ofInteger.MIN_VALUEandInteger.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.aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
Instantiates a newChaosKeyfrom the provided integer values. The integers are converted to the valid ranges of double values for invoking the constructorChaosKey(double, double, long). You can use values in the range ofInteger.MIN_VALUEandInteger.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.aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption by enabling various additional processing steps.aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.- Parameters:
aSecret- The char array (in contrast to aString, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
-
ChaosKey
Instantiates theChaosKeyby reversing the result of thegetEncoded()operation where the byte array contains the values x0, a and s (including theChaosOptions.getEncoded()). The values use a big endian representation. The byte array being passed is to be of the size as returned bygetEncodedLength(). The number of bytes required by each value in the byte array are defined in the constants 8,A_BYTESandS_BYTESrespectively and in that order. -
ChaosKey
Instantiates a newChaosKeydirectly from the provided double values. Make sure your provided arguments are within the allowed bounds;- Parameters:
x0- the x0: (0 <= x0 <= 1 )a- the a: (a <= 3.57 <= 4 )s- the s: (Integer.MAX_VALUE>= s >=Integer.MAX_VALUEAND 16 <= s <= -16)aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption by enabling various additional processing steps.aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
Instantiates a newChaosKeyby calculating x0, a and s from the provided char array.- Parameters:
aSecret- The char array (in contrast to aString, a char array can be invalidated after use by overwriting its array elements with random values) from which to calculate x0, a and s.aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption.aChildKey- The childChaosKeybeing the successor of thisChaosKeyto encrypt and the predecessor of thisChaosKeyto decrypt.
-
ChaosKey
-
-
Method Details
-
destroy
- Specified by:
destroyin interfaceDestroyable- Throws:
DestroyFailedException
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.refcodes.mixin.Disposable
-
getA
public double getA()Gets the a.- Returns:
- the a
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceKey
-
getOptions
Returns theChaosOptionsbeing used to enhance Chaos-based encryption by enabling various additional processing steps. Defaults toChaosMode.NONE.- Returns:
- the chaos metrics
-
getEncoded
public byte[] getEncoded()Returns the key in its primary encoding format. Returns the bytes in a defined order representing the x0, a and s values (including theChaosOptions.getEncoded()). The values use a big endian representation. The byte array being returned is of the size as returned bygetEncodedLength(). The number of bytes required by each value in the byte array are defined in the constants 8,A_BYTESandS_BYTESrespectively and in that order.- Specified by:
getEncodedin interfaceorg.refcodes.mixin.EncodedAccessor- Specified by:
getEncodedin interfaceKey- Returns:
- The encoded key being the according bytes representing the
ChaosKeyx0, a and s values.
-
toEncodedChain
public byte[] toEncodedChain()Returns all encodedChaosKeyrepresentations including thisChaosKeyas well as all the nestedChaosKeychildren being their concatenatedgetEncoded()representation, the this being first and the bottom most child the last. Invoking thecreateKeyChain(byte[])method with the result of this method reconstructs theChaosKeychain's instances.- Returns:
- The bytes representation of this
ChaosKeyand its nestedChaosKeychildren as of theirgetEncoded()representation.
-
getFormat
-
getChild
-
getS
public long getS()Gets the s.- Returns:
- the s
-
getX0
public double getX0()Gets the x0.- Returns:
- the x0
-
toCertificate
-
toCertificate
Creates a certificate for encryption and decryption from thisChaosKey. The certificate is not password protected! -
toCertificate
-
toCertificate
Creates a password protected certificate for encryption and decryption from thisChaosKey. -
toCertificate
Creates password protected a certificate for encryption and decryption from thisChaosKey.- Parameters:
aPassword- The password with which to protect the key.aChaosOptions- TheChaosOptionsto use for the certificate encryption.- Returns:
- The
Stringcertificate representation of thisChaosKey.
-
toCertificate
Creates password protected a certificate for encryption and decryption from thisChaosKey.- Parameters:
aPassword- The password with which to protect the key.aChaosOptions- TheChaosOptionsto use for the certificate encryption.aLineWidth- The line width to use for the encoded certificate data (excluding the head and the tail).- Returns:
- The
Stringcertificate representation of thisChaosKey.
-
hashCode
-
equals
Returns true if all the passed object is of typeChaosKeyand all the attributes from theChaosKeyare equal to this instance's attributes (as ofgetX0(),getA()andgetS()as well asgetOptions()andgetChild()). -
toString
-
createFromCertificate
- Parameters:
aCertFile- TheFilepointing to the certificate representing theChaosKey.aPassword- The password protecting the certificate.- Returns:
- The
ChaosKey(chain) represented by the certificate. - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theFile.
-
createFromCertificate
public static ChaosKey createFromCertificate(InputStream aInputStream, String aPassword) throws IOException Creates aChaosKey(chain) from the password protected certificate retrieved from the givenInputStream.- Parameters:
aInputStream- TheInputStreamproviding the certificate representing theChaosKey.aPassword- The password protecting the certificate.- Returns:
- The
ChaosKey(chain) represented by the certificate. - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theInputStream.
-
createFromCertificate
Creates aChaosKey(chain) from the password protected certificate. -
createFromCertificate
- Parameters:
aCertFile- TheFilepointing to the certificate representing theChaosKey.- Returns:
- The
ChaosKey(chain) represented by the certificate. - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theFile.
-
createFromCertificate
Creates aChaosKey(chain) from the unsecured certificate retrieved from the givenInputStream.- Parameters:
aInputStream- TheInputStreamproviding the certificate representing theChaosKey.- Returns:
- The
ChaosKey(chain) represented by the certificate. - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theInputStream.
-
createFromCertificate
-
createKeyChain
Creates aChaosKeyfrom the provided encoded chain representations (as oftoEncodedChain()) including all the nestedChaosKeychildren.- Parameters:
aEncodedChain- The byte array representing theChaosKeychain's encoding (as oftoEncodedChain()).- Returns:
- The reconstructed
ChaosKeychain from the provided encoded chain representation.
-
createRndKeyChain
Creates a randomChaosKeychain, where eachChaosKeyreferences a childChaosKey(as ofgetChild()) as defined by the provided chain length and eachChaosKeyin the chain is initialized by its unique random values.- Parameters:
aChainLength- The number ofChaosKeyinstances chained behind each other as ofgetChild()- Returns:
- the
ChaosKeywith the according chain length being initialized with random values.
-
createRndKeyChain
Creates a randomChaosKeychain, where eachChaosKeyreferences a childChaosKey(as ofgetChild()) as defined by the provided chain length and eachChaosKeyin the chain is initialized by its unique random values.- Parameters:
aChainLength- The number ofChaosKeyinstances chained behind each other as ofgetChild()aChaosOptions- TheChaosOptionsto use for eachChaosKey, the first one is used for the top most parentChaosKey, the others for the succeedingChaosKeychildren. The lastChaosOptionselement is used for anyChaosKeyto be created exceeding the length of theChaosOptionselements.- Returns:
- the
ChaosKeywith the according chain length being initialized with random values.
-
createRndKey
-
createRndKey
Creates a randomChaosKey. UsegetX0(),getA()andgetS()orgetEncoded()to retrieve the parameters of the createdChaosKey.- Parameters:
aChaosOptions- TheChaosMode(ChaosOptions) to use to enhance Chaos-based encryption.- Returns:
- the
ChaosKeybeing initialized with random values.
-
createRndKey
-
createRndKey
-
asCertificateOptions
Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenFile.- Parameters:
aCertFile- TheFilepointing to the certificate representing which'sChaosOptionsare to be determined.- Returns:
- The
ChaosOptionsof the certificate itself or null if it is an unsecured certificate. - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theFile.IllegalArgumentException- thrown in case the provided certificate does not match aChaosKeycertificate notation.
-
asCertificateOptions
Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenInputStream.- Parameters:
aInputStream- TheInputStreampointing to the certificate representing which'sChaosOptionsare to be determined.- Returns:
- The
ChaosOptionsof the certificate itself or null if it is an unsecured certificate - Throws:
IOException- thrown in case an I/O related problem occurred while accessing theInputStream.IllegalArgumentException- thrown in case the provided certificate does not match aChaosKeycertificate notation.
-
asCertificateOptions
Creates aChaosOptionsof the (secured) certificate itself (and not the therein contained key chain) retrieved from the givenString.- Parameters:
aCertificate- TheStringrepresenting the certificatewhich'sChaosOptionsare to be determined.- Returns:
- The
ChaosOptionsof the certificate itself or null if it is an unsecured certificate - Throws:
IllegalArgumentException- thrown in case the provided certificate does not match aChaosKeycertificate notation.
-
getEncodedLength
public static int getEncodedLength()Returns the length of thisChaosKeywhen represented as bytes (as ofgetEncoded()) (excluding theChaosOptions).- Returns:
- The number of bytes required to represent a
ChaosKeyx0, a and s values.
-
fixedLengthChildDepth
protected int fixedLengthChildDepth()Determines the number ofChaosKeychildren in a row which when applied produce output of the same length as the input was. TheChaosKeychild after that determined depth is either null or a variable lengthChaosKeychild (as ofnextVariableLengthChild()).- Returns:
- The number of
ChaosKeychildren in a row which when applied produce output of the same length as the input was.
-
nextVariableLengthChild
Determines the nextChaosKeychild (excluding this) which does not(!) produce output of the same length as the input was. This is theChaosKeychild after the determined depth ofChaosKeychildren in a row which when applied produce output of the same length as the input was (as offixedLengthChildDepth()) or null if there is no such nextChaosKey. -
addToS
protected static long addToS(long s, long aAddend) Adds a value to s so that a result exceedingS_MAXor {S_MINis wrapped around accordingly and any result inbetweenS_POSITIVE_MINandS_NEGATIVE_MAXis moved pastS_POSITIVE_MINorS_NEGATIVE_MAXaccordingly.- Parameters:
s- The value to which to add an summand.aAddend- The summand to be added to s.- Returns:
- The accordingly wrapped new s value.
-
toA
protected static double toA(int a) Creates a valid a double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed.- Parameters:
a- The integer as source for a- Returns:
- The a inside the valid scope.
-
toA
protected static double toA(long a) Creates a valid a double from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).- Parameters:
a- The long as source for a- Returns:
- The a inside the valid scope.
-
toS
protected static long toS(int s) Creates a valid s double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed).- Parameters:
s- The integer as source for s- Returns:
- The s inside the valid scope.
-
toS
protected static long toS(long s) Creates a valid s long from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).- Parameters:
s- The long as source for s- Returns:
- The s inside the valid scope.
-
toX0
protected static double toX0(int x0) Creates a valid x0 double from the provided integer (values fromInteger.MIN_VALUEtoInteger.MAX_VALUEare allowed.- Parameters:
x0- The integer as source for x0- Returns:
- The x0 inside the valid scope.
-
toX0
protected static double toX0(long x0) Creates a valid x0 double from the provided long (values fromLong.MIN_VALUEtoLong.MAX_VALUEare allowed).- Parameters:
x0- The long as source for x0- Returns:
- The x0 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.
-
fromCertificateHead
Extracts aChaosOptionsinstance from the provided certificate head.- Parameters:
aCertificateHead- The head (first line) of the certificate in question.- Returns:
- The according
ChaosOptionsinstance. - Throws:
IllegalArgumentException- in case the certificate head is not valid for creating aChaosOptionsinstance.
-
fromCertificateTail
Extracts aChaosOptionsinstance from the provided certificate tail.- Parameters:
aCertificateTail- The tail (last line) of the certificate in question.- Returns:
- The according
ChaosOptionsinstance. - Throws:
IllegalArgumentException- in case the certificate tail is not valid for creating aChaosOptionsinstance.
-
toCertificateHead
Creates a certificate head for an unsecured certificate.- Returns:
- The accordingly created certificate head.
-
toCertificateHead
Creates a certificate head from the providedChaosOptionsinstance for a password protected certificate.- Parameters:
aChaosOptions- TheChaosOptionsfrom which to create the certificate head.- Returns:
- The accordingly created certificate head.
-
toCertificateTail
Creates a certificate tail for an unsecured certificate.- Returns:
- The accordingly created certificate tail.
-
toCertificateTail
Creates a certificate tail from the providedChaosOptionsinstance for a password protected certificate.- Parameters:
aChaosOptions- TheChaosOptionsfrom which to create the certificate tail.- Returns:
- The accordingly created certificate tail.
-