Module io.github.mmm.crypto
Class SymmetricAccess<K extends SecretKey>
- java.lang.Object
-
- io.github.mmm.crypto.CryptoAccess
-
- io.github.mmm.crypto.symmetric.access.SymmetricAccess<K>
-
- Type Parameters:
K- type ofSecretKey.
- All Implemented Interfaces:
AbstractCryptoFactory,CryptorFactory,AbstractGetKeyLength,KeyCreatorFactory,SymmetricCryptorFactory<K>,SymmetricKeyCreatorFactory<SymmetricKeyCreator<K>>
- Direct Known Subclasses:
PbeAccess
public abstract class SymmetricAccess<K extends SecretKey> extends CryptoAccess implements SymmetricKeyCreatorFactory<SymmetricKeyCreator<K>>, SymmetricCryptorFactory<K>, AbstractGetKeyLength
Abstract base implementation of factory forkey managementandencryption/decryptionbased onsymmetriccryptography.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description SymmetricAccess(SymmetricKeyConfig keyConfig, CryptorConfig cryptorConfig)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CryptorConfiggetCryptorConfig()SymmetricKeyConfiggetKeyConfig()intgetKeyLength()DecryptornewDecryptor(K decryptionKey)DecryptornewDecryptorUnsafe(Key decryptionKey)Please use typesafenewEncryptormethod instead to avoid mistakes (passing wrongKey).EncryptornewEncryptor(K encryptionKey)EncryptornewEncryptorUnsafe(Key encryptionKey)Please use typesafenewDecryptormethod instead to avoid mistakes (passing wrongKey).SymmetricKeyCreator<K>newKeyCreator()
-
-
-
Constructor Detail
-
SymmetricAccess
public SymmetricAccess(SymmetricKeyConfig keyConfig, CryptorConfig cryptorConfig)
The constructor.- Parameters:
keyConfig- theSymmetricKeyConfig.cryptorConfig- theCryptorConfig.
-
-
Method Detail
-
newKeyCreator
public SymmetricKeyCreator<K> newKeyCreator()
- Specified by:
newKeyCreatorin interfaceKeyCreatorFactory- Specified by:
newKeyCreatorin interfaceSymmetricKeyCreatorFactory<K extends SecretKey>- Returns:
- a new instance of
KeyCreator. May be reused but is not guaranteed to be thread-safe.
-
getKeyConfig
public SymmetricKeyConfig getKeyConfig()
- Returns:
- the
SymmetricKeyConfig.
-
getCryptorConfig
public CryptorConfig getCryptorConfig()
- Returns:
- the
CryptorConfig.
-
getKeyLength
public int getKeyLength()
- Specified by:
getKeyLengthin interfaceAbstractGetKeyLength- Returns:
- the length of the key in bits. The bigger the key length the stronger and more secure the encryption but
also the more performance is required for computation. Reasonable values depend on the
algorithm: A recent value for RSA is 4096 bits while for PBKDF2 256 is sufficient. However, recommended and secure values change over time as computing power is increasing. Therefore you should research the web to find an accurate value.
-
newDecryptor
public Decryptor newDecryptor(K decryptionKey)
- Specified by:
newDecryptorin interfaceSymmetricCryptorFactory<K extends SecretKey>- Parameters:
decryptionKey- theSecretKeyto use for decryption.- Returns:
- the
Decryptorfor decryption.
-
newEncryptor
public Encryptor newEncryptor(K encryptionKey)
- Specified by:
newEncryptorin interfaceSymmetricCryptorFactory<K extends SecretKey>- Parameters:
encryptionKey- theSecretKeyto use for encryption.- Returns:
- the
Encryptorfor encryption.
-
newEncryptorUnsafe
public Encryptor newEncryptorUnsafe(Key encryptionKey)
Description copied from interface:CryptorFactoryPlease use typesafenewDecryptormethod instead to avoid mistakes (passing wrongKey).- Specified by:
newEncryptorUnsafein interfaceCryptorFactory- Parameters:
encryptionKey- theKeyto use for encryption.- Returns:
- the
Encryptorfor encryption.
-
newDecryptorUnsafe
public Decryptor newDecryptorUnsafe(Key decryptionKey)
Description copied from interface:CryptorFactoryPlease use typesafenewEncryptormethod instead to avoid mistakes (passing wrongKey).- Specified by:
newDecryptorUnsafein interfaceCryptorFactory- Parameters:
decryptionKey- theKeyto use for decryption.- Returns:
- the
Decryptorfor decryption.
-
-