if (methods.size() == 1)
{
if (methods.get(0) instanceof PBEKeyEncryptionMethodGenerator)
{
PBEKeyEncryptionMethodGenerator m = (PBEKeyEncryptionMethodGenerator)methods.get(0);
key = m.getKey(dataEncryptorBuilder.getAlgorithm());
pOut.writePacket(((PGPKeyEncryptionMethodGenerator)methods.get(0)).generate(defAlgorithm, null));
}
else
{
key = PGPUtil.makeRandomKey(defAlgorithm, rand);
byte[] sessionInfo = createSessionInfo(defAlgorithm, key);
PGPKeyEncryptionMethodGenerator m = (PGPKeyEncryptionMethodGenerator)methods.get(0);
pOut.writePacket(m.generate(defAlgorithm, sessionInfo));
}
}
else // multiple methods
{
key = PGPUtil.makeRandomKey(defAlgorithm, rand);
byte[] sessionInfo = createSessionInfo(defAlgorithm, key);
for (int i = 0; i != methods.size(); i++)
{
PGPKeyEncryptionMethodGenerator m = (PGPKeyEncryptionMethodGenerator)methods.get(i);
pOut.writePacket(m.generate(defAlgorithm, sessionInfo));
}
}
try
{