prerequisite for #278
parseDecryptMsg currently accepts these values: { keys: PrvKeyInfo[], msgPwd: string?, isEmail: boolean }
I'd like to add optional verificationPubkeys: string[]? which will accept an array of armored public keys.
This will get passed into:
const decryptRes = await PgpMsg.decrypt({ kisWithPp, msgPwd, encryptedData: Buf.with(rawBlock.content) });
// which is
public static decrypt: PgpMsgMethod.Decrypt = async ({ kisWithPp, encryptedData, msgPwd }) => {
in the PgpMsg.decrypt method you need to edit const keys = await PgpMsg.getSortedKeys(kisWithPp, prepared.message); to accept this array as well (optionally - can be undefined), which means updating the signature of private static getSortedKeys = async (kiWithPp: PrvKeyInfo[], msg: OpenpgpMsgOrCleartext): Promise<SortedKeysForDecrypt> => { to accept it.
Then finally in getSortedKeys, this line:
await PgpMsg.cryptoMsgGetSignedBy(msg, keys);
should be changed to something like:
if(typeof verificationPubkeys !== 'undefined') {
keys.forVerification = [];
for (const verificationPubkey of verificationPubkeys) {
const { keys: keysForVerification } = await openpgp.key.readArmored(verificationPubkey);
keys.forVerification.push(...keysForVerification);
}
} else {
await PgpMsg.cryptoMsgGetSignedBy(msg, keys);
}
Then please remove everything related to keys.verificationContacts, which includes changing singature of PpgMsg.verify to not accept a Contact? and not return it either.
Once you do all that, and run parseDecryptMsg, you should see it return verification results automatically.
This issue should involve the following tests:
prerequisite for #278
parseDecryptMsgcurrently accepts these values:{ keys: PrvKeyInfo[], msgPwd: string?, isEmail: boolean }I'd like to add optional
verificationPubkeys: string[]?which will accept an array of armored public keys.This will get passed into:
in the
PgpMsg.decryptmethod you need to editconst keys = await PgpMsg.getSortedKeys(kisWithPp, prepared.message);to accept this array as well (optionally - can be undefined), which means updating the signature ofprivate static getSortedKeys = async (kiWithPp: PrvKeyInfo[], msg: OpenpgpMsgOrCleartext): Promise<SortedKeysForDecrypt> => {to accept it.Then finally in
getSortedKeys, this line:should be changed to something like:
Then please remove everything related to
keys.verificationContacts, which includes changing singature ofPpgMsg.verifyto not accept aContact?and not return it either.Once you do all that, and run
parseDecryptMsg, you should see it return verification results automatically.This issue should involve the following tests: