Skip to content

Instantly share code, notes, and snippets.

@kbsriram
Created March 16, 2012 15:57
Show Gist options
  • Save kbsriram/2050672 to your computer and use it in GitHub Desktop.
Save kbsriram/2050672 to your computer and use it in GitHub Desktop.
anonymous keyid recipients
import org.bouncycastle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.bcpg.ContainedPacket;
import org.bouncycastle.bcpg.PublicKeyEncSessionPacket;
public class CAnonymousPublicKeyKeyEncryptionMethodGenerator
extends BcPublicKeyKeyEncryptionMethodGenerator
{
public CAnonymousPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key)
{
super(key);
m_pubkey = key;
}
// generate a wildcard keyid rather than embedding it into
// the content.
@Override
public ContainedPacket generate(int encAlg, byte[] sessionInfo)
throws PGPException
{
return new PublicKeyEncSessionPacket
(0l, m_pubkey.getAlgorithm(),
processSessionInfo
(encryptSessionInfo
(m_pubkey, sessionInfo)));
}
private final PGPPublicKey m_pubkey;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment