Package org.syncany.crypto
Class CipherSpec
- java.lang.Object
-
- org.syncany.crypto.CipherSpec
-
- Direct Known Subclasses:
AesGcmCipherSpec,HmacSha256CipherSpec,TwofishGcmCipherSpec
public abstract class CipherSpec extends java.lang.Object
A cipher spec represents the definition of a cipher/encryption algorithm and the corresponding settings required to instantiate a new cipher object.Cipher specs are identified by an identifier (id), which will (when the cipher spec is used by the
MultiCipherOutputStream) be written to the output file format. When the file is read byMultiCipherInputStream, the identifier is looked up using theCipherSpecsclass.While it would be technically possible to define any kind of cipher using this class, this class restricts the allowed algorithms to a few ones that are considered secure.
Instantiating a cipher spec that does pass the sanity checks will result in a RuntimeException.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.PatternALLOWED_CIPHER_ALGORITHMS
-
Constructor Summary
Constructors Constructor Description CipherSpec(int id, java.lang.String algorithm, int keySize, int ivSize, boolean needsUnlimitedStrength)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetAlgorithm()intgetId()intgetIvSize()intgetKeySize()inthashCode()booleanneedsUnlimitedStrength()abstract java.io.InputStreamnewCipherInputStream(java.io.InputStream underlyingInputStream, byte[] secretKey, byte[] iv)abstract java.io.OutputStreamnewCipherOutputStream(java.io.OutputStream underlyingOutputStream, byte[] secretKey, byte[] iv)java.lang.StringtoString()
-
-
-
Field Detail
-
ALLOWED_CIPHER_ALGORITHMS
public static final java.util.regex.Pattern ALLOWED_CIPHER_ALGORITHMS
-
-
Constructor Detail
-
CipherSpec
public CipherSpec(int id, java.lang.String algorithm, int keySize, int ivSize, boolean needsUnlimitedStrength)
-
-
Method Detail
-
getId
public int getId()
-
needsUnlimitedStrength
public boolean needsUnlimitedStrength()
-
getAlgorithm
public java.lang.String getAlgorithm()
-
getKeySize
public int getKeySize()
-
getIvSize
public int getIvSize()
-
newCipherOutputStream
public abstract java.io.OutputStream newCipherOutputStream(java.io.OutputStream underlyingOutputStream, byte[] secretKey, byte[] iv) throws CipherException
- Throws:
CipherException
-
newCipherInputStream
public abstract java.io.InputStream newCipherInputStream(java.io.InputStream underlyingInputStream, byte[] secretKey, byte[] iv) throws CipherException
- Throws:
CipherException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-