begin refactor

This commit is contained in:
Ashley Hughes 2014-01-14 15:48:05 +00:00
parent bb0baa815e
commit cd4a3dd237

View File

@ -927,20 +927,12 @@ public class PgpOperation {
if (tmp_subkeyBinding_isok) if (tmp_subkeyBinding_isok)
subkeyBinding_isok = true; subkeyBinding_isok = true;
if (tmp_subkeyBinding_isok) { if (tmp_subkeyBinding_isok) {
PGPSignatureSubpacketVector hPkts = sig.getHashedSubPackets(); primkeyBinding_isok = verifyPrimaryBinding(sig.getUnhashedSubPackets(), mKey, signatureKey);
PGPSignatureSubpacketVector uhPkts = sig.getUnhashedSubPackets(); if (primkeyBinding_isok)
if (uhPkts.hasSubpacket(SignatureSubpacketTags.EMBEDDED_SIGNATURE)) { break;
PGPSignatureList eSigList = uhPkts.getEmbeddedSignatures(); primkeyBinding_isok = verifyPrimaryBinding(sig.getHashedSubPackets(), mKey, signatureKey);
for (int j = 0; j < eSigList.size(); ++j) { if (primkeyBinding_isok)
PGPSignature emSig = eSigList.get(j); break;
emSig.init(contentVerifierBuilderProvider, signatureKey);
primkeyBinding_isok = emSig.verifyCertification(mKey, signatureKey);
if (primkeyBinding_isok)
break;
}
}
if (hPkts.hasSubpacket(SignatureSubpacketTags.EMBEDDED_SIGNATURE)) {
}
} }
} }
} }
@ -954,6 +946,40 @@ public class PgpOperation {
return returnData; return returnData;
} }
private boolean verifyPrimaryBinding(PGPSignatureSubpacketVector Pkts, PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey)
{
boolean primkeyBinding_isok = false;
JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider()
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
PGPSignatureList eSigList;
if (Pkts.hasSubpacket(SignatureSubpacketTags.EMBEDDED_SIGNATURE)) {
try {
eSigList = Pkts.getEmbeddedSignatures();
} catch (IOException e) {
return false;
} catch (PGPException e) {
return false;
}
for (int j = 0; j < eSigList.size(); ++j) {
PGPSignature emSig = eSigList.get(j);
if (emSig.getSignatureType() == PGPSignature.PRIMARYKEY_BINDING) {
try {
emSig.init(contentVerifierBuilderProvider, signingPublicKey);
primkeyBinding_isok = emSig.verifyCertification(masterPublicKey, signingPublicKey);
if (primkeyBinding_isok)
break;
} catch (PGPException e) {
continue;
} catch (SignatureException e) {
continue;
}
}
}
}
return primkeyBinding_isok;
}
private static void processLine(final String pLine, final ArmoredOutputStream pArmoredOutput, private static void processLine(final String pLine, final ArmoredOutputStream pArmoredOutput,
final PGPSignatureGenerator pSignatureGenerator) throws IOException, SignatureException { final PGPSignatureGenerator pSignatureGenerator) throws IOException, SignatureException {