Interface ChaosOptions

All Superinterfaces:
org.refcodes.mixin.EncodedAccessor
All Known Implementing Classes:
ChaosMode, ChaosOptionsImpl

public interface ChaosOptions extends org.refcodes.mixin.EncodedAccessor
The ChaosOptions interface provides configuration means for the Chaos-based encryption and may be provided to the constructor of the ChaosKey e.g. as one of the ChaosMode enumerations. Disclaimer: Using the options "stand alone" in a ChaosKey not in combination with isSalted() either in this ChaosKey or in combination with another ChaosKey does not (completely) close the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")
  • 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The overall encoded length in bytes of the ChaosOptions.
    static final int
    The bit position of the isMutateS() option when creating the encoded representation as of getEncoded().
    static final int
    The bit position of the hasRndPrefix() option when creating the encoded representation as of getEncoded().
    static final int
    The bit position of the isSalted() option when creating the encoded representation as of getEncoded().
    static final int
    The bit position of the isXorNext() option when creating the encoded representation as of getEncoded().
    static final int
    The number of bytes required to store the ChaosOptions flags.
    static final int
    The number of bytes required to store the ChaosOptions RND prefix size (as of getRndPrefixSize()).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object aObj)
    Returns true if all the passed object is of type ChaosOptions and all the attributes from the ChaosOptions are equal to this instance's attributes (as of isMutateS(), isXorNext() and isSalted()).
    default byte[]
    Returns the options in their primary encoding format.
    static int
    Returns the length of this ChaosOptions when represented as bytes (as of getEncoded()).
    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.
    default boolean
    Determines whether a PREFIX operation of the ChaosKey's decrypted (raw) data with random data when encrypting is to be applied: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the same ChaosKey configuration.
    default boolean
    Determines whether applying an according configured ChaosKey associates one element of the encrypted data with exactly one element of the decrypted (raw) data: Any ChaosOptions option affecting the length of the encrypted data compared to the length of the decrypted (raw) data is considered in this context not(!)
    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).
  • Field Details

  • Method Details

    • isXorNext

      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 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")
      Returns:
      True in case XOR obfuscation is to be established.
    • isMutateS

      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 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")
      Returns:
      True in case ADD obfuscation is to be established.
    • isSalted

      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!
      Returns:
      True in case SALTING is to be established.
    • hasRndPrefix

      default boolean hasRndPrefix()
      Determines whether a PREFIX operation of the ChaosKey's decrypted (raw) data with random data when encrypting is to be applied: Prefixing with random bytes will cause the same (succeeding) decrypted (raw) data to be encrypted differently even when using the same ChaosKey configuration. Disclaimer: Using this option "stand alone" in a ChaosKey not in combination with 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")
      Returns:
      True in case PREFIX is to be established.
    • getRndPrefixSize

      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 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")
      Returns:
      The number of bytes for establishing the PREFIX functionality, 0 if no prefixing is to be applied at all.
    • isFixedLength

      default boolean isFixedLength()
      Determines whether applying an according configured ChaosKey associates one element of the encrypted data with exactly one element of the decrypted (raw) data: Any ChaosOptions option affecting the length of the encrypted data compared to the length of the decrypted (raw) data is considered in this context not(!) to be a fixed length ChaosKey. E.g. salting (being declared with the isSalted() option) is not(!) considered to be of fixed length as salting decrypted (raw) data during encryption will result in encrypted data being longer than the decrypted (raw) data (by the length of the salting key). Non fixed length options are only supported by streams such as the ChaosEncryptionOutputStream or the ChaosDecryptionInputStream!
      Returns:
      True when these ChaosOptions represent an injective configuration.
    • getEncoded

      default byte[] getEncoded()
      Returns the options in their primary encoding format. Returns the bytes in a defined order representing the ChaosOptions. The values use a big endian representation. The byte array being returned is of the size as returned by getEncodedLength(). The meaning of the bits in the encoded byte are defined as in OPTIONS_BIT_MUTATE_S, OPTIONS_BIT_XOR_NEXT and OPTIONS_BIT_SALTED.
      Specified by:
      getEncoded in interface org.refcodes.mixin.EncodedAccessor
      Returns:
      The encoded options being the according byte(s) representing the ChaosOptions.
    • getEncodedLength

      static int getEncodedLength()
      Returns the length of this ChaosOptions when represented as bytes (as of getEncoded()).
      Returns:
      The number of bytes required to represent a ChaosOptions settings.
    • equals

      boolean equals(Object aObj)
      Returns true if all the passed object is of type ChaosOptions and all the attributes from the ChaosOptions are equal to this instance's attributes (as of isMutateS(), isXorNext() and isSalted()).
      Overrides:
      equals in class Object
      Parameters:
      aObj - the object to compare with for equality.
      Returns:
      true, if equal