mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -05:00
ditch outdated certifyKey operation
This commit is contained in:
parent
4d091d1784
commit
9f947aefe6
@ -481,58 +481,4 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Certify the given pubkeyid with the given masterkeyid.
|
|
||||||
*
|
|
||||||
* @param certificationKey Certifying key
|
|
||||||
* @param publicKey public key to certify
|
|
||||||
* @param userIds User IDs to certify, must not be null or empty
|
|
||||||
* @param passphrase Passphrase of the secret key
|
|
||||||
* @return A keyring with added certifications
|
|
||||||
*/
|
|
||||||
public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey,
|
|
||||||
List<String> userIds, String passphrase)
|
|
||||||
throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException,
|
|
||||||
PGPException, SignatureException {
|
|
||||||
|
|
||||||
// create a signatureGenerator from the supplied masterKeyId and passphrase
|
|
||||||
PGPSignatureGenerator signatureGenerator;
|
|
||||||
{
|
|
||||||
|
|
||||||
if (certificationKey == null) {
|
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_no_signature_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
|
|
||||||
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.toCharArray());
|
|
||||||
PGPPrivateKey signaturePrivateKey = certificationKey.extractPrivateKey(keyDecryptor);
|
|
||||||
if (signaturePrivateKey == null) {
|
|
||||||
throw new PgpGeneralMsgIdException(R.string.error_could_not_extract_private_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: SHA256 fixed?
|
|
||||||
JcaPGPContentSignerBuilder contentSignerBuilder = new JcaPGPContentSignerBuilder(
|
|
||||||
certificationKey.getPublicKey().getAlgorithm(), PGPUtil.SHA256)
|
|
||||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
|
|
||||||
|
|
||||||
signatureGenerator = new PGPSignatureGenerator(contentSignerBuilder);
|
|
||||||
signatureGenerator.init(PGPSignature.DEFAULT_CERTIFICATION, signaturePrivateKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // supply signatureGenerator with a SubpacketVector
|
|
||||||
PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
|
|
||||||
PGPSignatureSubpacketVector packetVector = spGen.generate();
|
|
||||||
signatureGenerator.setHashedSubpackets(packetVector);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch public key ring, add the certification and return it
|
|
||||||
for (String userId : new IterableIterator<String>(userIds.iterator())) {
|
|
||||||
PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey);
|
|
||||||
publicKey = PGPPublicKey.addCertification(publicKey, userId, sig);
|
|
||||||
}
|
|
||||||
|
|
||||||
return publicKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user