Big error screen if signature is invalid or key is revoked/expired, also fixes signature status for expired and revoked keys
This commit is contained in:
@@ -25,6 +25,7 @@ import org.sufficientlysecure.keychain.util.IterableIterator;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/** A generic wrapped PGPKeyRing object.
|
||||
*
|
||||
@@ -76,6 +77,16 @@ public abstract class CanonicalizedKeyRing extends KeyRing {
|
||||
return getRing().getPublicKey().isRevoked();
|
||||
}
|
||||
|
||||
public boolean isExpired() throws PgpGeneralException {
|
||||
// Is the master key expired?
|
||||
Date creationDate = getRing().getPublicKey().getCreationTime();
|
||||
Date expiryDate = getRing().getPublicKey().getValidSeconds() > 0
|
||||
? new Date(creationDate.getTime() + getRing().getPublicKey().getValidSeconds() * 1000) : null;
|
||||
|
||||
Date now = new Date();
|
||||
return creationDate.after(now) || (expiryDate != null && expiryDate.before(now));
|
||||
}
|
||||
|
||||
public boolean canCertify() throws PgpGeneralException {
|
||||
return getRing().getPublicKey().isEncryptionKey();
|
||||
}
|
||||
|
||||
@@ -103,9 +103,14 @@ public class OpenPgpSignatureResultBuilder {
|
||||
Log.d(Constants.TAG, "signingRing.getUnorderedUserIds(): " + signingRing.getUnorderedUserIds());
|
||||
setUserIds(signingRing.getUnorderedUserIds());
|
||||
|
||||
// from KEY
|
||||
setKeyExpired(signingKey.isExpired());
|
||||
setKeyRevoked(signingKey.isRevoked());
|
||||
// either master key is expired/revoked or this specific subkey is expired/revoked
|
||||
try {
|
||||
setKeyExpired(signingRing.isExpired() || signingKey.isExpired());
|
||||
setKeyRevoked(signingRing.isRevoked() || signingKey.isRevoked());
|
||||
} catch (PgpGeneralException e) {
|
||||
Log.e(Constants.TAG, "shouldn't happen!");
|
||||
setKeyRevoked(true);
|
||||
}
|
||||
}
|
||||
|
||||
public OpenPgpSignatureResult build() {
|
||||
|
||||
Reference in New Issue
Block a user