Package org.bouncycastle.openpgp.api
Interface OpenPGPPolicy
- All Known Implementing Classes:
OpenPGPDefaultPolicy
public interface OpenPGPPolicy
Policy for OpenPGP algorithms and features.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classTheOpenPGPPolicy.OpenPGPNotationRegistrycan be used to register known notations, such that signatures containing notation instances of the same name, which are marked as critical do not invalidate the signature. -
Method Summary
Modifier and TypeMethodDescriptionintReturn the default certification signature hash algorithm ID.intReturn the default document signature hash algorithm ID.intReturn the default symmetric-key algorithm, which is used as a fallback if symmetric encryption algorithm negotiation fails.Return the policiesOpenPGPPolicy.OpenPGPNotationRegistrycontaining known notation names.default booleanReturn true, if thePGPSignatureuses an acceptable certification signature hash algorithm.default booleanReturn true, if thePGPSignatureuses an acceptable data/document signature hash algorithm.default booleanReturn true, if thePGPSignatureuses an acceptable revocation signature hash algorithm.default booleanhasAcceptableSignatureHashAlgorithm(PGPSignature signature) Return true, if the givenPGPSignaturewas made using an acceptable signature hash algorithm.default booleanhasNoCriticalUnknownNotations(PGPSignature signature) Return true, if the hashed subpacket area of the signature does NOT contain unknown critical notations.default booleanhasNoCriticalUnknownSubpackets(PGPSignature signature) Return true, if the hashed subpacket area of the signature does NOT contain unknown critical subpackets.booleanisAcceptableCertificationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable certification signature hash algorithm.default booleanReturn true, if the givenPGPPublicKeyis acceptable for decrypting messages.booleanisAcceptableDocumentSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable document signature hash algorithm.default booleanReturn true, if the givenPGPPublicKeyis acceptable for encrypting messages.default booleanReturn true, if the givenPGPPublicKeyis acceptable.booleanisAcceptablePublicKeyStrength(int publicKeyAlgorithmId, int bitStrength) Return true, if the given bitStrength is acceptable for the given public key algorithm ID.booleanisAcceptableRevocationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable revocation signature hash algorithm.default booleanisAcceptableSignature(PGPSignature signature) Return true, if the givenPGPSignatureis acceptable (uses acceptable hash algorithm, does not contain unknown critical notations or subpackets).default booleanReturn true, if the givenPGPPublicKeyis an acceptable signing key.booleanisAcceptableSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) Return true, if the given symmetric-key algorithm is acceptable.default booleanReturn true, if the givenPGPPublicKeyis an acceptable signature verification key.default booleanisKnownSignatureSubpacket(int signatureSubpacketTag) Return true, if the given signature subpacket ID is known by the implementation.
-
Method Details
-
isAcceptableSigningKey
Return true, if the givenPGPPublicKeyis an acceptable signing key. Note: Although signing requires a secret key, we perform checks on the public part for consistency.- Parameters:
key- key- Returns:
- true if acceptable signing key
-
isAcceptableVerificationKey
Return true, if the givenPGPPublicKeyis an acceptable signature verification key. Note: The asymmetry between this andisAcceptableSigningKey(PGPPublicKey)is useful to prevent creation of signatures using a legacy key, while still allowing verification of signatures made using the same key.- Parameters:
key- key- Returns:
- true if acceptable verification key
-
isAcceptableEncryptionKey
Return true, if the givenPGPPublicKeyis acceptable for encrypting messages.- Parameters:
key- key- Returns:
- true if acceptable encryption key
-
isAcceptableDecryptionKey
Return true, if the givenPGPPublicKeyis acceptable for decrypting messages. Note: Although decryption requires a secret key, we perform checks on the public part for consistency. The asymmetry between this andisAcceptableEncryptionKey(PGPPublicKey)is useful to prevent creation of new encrypted messages using a legacy key, while still allowing decryption of existing messages using the same key.- Parameters:
key- key- Returns:
- true if acceptable decryption key
-
isAcceptablePublicKey
Return true, if the givenPGPPublicKeyis acceptable.- Parameters:
key- key- Returns:
- true if acceptable key
-
isAcceptableSignature
Return true, if the givenPGPSignatureis acceptable (uses acceptable hash algorithm, does not contain unknown critical notations or subpackets). Note: A signature being acceptable does NOT mean that it is correct or valid.- Parameters:
signature- signature- Returns:
- true if acceptable
-
hasAcceptableSignatureHashAlgorithm
Return true, if the givenPGPSignaturewas made using an acceptable signature hash algorithm.- Parameters:
signature- signature- Returns:
- true if hash algorithm is acceptable
-
hasAcceptableDocumentSignatureHashAlgorithm
Return true, if thePGPSignatureuses an acceptable data/document signature hash algorithm.- Parameters:
signature- data / document signature- Returns:
- true if hash algorithm is acceptable
-
hasAcceptableRevocationSignatureHashAlgorithm
Return true, if thePGPSignatureuses an acceptable revocation signature hash algorithm.- Parameters:
signature- revocation signature- Returns:
- true if hash algorithm is acceptable
-
hasAcceptableCertificationSignatureHashAlgorithm
Return true, if thePGPSignatureuses an acceptable certification signature hash algorithm.- Parameters:
signature- certification signature- Returns:
- true if hash algorithm is acceptable
-
hasNoCriticalUnknownNotations
Return true, if the hashed subpacket area of the signature does NOT contain unknown critical notations.- Parameters:
signature- signature- Returns:
- true if signature is free from unknown critical notations
-
hasNoCriticalUnknownSubpackets
Return true, if the hashed subpacket area of the signature does NOT contain unknown critical subpackets.- Parameters:
signature- signature- Returns:
- true if signature is free from unknown critical subpackets
-
isKnownSignatureSubpacket
default boolean isKnownSignatureSubpacket(int signatureSubpacketTag) Return true, if the given signature subpacket ID is known by the implementation. Note: This method is only called for subpackets not recognized bySignatureSubpacketInputStream.- Parameters:
signatureSubpacketTag- signature subpacket ID- Returns:
- true if subpacket tag is known
-
isAcceptableDocumentSignatureHashAlgorithm
Return true, if the given hash algorithm is - at signature creation time - an acceptable document signature hash algorithm.- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
isAcceptableRevocationSignatureHashAlgorithm
boolean isAcceptableRevocationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable revocation signature hash algorithm.- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
isAcceptableCertificationSignatureHashAlgorithm
boolean isAcceptableCertificationSignatureHashAlgorithm(int hashAlgorithmId, Date signatureCreationTime) Return true, if the given hash algorithm is - at signature creation time - an acceptable certification signature hash algorithm.- Parameters:
hashAlgorithmId- hash algorithm IDsignatureCreationTime- optional signature creation time- Returns:
- true if hash algorithm is acceptable at creation time
-
getDefaultCertificationSignatureHashAlgorithm
int getDefaultCertificationSignatureHashAlgorithm()Return the default certification signature hash algorithm ID. This is used as fallback, if negotiation of a commonly supported hash algorithm fails.- Returns:
- default certification signature hash algorithm ID
-
getDefaultDocumentSignatureHashAlgorithm
int getDefaultDocumentSignatureHashAlgorithm()Return the default document signature hash algorithm ID. This is used as fallback, if negotiation of a commonly supported hash algorithm fails.- Returns:
- default document signature hash algorithm ID
-
isAcceptableSymmetricKeyAlgorithm
boolean isAcceptableSymmetricKeyAlgorithm(int symmetricKeyAlgorithmId) Return true, if the given symmetric-key algorithm is acceptable.- Parameters:
symmetricKeyAlgorithmId- symmetric-key algorithm- Returns:
- true if symmetric-key algorithm is acceptable
-
getDefaultSymmetricKeyAlgorithm
int getDefaultSymmetricKeyAlgorithm()Return the default symmetric-key algorithm, which is used as a fallback if symmetric encryption algorithm negotiation fails.- Returns:
- default symmetric-key algorithm
-
isAcceptablePublicKeyStrength
boolean isAcceptablePublicKeyStrength(int publicKeyAlgorithmId, int bitStrength) Return true, if the given bitStrength is acceptable for the given public key algorithm ID.- Parameters:
publicKeyAlgorithmId- ID of a public key algorithmbitStrength- key bit strength- Returns:
- true if strength is acceptable
-
getNotationRegistry
OpenPGPPolicy.OpenPGPNotationRegistry getNotationRegistry()Return the policiesOpenPGPPolicy.OpenPGPNotationRegistrycontaining known notation names.- Returns:
- notation registry
-