Package org.refcodes.security.alt.chaos
Interface ChaosOptions
-
- All Superinterfaces:
org.refcodes.mixin.EncodedAccessor
- All Known Implementing Classes:
ChaosMode
,ChaosOptionsBuilder
public interface ChaosOptions extends org.refcodes.mixin.EncodedAccessor
TheChaosOptions
interface provides configuration means for the Chaos-based encryption and may be provided to the constructor of theChaosKey
e.g. as one of theChaosMode
enumerations. Disclaimer: Using the options "stand alone" in aChaosKey
not in combination withisSalted()
either in thisChaosKey
or in combination with anotherChaosKey
does not (completely) close the "comparison" attack vector (see "https://www.metacodes.pro/funcodes/blog/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 int
ENCODED_LENGTH
The overall encoded length in bytes of theChaosOptions
.static int
OPTIONS_BIT_MUTATE_S
The bit position of theisMutateS()
option when creating the encoded representation as ofgetEncoded()
.static int
OPTIONS_BIT_RND_PREFIX
The bit position of thehasRndPrefix()
option when creating the encoded representation as ofgetEncoded()
.static int
OPTIONS_BIT_SALTED
The bit position of theisSalted()
option when creating the encoded representation as ofgetEncoded()
.static int
OPTIONS_BIT_XOR_NEXT
The bit position of theisXorNext()
option when creating the encoded representation as ofgetEncoded()
.static int
OPTIONS_BYTES
The number of bytes required to store theChaosOptions
flags.static int
PREFIX_SIZE_BYZES
The number of bytes required to store theChaosOptions
RND prefix size (as ofgetRndPrefixSize()
).
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
equals(Object aObj)
Returns true if all the passed object is of typeChaosOptions
and all the attributes from theChaosOptions
are equal to this instance's attributes (as ofisMutateS()
,isXorNext()
andisSalted()
).default byte[]
getEncoded()
Returns the options in their primary encoding format.static int
getEncodedLength()
Returns the length of thisChaosOptions
when represented as bytes (as ofgetEncoded()
).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.default boolean
hasRndPrefix()
default boolean
isFixedLength()
Determines whether applying an according configuredChaosKey
associates one element of the encrypted data with exactly one element of the decrypted (raw) data: AnyChaosOptions
option affecting the length of the encrypted data compared to the length of the decrypted (raw) data is considered in this context not(!)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).
-
-
-
Field Detail
-
OPTIONS_BIT_MUTATE_S
static final int OPTIONS_BIT_MUTATE_S
The bit position of theisMutateS()
option when creating the encoded representation as ofgetEncoded()
.- See Also:
- Constant Field Values
-
OPTIONS_BIT_XOR_NEXT
static final int OPTIONS_BIT_XOR_NEXT
The bit position of theisXorNext()
option when creating the encoded representation as ofgetEncoded()
.- See Also:
- Constant Field Values
-
OPTIONS_BIT_SALTED
static final int OPTIONS_BIT_SALTED
The bit position of theisSalted()
option when creating the encoded representation as ofgetEncoded()
.- See Also:
- Constant Field Values
-
OPTIONS_BIT_RND_PREFIX
static final int OPTIONS_BIT_RND_PREFIX
The bit position of thehasRndPrefix()
option when creating the encoded representation as ofgetEncoded()
.- See Also:
- Constant Field Values
-
OPTIONS_BYTES
static final int OPTIONS_BYTES
The number of bytes required to store theChaosOptions
flags.- See Also:
- Constant Field Values
-
PREFIX_SIZE_BYZES
static final int PREFIX_SIZE_BYZES
The number of bytes required to store theChaosOptions
RND prefix size (as ofgetRndPrefixSize()
).- See Also:
- Constant Field Values
-
ENCODED_LENGTH
static final int ENCODED_LENGTH
The overall encoded length in bytes of theChaosOptions
.- See Also:
- Constant Field Values
-
-
Method Detail
-
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 aChaosKey
not in combination withisSalted()
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")- 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 aChaosKey
not in combination withisSalted()
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")- 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 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!- 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 sameChaosKey
configuration. Disclaimer: Using this option "stand alone" in aChaosKey
not in combination withisSalted()
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")- 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 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 withisSalted()
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")- 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 configuredChaosKey
associates one element of the encrypted data with exactly one element of the decrypted (raw) data: AnyChaosOptions
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 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 theChaosEncryptionOutputStream
or theChaosDecryptionInputStream
!- 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 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_NEXT
andOPTIONS_BIT_SALTED
.- Specified by:
getEncoded
in interfaceorg.refcodes.mixin.EncodedAccessor
- Returns:
- The encoded options being the according byte(s) representing the
ChaosOptions
.
-
getEncodedLength
static int getEncodedLength()
Returns the length of thisChaosOptions
when represented as bytes (as ofgetEncoded()
).- 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 typeChaosOptions
and all the attributes from theChaosOptions
are equal to this instance's attributes (as ofisMutateS()
,isXorNext()
andisSalted()
).
-
-