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 management
based onasymmetric
cryptography.- Since:
- 1.0.0
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description protected AsymmetricCryptorConfig<PR,PU>
cryptorConfig
protected RandomFactory
randomFactory
TheRandomFactory
.
-
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 S
createSignature(byte[] data)
AsymmetricCryptorConfig<PR,PU>
getCryptorConfig()
SignatureConfig<S>
getSignatureConfig()
SignatureProcessorFactory<S,PR,PU>
getSignatureFactoryWithoutHash()
Decryptor
newDecryptor(PR privateKey)
Decryptor
newDecryptorUnsafe(Key decryptionKey)
Please use typesafenewEncryptor
method instead to avoid mistakes (passing wrongKey
).Encryptor
newEncryptor(PU publicKey)
Encryptor
newEncryptorUnsafe(Key encryptionKey)
Please use typesafenewDecryptor
method instead to avoid mistakes (passing wrongKey
).HashCreator
newHashCreator()
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: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.
-
newDecryptor
public Decryptor newDecryptor(PR privateKey)
- Specified by:
newDecryptor
in interfaceAsymmetricCryptorFactory<S extends SignatureBinary,PR extends PrivateKey>
- Parameters:
privateKey
- thePrivateKey
to use for decryption.- Returns:
- the
Decryptor
for decryption.
-
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.
-
newEncryptor
public Encryptor newEncryptor(PU publicKey)
- Specified by:
newEncryptor
in interfaceAsymmetricCryptorFactory<S extends SignatureBinary,PR extends PrivateKey>
- Parameters:
publicKey
- thePublicKey
to use for encryption.- Returns:
- the
Encryptor
for encryption.
-
newSigner
public SignatureSigner<S> newSigner(PR privateKey)
- Specified by:
newSigner
in interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>
- Parameters:
privateKey
- thePrivateKey
to use for signing.- Returns:
- the
SignatureSigner
for signing.
-
newVerifier
public SignatureVerifier<S> newVerifier(PU publicKey)
- Specified by:
newVerifier
in interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>
- Parameters:
publicKey
- thePublicKey
to use for verifying.- Returns:
- the
SignatureVerifier
for verifying.
-
createSignature
public S createSignature(byte[] data)
- Specified by:
createSignature
in interfaceSignatureFactory<S extends SignatureBinary>
- Parameters:
data
- thebinary signature data
.- Returns:
- the deserialized
SignatureBinary
.
-
newHashCreator
public HashCreator newHashCreator()
- Specified by:
newHashCreator
in interfaceHashFactory
- Returns:
- a new instance of
HashCreator
for the configured hash algorithm of this factory.
-
getSignatureFactoryWithoutHash
public SignatureProcessorFactory<S,PR,PU> getSignatureFactoryWithoutHash()
- Specified by:
getSignatureFactoryWithoutHash
in interfaceSignatureProcessorFactory<S extends SignatureBinary,PR extends PrivateKey,PU extends PublicKey>
- Returns:
- an instance of this
SignatureFactory
that 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).
-
-