diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-07-19 17:13:40 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2017-07-19 17:13:40 +0700 |
commit | e32961e6fa9ec43c9d4baaa0d906846b0a3ac2cc (patch) | |
tree | 68170f600dcde9fc3f46ca792d78ace047810f7c /crypto/src/openpgp/PgpPublicKey.cs | |
parent | Update project files for recent additions (diff) | |
download | BouncyCastle.NET-ed25519-e32961e6fa9ec43c9d4baaa0d906846b0a3ac2cc.tar.xz |
Fix GetValidSeconds for multi-sigs (port from Java version)
Diffstat (limited to '')
-rw-r--r-- | crypto/src/openpgp/PgpPublicKey.cs | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/crypto/src/openpgp/PgpPublicKey.cs b/crypto/src/openpgp/PgpPublicKey.cs index 904e29913..fc125e8c8 100644 --- a/crypto/src/openpgp/PgpPublicKey.cs +++ b/crypto/src/openpgp/PgpPublicKey.cs @@ -374,26 +374,37 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp return 0; } - private long GetExpirationTimeFromSig( - bool selfSigned, - int signatureType) + private long GetExpirationTimeFromSig(bool selfSigned, int signatureType) { + long expiryTime = -1; + long lastDate = -1; + foreach (PgpSignature sig in GetSignaturesOfType(signatureType)) { - if (!selfSigned || sig.KeyId == KeyId) - { - PgpSignatureSubpacketVector hashed = sig.GetHashedSubPackets(); + if (selfSigned && sig.KeyId != this.KeyId) + continue; + + PgpSignatureSubpacketVector hashed = sig.GetHashedSubPackets(); + if (hashed == null) + continue; - if (hashed != null) + long current = hashed.GetKeyExpirationTime(); + + if (sig.KeyId == this.KeyId) + { + if (sig.CreationTime.Ticks > lastDate) { - return hashed.GetKeyExpirationTime(); + lastDate = sig.CreationTime.Ticks; + expiryTime = current; } - - return 0; + } + else if (current == 0 || current > expiryTime) + { + expiryTime = current; } } - return -1; + return expiryTime; } /// <summary>The keyId associated with the public key.</summary> |