- java.lang.Object
-
- java.lang.Enum<ChaosMode>
-
- org.refcodes.security.alt.chaos.ChaosMode
-
- All Implemented Interfaces:
Serializable
,Comparable<ChaosMode>
,org.refcodes.mixin.EncodedAccessor
,ChaosOptions
public enum ChaosMode extends Enum<ChaosMode> implements ChaosOptions
TheChaosMode
specifies the mode of operation of aChaosKey
when using Chaos-based encryption/decryption. Attention: Comparing aChaosMode
with a different implementation of theChaosOptions
only functions as expected when passing theChaosMode
as argument to that differentChaosOptions
implementation'sChaosOptions.equals(Object)
method as theEnum.equals(Object)
method of theChaosMode
enumeration cannot be overwritten (theEnum.equals(Object)
method of an enumeration cannot be overridden)! TheChaosOptionsBuilder
is an implementation which'sChaosOptionsBuilder.equals(Object)
evaluates equality correctly when being passed aChaosMode
element.
-
-
Nested Class Summary
-
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
-
-
Enum Constant Summary
Enum Constants Enum Constant Description MUTATE
A MUTATION operation as ofisMutateS()
is being applied.MUTATE_XOR
NONE
No additions are to be applied to the raw Chaos-based encryption/decryption.SALTED
A SALTING operation as ofisSalted()
is being applied where applicable.SALTED_MUTATE
SALTED_MUTATE_XOR
SALTED_XOR
XOR
XOR obfuscation as ofisXorNext()
is being applied.
-
Field Summary
-
Fields inherited from interface org.refcodes.security.alt.chaos.ChaosOptions
ENCODED_LENGTH, OPTIONS_BIT_MUTATE_S, OPTIONS_BIT_RND_PREFIX, OPTIONS_BIT_SALTED, OPTIONS_BIT_XOR_NEXT, OPTIONS_BYTES, PREFIX_SIZE_BYZES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description short
getRndPrefixSize()
Sets the number of random bytes to be prefixed upon a PREFIX operation of decrypted (raw) data when encrypting with the accordingly configuredChaosKey
: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the sameChaosKey
configuration.boolean
isMutateS()
Determines whether a MUTATION operation of theChaosKey
's S value is to be applied with the previous byte value (before its encryption or zero 0 in case of the first value being processed), S then varies by +127 to -128 by each iteration: Nearly equal encrypted datasets will differ chaotically beginning with the the first occurrence of a different byte.boolean
isSalted()
Determines whether an additional SALTING operation with an additional salting (random)ChaosKey
is to be applied: The saltingChaosKey
's encoded bytes representation (as ofChaosKey.getEncoded()
) is prefixed to the actual data which in a first pass is encoded with the this very saltingChaosKey
.boolean
isXorNext()
Determines whether an XOR obfuscation of the next byte value to be encrypted is to be applied with the previous byte value (before its encryption or zero 0 in case of the first value being processed).String
toString()
static ChaosMode
valueOf(String name)
Returns the enum constant of this type with the specified name.static ChaosMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
-
Methods inherited from interface org.refcodes.security.alt.chaos.ChaosOptions
equals, getEncoded, hasRndPrefix, isFixedLength
-
-
-
-
Enum Constant Detail
-
NONE
public static final ChaosMode NONE
No additions are to be applied to the raw Chaos-based encryption/decryption.
-
MUTATE
public static final ChaosMode MUTATE
A MUTATION operation as ofisMutateS()
is being applied.
-
XOR
public static final ChaosMode XOR
XOR obfuscation as ofisXorNext()
is being applied.
-
MUTATE_XOR
public static final ChaosMode MUTATE_XOR
-
SALTED
public static final ChaosMode SALTED
A SALTING operation as ofisSalted()
is being applied where applicable.
-
SALTED_MUTATE
public static final ChaosMode SALTED_MUTATE
-
SALTED_XOR
public static final ChaosMode SALTED_XOR
-
SALTED_MUTATE_XOR
public static final ChaosMode SALTED_MUTATE_XOR
-
-
Method Detail
-
values
public static ChaosMode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ChaosMode c : ChaosMode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ChaosMode valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isXorNext
public boolean isXorNext()
Determines whether an XOR obfuscation of the next byte value to be encrypted is to be applied with the previous byte value (before its encryption or zero 0 in case of the first value being processed). XOR does not seem to be too effective obfuscating similar encrypted data with the sameChaosKey
, though for low capability devices it can be handy to add that little extra obfuscation to make it hard to interpolate between two similar but different messages. Disclaimer: Using this option "stand alone" in aChaosKey
not in combination withChaosOptions.isSalted()
either in thisChaosKey
or in combination with anotherChaosKey
not completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/blog/chaos-based_encryption_revisited")- Specified by:
isXorNext
in interfaceChaosOptions
- Returns:
- True in case XOR obfuscation is to be established.
-
isMutateS
public boolean isMutateS()
Determines whether a MUTATION operation of theChaosKey
's S value is to be applied with the previous byte value (before its encryption or zero 0 in case of the first value being processed), S then varies by +127 to -128 by each iteration: Nearly equal encrypted datasets will differ chaotically beginning with the the first occurrence of a different byte. Disclaimer: Using this option "stand alone" in aChaosKey
not in combination withChaosOptions.isSalted()
either in thisChaosKey
or in combination with anotherChaosKey
not completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/blog/chaos-based_encryption_revisited")- Specified by:
isMutateS
in interfaceChaosOptions
- Returns:
- True in case ADD obfuscation is to be established.
-
isSalted
public boolean isSalted()
Determines whether an additional SALTING operation with an additional salting (random)ChaosKey
is to be applied: The saltingChaosKey
's encoded bytes representation (as ofChaosKey.getEncoded()
) is prefixed to the actual data which in a first pass is encoded with the this very saltingChaosKey
. The saltingChaosKey
encoded bytes representation as well as the succeeding initially encoded (salted) data then is encoded with the actual encryptionChaosKey
, ensuring that the prefixed saltingChaosKey
bytes are encoded. Decryption then is applied in reverse order. Currently only theChaosEncryptionOutputStream
and theChaosDecryptionInputStream
support salting! TheChaosEncrypter
andChaosDecrypter
ignore this option!- Specified by:
isSalted
in interfaceChaosOptions
- Returns:
- True in case SALTING is to be established.
-
getRndPrefixSize
public short getRndPrefixSize()
Sets the number of random bytes to be prefixed upon a PREFIX operation of decrypted (raw) data when encrypting with the accordingly configuredChaosKey
: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the sameChaosKey
configuration. Valid values range from {1..256} representable by one byte as of {0x00..0xFF}. Disclaimer: Using this option "stand alone" in aChaosKey
not in combination withChaosOptions.isSalted()
either in thisChaosKey
or in combination with anotherChaosKey
not close by any means the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/blog/chaos-based_encryption_revisited")- Specified by:
getRndPrefixSize
in interfaceChaosOptions
- Returns:
- The number of bytes for establishing the PREFIX functionality, 0 if no prefixing is to be applied at all.
-
-