Package org.syncany.crypto
Class CipherSpecs
- java.lang.Object
-
- org.syncany.crypto.CipherSpecs
-
public class CipherSpecs extends java.lang.Object
Defines and identifies the application supportedCipherSpecs.These cipher specs are used by the
MultiCipherOutputStreamto encrypt data, and by theMultiCipherInputStreamto decrypt data. The cipher spec identifiers are used in the crypto format header to identify the crypto algorithms used for encryption.The class defines a well defined (and developer-approved) set of allowed cipher algorithms, modes and key sizes. The number of allowed ciphers is greatly restricted to follow the application-specific security standards. Most prominently, this includes:
- The block cipher mode must be authenticated (GCM, EAX, etc.). Unauthenticated
modes are not supported and will be rejected by the
CipherSpecsanity checks. - The block cipher mode must require an initialization vector (IV). Modes that do
not require an IV (e.g. ECB) will be rejected by the
CipherSpecsanity checks.
- The block cipher mode must be authenticated (GCM, EAX, etc.). Unauthenticated
modes are not supported and will be rejected by the
-
-
Field Summary
Fields Modifier and Type Field Description static intAES_128_GCMstatic intAES_256_GCMstatic int[]DEFAULT_CIPHER_SPECSstatic intTWOFISH_128_GCMstatic intTWOFISH_256_GCM
-
Constructor Summary
Constructors Constructor Description CipherSpecs()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.Integer,CipherSpec>getAvailableCipherSpecs()Returns a list of available/registeredCipherSpecs.static CipherSpecgetCipherSpec(int id)Retrieves an available/registeredCipherSpecusing the cipher spec identifier defined in this class.static java.util.List<CipherSpec>getDefaultCipherSpecs()Returns the defaultCipherSpecs used by the application.static voidregisterCipherSpec(int id, CipherSpec cipherSpec)Register a new cipher spec.
-
-
-
Field Detail
-
AES_128_GCM
public static final int AES_128_GCM
- See Also:
- Constant Field Values
-
TWOFISH_128_GCM
public static final int TWOFISH_128_GCM
- See Also:
- Constant Field Values
-
AES_256_GCM
public static final int AES_256_GCM
- See Also:
- Constant Field Values
-
TWOFISH_256_GCM
public static final int TWOFISH_256_GCM
- See Also:
- Constant Field Values
-
DEFAULT_CIPHER_SPECS
public static final int[] DEFAULT_CIPHER_SPECS
-
-
Constructor Detail
-
CipherSpecs
public CipherSpecs()
-
-
Method Detail
-
getAvailableCipherSpecs
public static java.util.Map<java.lang.Integer,CipherSpec> getAvailableCipherSpecs()
Returns a list of available/registeredCipherSpecs. Refer to theclass descriptionfor a more detailed explanation.
-
getDefaultCipherSpecs
public static java.util.List<CipherSpec> getDefaultCipherSpecs()
Returns the defaultCipherSpecs used by the application.
-
getCipherSpec
public static CipherSpec getCipherSpec(int id)
Retrieves an available/registeredCipherSpecusing the cipher spec identifier defined in this class.- Parameters:
id- Identifier of the cipher spec- Returns:
- A cipher spec, or
nullif no cipher spec with this identifier is registered
-
registerCipherSpec
public static void registerCipherSpec(int id, CipherSpec cipherSpec)
Register a new cipher spec.Note: Registering a cipher spec locally does not make it available on all clients. Unless a cipher spec is registered before a client tries to decrypt data using the
MultiCipherInputStream, the decryption process will fail.- Parameters:
id- Identifier of the cipher spec
-
-