Package org.refcodes.security.alt.chaos
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
FieldsModifier and TypeFieldDescriptionstatic final intThe overall encoded length in bytes of theChaosOptions.static final intThe bit position of theisMutateS()option when creating the encoded representation as ofgetEncoded().static final intThe bit position of thehasRndPrefix()option when creating the encoded representation as ofgetEncoded().static final intThe bit position of theisSalted()option when creating the encoded representation as ofgetEncoded().static final intThe bit position of theisXorNext()option when creating the encoded representation as ofgetEncoded().static final intThe number of bytes required to store theChaosOptionsflags.static final intThe number of bytes required to store theChaosOptionsRND prefix size (as ofgetRndPrefixSize()). -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if all the passed object is of typeChaosOptionsand all the attributes from theChaosOptionsare equal to this instance's attributes (as ofisMutateS(),isXorNext()andisSalted()).default byte[]Returns the options in their primary encoding format.static intReturns the length of thisChaosOptionswhen represented as bytes (as ofgetEncoded()).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.default booleandefault booleanDetermines whether applying an according configuredChaosKeyassociates one element of the encrypted data with exactly one element of the decrypted (raw) data: AnyChaosOptionsoption affecting the length of the encrypted data compared to the length of the decrypted (raw) data is considered in this context not(!)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).
-
Field Details
-
OPTIONS_BIT_MUTATE_S
static final int OPTIONS_BIT_MUTATE_SThe bit position of theisMutateS()option when creating the encoded representation as ofgetEncoded().- See Also:
-
OPTIONS_BIT_XOR_NEXT
static final int OPTIONS_BIT_XOR_NEXTThe bit position of theisXorNext()option when creating the encoded representation as ofgetEncoded().- See Also:
-
OPTIONS_BIT_SALTED
static final int OPTIONS_BIT_SALTEDThe bit position of theisSalted()option when creating the encoded representation as ofgetEncoded().- See Also:
-
OPTIONS_BIT_RND_PREFIX
static final int OPTIONS_BIT_RND_PREFIXThe bit position of thehasRndPrefix()option when creating the encoded representation as ofgetEncoded().- See Also:
-
OPTIONS_BYTES
static final int OPTIONS_BYTESThe number of bytes required to store theChaosOptionsflags.- See Also:
-
PREFIX_SIZE_BYZES
static final int PREFIX_SIZE_BYZESThe number of bytes required to store theChaosOptionsRND prefix size (as ofgetRndPrefixSize()).- See Also:
-
ENCODED_LENGTH
-
-
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 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 withisSalted()either in thisChaosKeyor in combination with anotherChaosKeynot 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 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 withisSalted()either in thisChaosKeyor in combination with anotherChaosKeynot 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)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!- Returns:
- True in case SALTING is to be established.
-
hasRndPrefix
default boolean hasRndPrefix()Determines whether a PREFIX operation of theChaosKey'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 sameChaosKeyconfiguration. Disclaimer: Using this option "stand alone" in aChaosKeynot in combination withisSalted()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")- 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 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 withisSalted()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")- 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 configuredChaosKeyassociates one element of the encrypted data with exactly one element of the decrypted (raw) data: AnyChaosOptionsoption 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 lengthChaosKey. E.g. salting (being declared with theisSalted()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 theChaosEncryptionOutputStreamor theChaosDecryptionInputStream!- Returns:
- True when these
ChaosOptionsrepresent an injective configuration.
-
getEncoded
default byte[] getEncoded()Returns the options in their primary encoding format. Returns the bytes in a defined order representing theChaosOptions. The values use a big endian representation. The byte array being returned is of the size as returned bygetEncodedLength(). The meaning of the bits in the encoded byte are defined as inOPTIONS_BIT_MUTATE_S,OPTIONS_BIT_XOR_NEXTandOPTIONS_BIT_SALTED.- Specified by:
getEncodedin interfaceorg.refcodes.mixin.EncodedAccessor- Returns:
- The encoded options being the according byte(s) representing the
ChaosOptions.
-
getEncodedLength
static int getEncodedLength()Returns the length of thisChaosOptionswhen represented as bytes (as ofgetEncoded()).- Returns:
- The number of bytes required to represent a
ChaosOptionssettings.
-
equals
Returns true if all the passed object is of typeChaosOptionsand all the attributes from theChaosOptionsare equal to this instance's attributes (as ofisMutateS(),isXorNext()andisSalted()).
-