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 supportedCipherSpec
s.These cipher specs are used by the
MultiCipherOutputStream
to encrypt data, and by theMultiCipherInputStream
to 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
CipherSpec
sanity 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
CipherSpec
sanity 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 int
AES_128_GCM
static int
AES_256_GCM
static int[]
DEFAULT_CIPHER_SPECS
static int
TWOFISH_128_GCM
static int
TWOFISH_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/registeredCipherSpec
s.static CipherSpec
getCipherSpec(int id)
Retrieves an available/registeredCipherSpec
using the cipher spec identifier defined in this class.static java.util.List<CipherSpec>
getDefaultCipherSpecs()
Returns the defaultCipherSpec
s used by the application.static void
registerCipherSpec(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/registeredCipherSpec
s. Refer to theclass description
for a more detailed explanation.
-
getDefaultCipherSpecs
public static java.util.List<CipherSpec> getDefaultCipherSpecs()
Returns the defaultCipherSpec
s used by the application.
-
getCipherSpec
public static CipherSpec getCipherSpec(int id)
Retrieves an available/registeredCipherSpec
using the cipher spec identifier defined in this class.- Parameters:
id
- Identifier of the cipher spec- Returns:
- A cipher spec, or
null
if 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
-
-