java.lang.Object
java.lang.Enum<ChaosMode>
org.refcodes.security.alt.chaos.ChaosMode
All Implemented Interfaces:
Serializable, Comparable<ChaosMode>, Constable, org.refcodes.mixin.EncodedAccessor, ChaosOptions

public enum ChaosMode extends Enum<ChaosMode> implements ChaosOptions
The ChaosMode specifies the mode of operation of a ChaosKey when using Chaos-based encryption/decryption. Attention: Comparing a ChaosMode with a different implementation of the ChaosOptions only functions as expected when passing the ChaosMode as argument to that different ChaosOptions implementation's ChaosOptions.equals(Object) method as the Enum.equals(Object) method of the ChaosMode enumeration cannot be overwritten (the Enum.equals(Object) method of an enumeration cannot be overridden)!
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>

    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
    A MUTATION operation as of isMutateS() is being applied.
    Combination of the XOR mode alongside the MUTATE mode.
    No additions are to be applied to the raw Chaos-based encryption/decryption.
    A SALTING operation as of isSalted() is being applied where applicable.
    Combination of the SALTED mode alongside the MUTATE mode.
    Combination of the SALTED mode as well as the XOR mode alongside the MUTATE mode.
    Combination of the SALTED mode alongside the XOR mode.
    XOR obfuscation as of isXorNext() is being applied.
  • Field Summary

  • Method Summary

    Modifier and Type
    Method
    Description
    short
    Sets the number of random bytes to be prefixed upon a PREFIX operation of decrypted (raw) data when encrypting with the accordingly configured ChaosKey: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the same ChaosKey configuration.
    boolean
    Determines whether a MUTATION operation of the ChaosKey'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
    Determines whether an additional SALTING operation with an additional salting (random) ChaosKey is to be applied: The salting ChaosKey's encoded bytes representation (as of ChaosKey.getEncoded()) is prefixed to the actual data which in a first pass is encoded with the this very salting ChaosKey.
    boolean
    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).
    static ChaosMode
    Returns the enum constant of this class with the specified name.
    static ChaosMode[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.refcodes.security.alt.chaos.ChaosOptions

    equals, getEncoded, hasRndPrefix, isFixedLength
  • Enum Constant Details

    • 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 of isMutateS() is being applied.
    • XOR

      public static final ChaosMode XOR
      XOR obfuscation as of isXorNext() is being applied.
    • MUTATE_XOR

      public static final ChaosMode MUTATE_XOR
      Combination of the XOR mode alongside the MUTATE mode.
    • SALTED

      public static final ChaosMode SALTED
      A SALTING operation as of isSalted() is being applied where applicable.
    • SALTED_MUTATE

      public static final ChaosMode SALTED_MUTATE
      Combination of the SALTED mode alongside the MUTATE mode.
    • SALTED_XOR

      public static final ChaosMode SALTED_XOR
      Combination of the SALTED mode alongside the XOR mode.
    • SALTED_MUTATE_XOR

      public static final ChaosMode SALTED_MUTATE_XOR
      Combination of the SALTED mode as well as the XOR mode alongside the MUTATE mode.
  • Method Details

    • values

      public static ChaosMode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ChaosMode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - 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 same ChaosKey, 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 a ChaosKey not in combination with ChaosOptions.isSalted() either in this ChaosKey or in combination with another ChaosKey not completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")
      Specified by:
      isXorNext in interface ChaosOptions
      Returns:
      True in case XOR obfuscation is to be established.
    • isMutateS

      public boolean isMutateS()
      Determines whether a MUTATION operation of the ChaosKey'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 a ChaosKey not in combination with ChaosOptions.isSalted() either in this ChaosKey or in combination with another ChaosKey not completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")
      Specified by:
      isMutateS in interface ChaosOptions
      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 salting ChaosKey's encoded bytes representation (as of ChaosKey.getEncoded()) is prefixed to the actual data which in a first pass is encoded with the this very salting ChaosKey. The salting ChaosKey encoded bytes representation as well as the succeeding initially encoded (salted) data then is encoded with the actual encryption ChaosKey, ensuring that the prefixed salting ChaosKey bytes are encoded. Decryption then is applied in reverse order. Currently only the ChaosEncryptionOutputStream and the ChaosDecryptionInputStream support salting! The ChaosEncrypter and ChaosDecrypter ignore this option!
      Specified by:
      isSalted in interface ChaosOptions
      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 configured ChaosKey: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the same ChaosKey configuration. Valid values range from {1..256} representable by one byte as of {0x00..0xFF}. Disclaimer: Using this option "stand alone" in a ChaosKey not in combination with ChaosOptions.isSalted() either in this ChaosKey or in combination with another ChaosKey not close by any means the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")
      Specified by:
      getRndPrefixSize in interface ChaosOptions
      Returns:
      The number of bytes for establishing the PREFIX functionality, 0 if no prefixing is to be applied at all.
    • toString

      public String toString()
      Overrides:
      toString in class Enum<ChaosMode>