* Add signing key details to signature. Validate if sender identity matches signature. * @param {Array} signatures * @param {KeyringBase} keyring
({signatures = [], keyring, senderAddress})
| 110 | * @param {KeyringBase} keyring |
| 111 | */ |
| 112 | async function addSignatureDetails({signatures = [], keyring, senderAddress}) { |
| 113 | let senderKeys; |
| 114 | if (senderAddress) { |
| 115 | // valid sender keys for verification of the message are keys with the sender email address as user ID |
| 116 | ({[senderAddress]: senderKeys} = await keyring.getKeyByAddress(senderAddress)); |
| 117 | } |
| 118 | for (const signature of signatures) { |
| 119 | if (signature.valid === null) { |
| 120 | continue; |
| 121 | } |
| 122 | const signingKey = keyring.keystore.getKeysForId(signature.fingerprint ?? signature.keyId, true); |
| 123 | if (signingKey) { |
| 124 | [signature.keyDetails] = await mapKeys(signingKey); |
| 125 | } |
| 126 | if (!signature.valid) { |
| 127 | continue; |
| 128 | } |
| 129 | if (senderKeys) { |
| 130 | if (!senderKeys.length) { |
| 131 | // we don't have the sender email and therefore the connection between this signature and the sender is uncertain |
| 132 | signature.uncertainSender = true; |
| 133 | } else if (!senderKeys.some(key => key.getKeys(keyIDfromHex(signature)).length)) { |
| 134 | // sender email is not present in user ID of key that created this signature |
| 135 | signature.senderMismatch = true; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | export function noKeyFoundError(encryptionKeyIds) { |
| 142 | const keyId = encryptionKeyIds[0].toHex(); |
no test coverage detected