1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-17 18:02:05 +01:00

Add ImplementationFactory.getSessionKeyDataDecryptorFactory() and impls

This commit is contained in:
Paul Schaub 2022-09-13 20:22:12 +02:00
parent 8dfabf1842
commit 9e403c1124
3 changed files with 22 additions and 0 deletions

View file

@ -113,6 +113,11 @@ public class BcImplementationFactory extends ImplementationFactory {
return new BcPublicKeyDataDecryptorFactory(privateKey);
}
@Override
public SessionKeyDataDecryptorFactory getSessionKeyDataDecryptorFactory(PGPSessionKey sessionKey) {
return new BcSessionKeyDataDecryptorFactory(sessionKey);
}
@Override
public PublicKeyKeyEncryptionMethodGenerator getPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key) {
return new BcPublicKeyKeyEncryptionMethodGenerator(key);

View file

@ -32,6 +32,7 @@ import org.pgpainless.algorithm.HashAlgorithm;
import org.pgpainless.algorithm.PublicKeyAlgorithm;
import org.pgpainless.algorithm.SymmetricKeyAlgorithm;
import org.pgpainless.util.Passphrase;
import org.pgpainless.util.SessionKey;
public abstract class ImplementationFactory {
@ -91,6 +92,16 @@ public abstract class ImplementationFactory {
public abstract PublicKeyDataDecryptorFactory getPublicKeyDataDecryptorFactory(PGPPrivateKey privateKey);
public SessionKeyDataDecryptorFactory getSessionKeyDataDecryptorFactory(SessionKey sessionKey) {
PGPSessionKey pgpSessionKey = new PGPSessionKey(
sessionKey.getAlgorithm().getAlgorithmId(),
sessionKey.getKey()
);
return getSessionKeyDataDecryptorFactory(pgpSessionKey);
}
public abstract SessionKeyDataDecryptorFactory getSessionKeyDataDecryptorFactory(PGPSessionKey sessionKey);
public abstract PublicKeyKeyEncryptionMethodGenerator getPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key);
public abstract PBEKeyEncryptionMethodGenerator getPBEKeyEncryptionMethodGenerator(Passphrase passphrase);

View file

@ -103,6 +103,12 @@ public class JceImplementationFactory extends ImplementationFactory {
.build(privateKey);
}
@Override
public SessionKeyDataDecryptorFactory getSessionKeyDataDecryptorFactory(PGPSessionKey sessionKey) {
return new JceSessionKeyDataDecryptorFactoryBuilder()
.build(sessionKey);
}
public PublicKeyKeyEncryptionMethodGenerator getPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key) {
return new JcePublicKeyKeyEncryptionMethodGenerator(key)
.setProvider(ProviderFactory.getProvider());