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 management
andencryption/decryption
based onsymmetric
cryptography.- 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 CryptorConfig
getCryptorConfig()
SymmetricKeyConfig
getKeyConfig()
int
getKeyLength()
Decryptor
newDecryptor(K decryptionKey)
Decryptor
newDecryptorUnsafe(Key decryptionKey)
Please use typesafenewEncryptor
method instead to avoid mistakes (passing wrongKey
).Encryptor
newEncryptor(K encryptionKey)
Encryptor
newEncryptorUnsafe(Key encryptionKey)
Please use typesafenewDecryptor
method 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:
newKeyCreator
in interfaceKeyCreatorFactory
- Specified by:
newKeyCreator
in 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:
getKeyLength
in 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:
newDecryptor
in interfaceSymmetricCryptorFactory<K extends SecretKey>
- Parameters:
decryptionKey
- theSecretKey
to use for decryption.- Returns:
- the
Decryptor
for decryption.
-
newEncryptor
public Encryptor newEncryptor(K encryptionKey)
- Specified by:
newEncryptor
in interfaceSymmetricCryptorFactory<K extends SecretKey>
- Parameters:
encryptionKey
- theSecretKey
to use for encryption.- Returns:
- the
Encryptor
for encryption.
-
newEncryptorUnsafe
public Encryptor newEncryptorUnsafe(Key encryptionKey)
Description copied from interface:CryptorFactory
Please use typesafenewDecryptor
method instead to avoid mistakes (passing wrongKey
).- Specified by:
newEncryptorUnsafe
in interfaceCryptorFactory
- Parameters:
encryptionKey
- theKey
to use for encryption.- Returns:
- the
Encryptor
for encryption.
-
newDecryptorUnsafe
public Decryptor newDecryptorUnsafe(Key decryptionKey)
Description copied from interface:CryptorFactory
Please use typesafenewEncryptor
method instead to avoid mistakes (passing wrongKey
).- Specified by:
newDecryptorUnsafe
in interfaceCryptorFactory
- Parameters:
decryptionKey
- theKey
to use for decryption.- Returns:
- the
Decryptor
for decryption.
-
-