GetKeyExpirationTime() public method

Return the number of seconds a key is valid for after its creation date. A value of zero means the key never expires.
public GetKeyExpirationTime ( ) : long
return long
Exemplo n.º 1
0
        private long GetExpirationTimeFromSig(bool selfSigned, int signatureType)
        {
            long expiryTime = -1;
            long lastDate   = -1;

            foreach (PgpSignature sig in GetSignaturesOfType(signatureType))
            {
                if (selfSigned && sig.KeyId != this.KeyId)
                {
                    continue;
                }

                PgpSignatureSubpacketVector hashed = sig.GetHashedSubPackets();
                if (hashed == null)
                {
                    continue;
                }

                if (!hashed.HasSubpacket(SignatureSubpacketTag.KeyExpireTime))
                {
                    continue;
                }

                long current = hashed.GetKeyExpirationTime();

                if (sig.KeyId == this.KeyId)
                {
                    if (sig.CreationTime.Ticks > lastDate)
                    {
                        lastDate   = sig.CreationTime.Ticks;
                        expiryTime = current;
                    }
                }
                else if (current == 0 || current > expiryTime)
                {
                    expiryTime = current;
                }
            }

            return(expiryTime);
        }
Exemplo n.º 2
0
        private long GetExpirationTimeFromSig(
            bool selfSigned,
            int signatureType)
        {
            foreach (PgpSignature sig in GetSignaturesOfType(signatureType))
            {
                if (!selfSigned || sig.KeyId == KeyId)
                {
                    PgpSignatureSubpacketVector hashed = sig.GetHashedSubPackets();

                    if (hashed != null)
                    {
                        return(hashed.GetKeyExpirationTime());
                    }

                    return(0);
                }
            }

            return(-1);
        }