Skip to content

Instantly share code, notes, and snippets.

@kbsriram
Created June 6, 2013 23:22
Show Gist options
  • Save kbsriram/5725808 to your computer and use it in GitHub Desktop.
Save kbsriram/5725808 to your computer and use it in GitHub Desktop.
package org.ppdrive.crypto;
import org.bouncyrattle.bcpg.ContainedPacket;
import org.bouncyrattle.bcpg.PublicKeyEncSessionPacket;
import org.bouncyrattle.openpgp.PGPException;
import org.bouncyrattle.openpgp.PGPPublicKey;
import org.bouncyrattle.openpgp.operator.bc.BcPublicKeyKeyEncryptionMethodGenerator;
class CAnonymousPublicKeyKeyEncryptionMethodGenerator
extends BcPublicKeyKeyEncryptionMethodGenerator
{
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