Package org.refcodes.security.alt.chaos
Class ChaosOptionsImpl
java.lang.Object
org.refcodes.security.alt.chaos.ChaosOptionsImpl
- All Implemented Interfaces:
org.refcodes.mixin.EncodedAccessor,ChaosOptions
The
ChaosOptionsImpl provides means to create a ChaosOptions
instance.-
Nested Class Summary
Nested ClassesNested 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 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 -
Constructor Summary
ConstructorsConstructorDescriptionChaosOptionsImpl(boolean isMutateS, boolean isXorNext, boolean isSalted) Constructs theChaosOptionsImplwith the given values.ChaosOptionsImpl(boolean isMutateS, boolean isXorNext, boolean isSalted, short aRndPrefixSize) Constructs theChaosOptionsImplwith the given values.ChaosOptionsImpl(byte[] aEncoded) Instantiates theChaosOptionsby reversing the result of theChaosOptions.getEncoded()operation where the byte array contains the values of the options. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChaosOptionsImpl.Builderbuilder()Creates builder to buildChaosOptionsImpl.booleanReturns true if all the passed object is of typeChaosOptionsand all the attributes from theChaosOptionsare equal to this instance's attributes (as ofChaosOptions.isMutateS(),ChaosOptions.isXorNext()andChaosOptions.isSalted()).shortSets 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 sameChaosKeyconfiguration.inthashCode()booleanDetermines 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.booleanisSalted()Determines whether an additional SALTING operation with an additional salting (random)ChaosKeyis 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.booleanDetermines 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).toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.refcodes.security.alt.chaos.ChaosOptions
getEncoded, hasRndPrefix, isFixedLength
-
Constructor Details
-
ChaosOptionsImpl
public ChaosOptionsImpl(byte[] aEncoded) Instantiates theChaosOptionsby reversing the result of theChaosOptions.getEncoded()operation where the byte array contains the values of the options. The values use a big endian representation. The byte array being passed is to be of the size as returned byChaosOptions.getEncodedLength(). The meaning of the bits in the encoded byte are defined as inChaosOptions.OPTIONS_BIT_MUTATE_S,ChaosOptions.OPTIONS_BIT_XOR_NEXTandChaosOptions.OPTIONS_BIT_SALTED.- Parameters:
aEncoded- The encoded representation of the options.
-
ChaosOptionsImpl
public ChaosOptionsImpl(boolean isMutateS, boolean isXorNext, boolean isSalted) Constructs theChaosOptionsImplwith the given values.- Parameters:
isMutateS- Enables or disables theisMutateS()option.isXorNext- Enables or disables theisXorNext()option.isSalted- Enables or disables theisSalted()option.
-
ChaosOptionsImpl
public ChaosOptionsImpl(boolean isMutateS, boolean isXorNext, boolean isSalted, short aRndPrefixSize) Constructs theChaosOptionsImplwith the given values.- Parameters:
isMutateS- Enables or disables theisMutateS()option.isXorNext- Enables or disables theisXorNext()option.isSalted- Enables or disables theisSalted()option.aRndPrefixSize- The number of bytes to prefix with random bytes.
-
-
Method Details
-
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 aChaosKeynot in combination withChaosOptions.isSalted()either in thisChaosKeyor in combination with anotherChaosKeynot completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")- Specified by:
isXorNextin 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 aChaosKeynot in combination withChaosOptions.isSalted()either in thisChaosKeyor in combination with anotherChaosKeynot completely closes the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")- Specified by:
isMutateSin 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)ChaosKeyis 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 saltingChaosKeyencoded bytes representation as well as the succeeding initially encoded (salted) data then is encoded with the actual encryptionChaosKey, ensuring that the prefixed saltingChaosKeybytes are encoded. Decryption then is applied in reverse order. Currently only theChaosEncryptionOutputStreamand theChaosDecryptionInputStreamsupport salting! TheChaosEncrypterandChaosDecrypterignore this option!- Specified by:
isSaltedin 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 sameChaosKeyconfiguration. Valid values range from {1..256} representable by one byte as of {0x00..0xFF}. Disclaimer: Using this option "stand alone" in aChaosKeynot in combination withChaosOptions.isSalted()either in thisChaosKeyor in combination with anotherChaosKeynot close by any means the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/chaos-based_encryption_revisited")- Specified by:
getRndPrefixSizein interfaceChaosOptions- Returns:
- The number of bytes for establishing the PREFIX functionality, 0 if no prefixing is to be applied at all.
-
toString
-
hashCode
-
equals
Returns true if all the passed object is of typeChaosOptionsand all the attributes from theChaosOptionsare equal to this instance's attributes (as ofChaosOptions.isMutateS(),ChaosOptions.isXorNext()andChaosOptions.isSalted()).- Specified by:
equalsin interfaceChaosOptions- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with for equality.- Returns:
- true, if equal
-
builder
Creates builder to buildChaosOptionsImpl.- Returns:
- created builder
-