Package org.pgpainless.policy
Class Policy.HashAlgorithmPolicy
java.lang.Object
org.pgpainless.policy.Policy.HashAlgorithmPolicy
- Enclosing class:
Policy
-
Constructor Summary
ConstructorsConstructorDescriptionHashAlgorithmPolicy
(HashAlgorithm defaultHashAlgorithm, List<HashAlgorithm> acceptableHashAlgorithms) Create aPolicy.HashAlgorithmPolicy
which accepts allHashAlgorithms
listed in the given list, regardless of usage date.HashAlgorithmPolicy
(HashAlgorithm defaultHashAlgorithm, Map<HashAlgorithm, Date> algorithmTerminationDates) Create aPolicy.HashAlgorithmPolicy
which accepts allHashAlgorithms
from the given map, if the queried usage date is BEFORE the respective termination date. -
Method Summary
Modifier and TypeMethodDescriptionReturn the default hash algorithm.static Policy.HashAlgorithmPolicy
Deprecated.not expressive - will be removed in an upcoming releasestatic Policy.HashAlgorithmPolicy
Deprecated.not expressive - will be removed in an upcoming releaseboolean
isAcceptable
(int algorithmId) Return true if the given hash algorithm is currently acceptable by this policy.boolean
isAcceptable
(int algorithmId, Date usageDate) boolean
isAcceptable
(HashAlgorithm hashAlgorithm) Return true if the given hash algorithm is currently acceptable by this policy.boolean
isAcceptable
(HashAlgorithm hashAlgorithm, Date usageDate) Return true, if the given algorithm is acceptable for the given usage date.static Policy.HashAlgorithmPolicy
Policy.HashAlgorithmPolicy
which takes the date of the algorithm usage into consideration.static Policy.HashAlgorithmPolicy
Hash algorithm policy for revocation signatures, which accepts SHA1 and SHA2 algorithms, as well as RIPEMD160.static Policy.HashAlgorithmPolicy
Policy.HashAlgorithmPolicy
which only accepts signatures made using algorithms which are acceptable according to 2022 standards.
-
Constructor Details
-
HashAlgorithmPolicy
public HashAlgorithmPolicy(@Nonnull HashAlgorithm defaultHashAlgorithm, @Nonnull Map<HashAlgorithm, Date> algorithmTerminationDates) Create aPolicy.HashAlgorithmPolicy
which accepts allHashAlgorithms
from the given map, if the queried usage date is BEFORE the respective termination date. A termination date value ofnull
means no termination, resulting in the algorithm being acceptable, regardless of usage date.- Parameters:
defaultHashAlgorithm
- default hash algorithmalgorithmTerminationDates
- map of acceptable algorithms and their termination dates
-
HashAlgorithmPolicy
public HashAlgorithmPolicy(@Nonnull HashAlgorithm defaultHashAlgorithm, @Nonnull List<HashAlgorithm> acceptableHashAlgorithms) Create aPolicy.HashAlgorithmPolicy
which accepts allHashAlgorithms
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 Details
-
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
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
Return true, if the given algorithm is acceptable for the given usage date.- Parameters:
hashAlgorithm
- algorithmusageDate
- usage date (e.g. signature creation time)- Returns:
- acceptance
-
isAcceptable
-
defaultSignatureAlgorithmPolicy
Deprecated.not expressive - will be removed in an upcoming releaseThe default signature hash algorithm policy of PGPainless. Note that this policy is only used for non-revocation signatures. For revocation signaturesdefaultRevocationSignatureHashAlgorithmPolicy()
is used instead.- Returns:
- default signature hash algorithm policy
-
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:
-
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 releaseThe default revocation signature hash algorithm policy of PGPainless.- Returns:
- default revocation signature hash algorithm policy
-
static2022RevocationSignatureHashAlgorithmPolicy
Hash algorithm policy for revocation signatures, which accepts SHA1 and SHA2 algorithms, as well as RIPEMD160.- Returns:
- static revocation signature hash algorithm policy
-