Class Policy.HashAlgorithmPolicy

  • Enclosing class:
    Policy

    public static final class Policy.HashAlgorithmPolicy
    extends java.lang.Object
    • Constructor Detail

      • HashAlgorithmPolicy

        public HashAlgorithmPolicy​(@Nonnull
                                   HashAlgorithm defaultHashAlgorithm,
                                   @Nonnull
                                   java.util.Map<HashAlgorithm,​java.util.Date> algorithmTerminationDates)
        Create a Policy.HashAlgorithmPolicy which accepts all HashAlgorithms from the given map, if the queried usage date is BEFORE the respective termination date. A termination date value of
        null
        means no termination, resulting in the algorithm being acceptable, regardless of usage date.
        Parameters:
        defaultHashAlgorithm - default hash algorithm
        algorithmTerminationDates - map of acceptable algorithms and their termination dates
      • HashAlgorithmPolicy

        public HashAlgorithmPolicy​(@Nonnull
                                   HashAlgorithm defaultHashAlgorithm,
                                   @Nonnull
                                   java.util.List<HashAlgorithm> acceptableHashAlgorithms)
        Create a Policy.HashAlgorithmPolicy which accepts all HashAlgorithms listed in the given list, regardless of usage date.
        Parameters:
        defaultHashAlgorithm - default hash algorithm (e.g. used as fallback if negotiation fails)
        acceptableHashAlgorithms - list of acceptable hash algorithms
    • Method Detail

      • defaultHashAlgorithm

        public HashAlgorithm defaultHashAlgorithm()
        Return the default hash algorithm. This algorithm is used as a fallback when no consensus about hash algorithms can be reached.
        Returns:
        default hash algorithm
      • isAcceptable

        public boolean isAcceptable​(@Nonnull
                                    HashAlgorithm hashAlgorithm)
        Return true if the given hash algorithm is currently acceptable by this policy.
        Parameters:
        hashAlgorithm - hash algorithm
        Returns:
        true if the hash algorithm is acceptable, false otherwise
      • isAcceptable

        public boolean isAcceptable​(int algorithmId)
        Return true if the given hash algorithm is currently acceptable by this policy.
        Parameters:
        algorithmId - hash algorithm
        Returns:
        true if the hash algorithm is acceptable, false otherwise
      • isAcceptable

        public boolean isAcceptable​(@Nonnull
                                    HashAlgorithm hashAlgorithm,
                                    @Nonnull
                                    java.util.Date usageDate)
        Return true, if the given algorithm is acceptable for the given usage date.
        Parameters:
        hashAlgorithm - algorithm
        usageDate - usage date (e.g. signature creation time)
        Returns:
        acceptance
      • isAcceptable

        public boolean isAcceptable​(int algorithmId,
                                    @Nonnull
                                    java.util.Date usageDate)
      • defaultSignatureAlgorithmPolicy

        @Deprecated
        public static Policy.HashAlgorithmPolicy defaultSignatureAlgorithmPolicy()
        Deprecated.
        not expressive - will be removed in an upcoming release
        The default signature hash algorithm policy of PGPainless. Note that this policy is only used for non-revocation signatures. For revocation signatures defaultRevocationSignatureHashAlgorithmPolicy() is used instead.
        Returns:
        default signature hash algorithm policy
      • smartSignatureHashAlgorithmPolicy

        public static Policy.HashAlgorithmPolicy smartSignatureHashAlgorithmPolicy()
        Policy.HashAlgorithmPolicy which takes the date of the algorithm usage into consideration. If the policy has a termination date for a given algorithm, and the usage date is after that termination date, the algorithm is rejected. This policy is inspired by Sequoia-PGP's collision resistant algorithm policy.
        Returns:
        smart signature algorithm policy
        See Also:
        Sequoia-PGP's Collision Resistant Algorithm Policy
      • static2022SignatureHashAlgorithmPolicy

        public static Policy.HashAlgorithmPolicy static2022SignatureHashAlgorithmPolicy()
        Policy.HashAlgorithmPolicy which only accepts signatures made using algorithms which are acceptable according to 2022 standards. Particularly this policy only accepts algorithms from the SHA2 family.
        Returns:
        static signature algorithm policy
      • defaultRevocationSignatureHashAlgorithmPolicy

        @Deprecated
        public static Policy.HashAlgorithmPolicy defaultRevocationSignatureHashAlgorithmPolicy()
        Deprecated.
        not expressive - will be removed in an upcoming release
        The default revocation signature hash algorithm policy of PGPainless.
        Returns:
        default revocation signature hash algorithm policy
      • static2022RevocationSignatureHashAlgorithmPolicy

        public static Policy.HashAlgorithmPolicy static2022RevocationSignatureHashAlgorithmPolicy()
        Hash algorithm policy for revocation signatures, which accepts SHA1 and SHA2 algorithms, as well as RIPEMD160.
        Returns:
        static revocation signature hash algorithm policy