Module io.github.mmm.crypto
Class AsymmetricAccess<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey,PAIR extends AsymmetricKeyPair<PR,PU>,KC extends AsymmetricKeyCreator<PR,PU,PAIR>>
- java.lang.Object
-
- io.github.mmm.crypto.CryptoAccess
-
- io.github.mmm.crypto.asymmetric.access.AsymmetricAccess<S,PR,PU,PAIR,KC>
-
- Type Parameters:
S- type ofSignatureBinary.PR- type ofPrivateKey.PU- type ofPublicKey.PAIR- type ofAsymmetricKeyPair.KC- type ofAsymmetricKeyCreator.
- All Implemented Interfaces:
AbstractCryptoFactory,AsymmetricCryptorFactory<PR,PU>,AsymmetricKeyCreatorFactory<KC>,SignatureFactory<S>,SignatureProcessorFactory<S,PR,PU>,CryptorFactory,HashFactory,KeyCreatorFactory
- Direct Known Subclasses:
AsymmetricAccessEcBc,Rsa
public abstract class AsymmetricAccess<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey,PAIR extends AsymmetricKeyPair<PR,PU>,KC extends AsymmetricKeyCreator<PR,PU,PAIR>> extends CryptoAccess implements AsymmetricKeyCreatorFactory<KC>, AsymmetricCryptorFactory<PR,PU>, SignatureProcessorFactory<S,PR,PU>, HashFactory
Abstract base implementation of factory forkey management,encryption/decryption, andsignature managementbased onasymmetriccryptography.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description protected AsymmetricCryptorConfig<PR,PU>cryptorConfigprotected RandomFactoryrandomFactoryTheRandomFactory.
-
Constructor Summary
Constructors Constructor Description AsymmetricAccess(SignatureConfig<S> signatureConfig, AsymmetricCryptorConfig<PR,PU> cryptorConfig, RandomFactory randomFactory)The constructor.AsymmetricAccess(SignatureConfig<S> signatureConfig, SignatureProcessorFactory<S,PR,PU> signatureFactory, AsymmetricCryptorConfig<PR,PU> cryptorConfig, RandomFactory randomFactory)The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScreateSignature(byte[] data)AsymmetricCryptorConfig<PR,PU>getCryptorConfig()SignatureConfig<S>getSignatureConfig()SignatureProcessorFactory<S,PR,PU>getSignatureFactoryWithoutHash()DecryptornewDecryptor(PR privateKey)DecryptornewDecryptorUnsafe(Key decryptionKey)Please use typesafenewEncryptormethod instead to avoid mistakes (passing wrongKey).EncryptornewEncryptor(PU publicKey)EncryptornewEncryptorUnsafe(Key encryptionKey)Please use typesafenewDecryptormethod instead to avoid mistakes (passing wrongKey).HashCreatornewHashCreator()SignatureSigner<S>newSigner(PR privateKey)SignatureVerifier<S>newVerifier(PU publicKey)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.mmm.crypto.asymmetric.key.AsymmetricKeyCreatorFactory
newKeyCreator
-
Methods inherited from interface io.github.mmm.crypto.asymmetric.sign.SignatureProcessorFactory
newSignerUnsafe, newVerifierUnsafe
-
-
-
-
Field Detail
-
cryptorConfig
protected final AsymmetricCryptorConfig<PR extends PrivateKey,PU extends PublicKey> cryptorConfig
-
randomFactory
protected final RandomFactory randomFactory
TheRandomFactory.
-
-
Constructor Detail
-
AsymmetricAccess
public AsymmetricAccess(SignatureConfig<S> signatureConfig, AsymmetricCryptorConfig<PR,PU> cryptorConfig, RandomFactory randomFactory)
The constructor.- Parameters:
signatureConfig- theSignatureConfig.cryptorConfig- theAsymmetricCryptorConfig.randomFactory- theRandomFactory.
-
AsymmetricAccess
public AsymmetricAccess(SignatureConfig<S> signatureConfig, SignatureProcessorFactory<S,PR,PU> signatureFactory, AsymmetricCryptorConfig<PR,PU> cryptorConfig, RandomFactory randomFactory)
The constructor.- Parameters:
signatureConfig- theSignatureConfig.signatureFactory- theSignatureProcessorFactory.cryptorConfig- theAsymmetricCryptorConfig.randomFactory- theRandomFactory.
-
-
Method Detail
-
getSignatureConfig
public SignatureConfig<S> getSignatureConfig()
- Returns:
- the
SignatureConfig.
-
getCryptorConfig
public AsymmetricCryptorConfig<PR,PU> getCryptorConfig()
- Returns:
- the
AsymmetricCryptorConfig.
-
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.
-
newDecryptor
public Decryptor newDecryptor(PR privateKey)
- Specified by:
newDecryptorin interfaceAsymmetricCryptorFactory<S extends SignatureBinary,PR extends PrivateKey>- Parameters:
privateKey- thePrivateKeyto use for decryption.- Returns:
- the
Decryptorfor decryption.
-
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.
-
newEncryptor
public Encryptor newEncryptor(PU publicKey)
- Specified by:
newEncryptorin interfaceAsymmetricCryptorFactory<S extends SignatureBinary,PR extends PrivateKey>- Parameters:
publicKey- thePublicKeyto use for encryption.- Returns:
- the
Encryptorfor encryption.
-
newSigner
public SignatureSigner<S> newSigner(PR privateKey)
- Specified by:
newSignerin interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>- Parameters:
privateKey- thePrivateKeyto use for signing.- Returns:
- the
SignatureSignerfor signing.
-
newVerifier
public SignatureVerifier<S> newVerifier(PU publicKey)
- Specified by:
newVerifierin interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>- Parameters:
publicKey- thePublicKeyto use for verifying.- Returns:
- the
SignatureVerifierfor verifying.
-
createSignature
public S createSignature(byte[] data)
- Specified by:
createSignaturein interfaceSignatureFactory<S extends SignatureBinary>- Parameters:
data- thebinary signature data.- Returns:
- the deserialized
SignatureBinary.
-
newHashCreator
public HashCreator newHashCreator()
- Specified by:
newHashCreatorin interfaceHashFactory- Returns:
- a new instance of
HashCreatorfor the configured hash algorithm of this factory.
-
getSignatureFactoryWithoutHash
public SignatureProcessorFactory<S,PR,PU> getSignatureFactoryWithoutHash()
- Specified by:
getSignatureFactoryWithoutHashin interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>- Returns:
- an instance of this
SignatureFactorythat does not hash before signing so you can control the hashing manually and only sign the resulting hash (e.g. to reuse the hash value for further calculations).
-
-