Top Description Inners Fields Constructors Methods
org.bouncycastle.openpgp.operator.bc

public Class BcPublicKeyKeyEncryptionMethodGenerator

extends PublicKeyKeyEncryptionMethodGenerator
Class Inheritance
Imports
java.io.IOException, java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.asn1.edec.EdECObjectIdentifiers, org.bouncycastle.bcpg.ECDHPublicBCPGKey, .HashAlgorithmTags, .MPInteger, .PublicKeyAlgorithmTags, .PublicKeyPacket, .SymmetricKeyAlgorithmTags, org.bouncycastle.crypto.AsymmetricBlockCipher, .AsymmetricCipherKeyPair, .AsymmetricCipherKeyPairGenerator, .KeyGenerationParameters, .RawAgreement, .Wrapper, org.bouncycastle.crypto.agreement.ECDHBasicAgreement, .X25519Agreement, .X448Agreement, org.bouncycastle.crypto.generators.ECKeyPairGenerator, .X25519KeyPairGenerator, .X448KeyPairGenerator, org.bouncycastle.crypto.params.AsymmetricKeyParameter, .ECKeyGenerationParameters, .ECPublicKeyParameters, .KeyParameter, .ParametersWithRandom, .X25519KeyGenerationParameters, .X25519PublicKeyParameters, .X448KeyGenerationParameters, .X448PublicKeyParameters, org.bouncycastle.openpgp.PGPException, .PGPPublicKey, org.bouncycastle.openpgp.operator.PGPPad, .PublicKeyKeyEncryptionMethodGenerator, .RFC6637Utils, org.bouncycastle.util.Arrays, .BigIntegers

A method generator for supporting public key based encryption operations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface

Field Summary

Modifier and TypeField and Description
private BcPGPKeyConverter
private SecureRandom
private static final byte
Inherited from org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator:
SESSION_KEY_OBFUSCATION_PROPERTYsessionKeyObfuscationuseWildcardRecipientWILDCARDWILDCARD_FINGERPRINTWILDCARD_KEYID

Constructor Summary

AccessConstructor and Description
public
BcPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey
the public key to use for encryption.
key
)

Create a public key encryption method generator with the method to be based on the passed in key.

Method Summary

Modifier and TypeMethod and Description
protected byte[]
encryptSessionInfo(PGPPublicKey
recipients public key
pubKey
,
byte[]
session-key
sessionKey
,
byte
for v3: session key algorithm ID; for v6: 0
symAlgId
,
boolean isV3)

Implements abstract org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator.encryptSessionInfo.

Encrypt a session key using the recipients public key.

private byte[]

Returns:

encrypted session key
encryptSessionInfoWithECDHKey
(byte[]
sym alg ID (if v3 PKESK) + session key + 2 octets checksum
sessionInfo
,
byte[]
shared secret
secret
,
byte[]
UKM
userKeyingMaterial
,
byte[]
ephemeral public key encoding
ephPubEncoding
,
int
hash algorithm
hashAlgorithm
,
int
symmetric key algorithm
symmetricKeyAlgorithm
)

Encrypt the session info.

private byte[]
encryptSessionInfoWithX25519X448Key(PublicKeyPacket pubKeyPacket, byte[] sessionKey, int hashAlgorithm, int symmetricKeyAlgorithm, String algorithmName, AsymmetricCipherKeyPairGenerator gen, KeyGenerationParameters parameters, RawAgreement agreement, AsymmetricKeyParameter cryptoPublicKey, int keySize, BcPublicKeyKeyEncryptionMethodGenerator.EphPubEncodingOperation ephPubEncodingOperation, byte optSymAlgId)

private AsymmetricCipherKeyPair
private byte[]
getWrapper(int symmetricKeyAlgorithm, KeyParameter key, byte[] sessionData)

public BcPublicKeyKeyEncryptionMethodGenerator

Returns:

the current generator.
setSecureRandom
(SecureRandom
the secure random to be used.
random
)

Provide a user defined source of randomness.

Inherited from org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator:
createSessionInfoencodeEncryptedSessionInfogenerategetSessionInfosetSessionKeyObfuscationsetUseWildcardKeyIDsetUseWildcardRecipient

Field Detail

keyConverterback to summary
private BcPGPKeyConverter keyConverter
randomback to summary
private SecureRandom random
X_HDRback to summary
private static final byte X_HDR

Constructor Detail

BcPublicKeyKeyEncryptionMethodGeneratorback to summary
public BcPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key)

Create a public key encryption method generator with the method to be based on the passed in key.

Parameters
key:PGPPublicKey

the public key to use for encryption.

Method Detail

encryptSessionInfoback to summary
protected byte[] encryptSessionInfo(PGPPublicKey pubKey, byte[] sessionKey, byte symAlgId, boolean isV3) throws PGPException

Implements abstract org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator.encryptSessionInfo.

Doc from org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator.encryptSessionInfo.

Encrypt a session key using the recipients public key.

Parameters
pubKey:PGPPublicKey

recipients public key

sessionKey:byte[]

session-key

symAlgId:byte

for v3: session key algorithm ID; for v6: 0

Returns:byte[]

encrypted session info

Annotations
@Override
encryptSessionInfoWithECDHKeyback to summary
private byte[] encryptSessionInfoWithECDHKey(byte[] sessionInfo, byte[] secret, byte[] userKeyingMaterial, byte[] ephPubEncoding, int hashAlgorithm, int symmetricKeyAlgorithm) throws IOException, PGPException

Encrypt the session info.

Parameters
sessionInfo:byte[]

sym alg ID (if v3 PKESK) + session key + 2 octets checksum

secret:byte[]

shared secret

userKeyingMaterial:byte[]

UKM

ephPubEncoding:byte[]

ephemeral public key encoding

hashAlgorithm:int

hash algorithm

symmetricKeyAlgorithm:int

symmetric key algorithm

Returns:byte[]

encrypted session key

See Also
Session-Key Encryption using ECDH
encryptSessionInfoWithX25519X448Keyback to summary
private byte[] encryptSessionInfoWithX25519X448Key(PublicKeyPacket pubKeyPacket, byte[] sessionKey, int hashAlgorithm, int symmetricKeyAlgorithm, String algorithmName, AsymmetricCipherKeyPairGenerator gen, KeyGenerationParameters parameters, RawAgreement agreement, AsymmetricKeyParameter cryptoPublicKey, int keySize, BcPublicKeyKeyEncryptionMethodGenerator.EphPubEncodingOperation ephPubEncodingOperation, byte optSymAlgId) throws PGPException
getAsymmetricCipherKeyPairback to summary
private AsymmetricCipherKeyPair getAsymmetricCipherKeyPair(AsymmetricCipherKeyPairGenerator gen, KeyGenerationParameters parameters)
getWrapperback to summary
private byte[] getWrapper(int symmetricKeyAlgorithm, KeyParameter key, byte[] sessionData) throws PGPException
setSecureRandomback to summary
public BcPublicKeyKeyEncryptionMethodGenerator setSecureRandom(SecureRandom random)

Provide a user defined source of randomness.

Parameters
random:SecureRandom

the secure random to be used.

Returns:BcPublicKeyKeyEncryptionMethodGenerator

the current generator.

org.bouncycastle.openpgp.operator.bc back to summary

private Interface BcPublicKeyKeyEncryptionMethodGenerator.EphPubEncodingOperation

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
getEphPubEncoding(AsymmetricKeyParameter publicKey, byte[] ephPubEncoding)

Method Detail

getEphPubEncodingback to summary
public void getEphPubEncoding(AsymmetricKeyParameter publicKey, byte[] ephPubEncoding)