Skip to content

Commit b2a8fe1

Browse files
committed
Add check of proof fingerprint vs key-being-verified fingerprint
1 parent bce2f85 commit b2a8fe1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • Lib/src/main/java/com/textuality/keybase/lib/prover

Lib/src/main/java/com/textuality/keybase/lib/prover/Prover.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,25 @@
5252
* How to use:
5353
* 1. call fetchProofData(), which will exhibit network latency. If it returns false the proof
5454
* verification failed; an explanation can be found in the log.
55-
* 2. fetch the PGP message with getPgpMessage(), check that it’s signed with the right fingerprint
55+
* 2. call checkFingerprint(), passing it the fingerprint of the key you’re checking up on; if
56+
* if it returns false the verification failed.
57+
* 3. fetch the PGP message with getPgpMessage(), check that it’s signed with the right fingerprint
5658
* (see above).
57-
* 3. Call dnsTxtCheckRequired() and if it returns non-null, the return value is a domain name;
59+
* 4. Call dnsTxtCheckRequired() and if it returns non-null, the return value is a domain name;
5860
* retrieve TXT records from that domain and pass them to checkDnsTxt(); if it returns false
5961
* the proof verification failed; an explanation can be found in the log.
60-
* 4. call rawMessageCheckRequired() and if it returns true, feed the raw (de-armored) bytes
62+
* 5. call rawMessageCheckRequired() and if it returns true, feed the raw (de-armored) bytes
6163
* of the message to checkRawMessageBytes(). if it returns false the proof verification failed;
6264
* an explanation can be found in the log. This may exhibit crypto latency.
63-
* 5. Pass the message to validate(), which should have no real latency. If it returns false the
65+
* 6. Pass the message to validate(), which should have no real latency. If it returns false the
6466
* proof verification failed; an explanation can be found in the log.
6567
*/
6668
public abstract class Prover {
6769

6870
String mPgpMessage;
6971
String mPayload;
7072
String mShortenedMessageHash;
73+
String mFingerprintUsedInProof = null;
7174
final Proof mProof;
7275
final List<String> mLog = new ArrayList<String>();
7376

@@ -94,6 +97,10 @@ public String getPgpMessage() {
9497
return mPgpMessage;
9598
}
9699

100+
public boolean checkFingerprint(String fingerprint) {
101+
return fingerprint.equalsIgnoreCase(mFingerprintUsedInProof);
102+
}
103+
97104
public boolean validate(String decryptedMessage) {
98105
return mPayload.equals(decryptedMessage);
99106
}
@@ -111,6 +118,7 @@ JSONObject readSig(String sigId) throws JSONException, KeybaseException {
111118
sigJSON = JWalk.getArray(sigJSON, "sigs").getJSONObject(0);
112119
mPayload = JWalk.getString(sigJSON, "payload_json");
113120
mPgpMessage = JWalk.getString(sigJSON, "sig");
121+
mFingerprintUsedInProof = JWalk.getString(sigJSON, "fingerprint");
114122

115123
mLog.add("Extracted payload & message from sig");
116124

0 commit comments

Comments
 (0)