php8.5
Home/ Manual/ reference / openssl/ Purpose checking flags

Purpose checking flags

Verify the certificate for use as an OCSP responder helper. Available as of PHP 8.4.0.

Predefined Constants Constants

Purpose checking flags

X509_PURPOSE_SSL_CLIENT (int)
X509_PURPOSE_SSL_SERVER (int)
X509_PURPOSE_NS_SSL_SERVER (int)
X509_PURPOSE_SMIME_SIGN (int)
X509_PURPOSE_SMIME_ENCRYPT (int)
X509_PURPOSE_CRL_SIGN (int)
X509_PURPOSE_ANY (int)
X509_PURPOSE_OCSP_HELPER (int)

Verify the certificate for use as an OCSP responder helper. Available as of PHP 8.4.0.

X509_PURPOSE_TIMESTAMP_SIGN (int)

Verify the certificate for use as a trusted time stamp signer. Available as of PHP 8.4.0.

Padding flags for asymmetric encryption

OPENSSL_PKCS1_PADDING (int)
OPENSSL_SSLV23_PADDING (int)
OPENSSL_NO_PADDING (int)
OPENSSL_PKCS1_OAEP_PADDING (int)
OPENSSL_PKCS1_PSS_PADDING (int)

RSA-PSS padding. Available as of PHP 8.5.0.

Key types

OPENSSL_KEYTYPE_RSA (int)

RSA key type.

OPENSSL_KEYTYPE_DSA (int)

DSA key type.

OPENSSL_KEYTYPE_DH (int)

DH (Diffie-Hellman) key type.

OPENSSL_KEYTYPE_EC (int)

Elliptic curve key type.

OPENSSL_KEYTYPE_X25519 (int)

X25519 curve key type. This constant is only available when PHP is compiled with OpenSSL 3.0+.

OPENSSL_KEYTYPE_ED25519 (int)

Ed25519 curve key type. This constant is only available when PHP is compiled with OpenSSL 3.0+.

OPENSSL_KEYTYPE_X448 (int)

X448 curve key type. This constant is only available when PHP is compiled with OpenSSL 3.0+.

OPENSSL_KEYTYPE_ED448 (int)

Ed448 curve key type. This constant is only available when PHP is compiled with OpenSSL 3.0+.

PKCS7 Flags/Constants

The S/MIME functions make use of flags which are specified using a bitfield which can include one or more of the following values:

ConstantDescription
PKCS7_TEXT (int)Adds text/plain content type headers to encrypted/signed message. If decrypting or verifying, it strips those headers from the output - if the decrypted or verified message is not of MIME type text/plain then an error will occur.
PKCS7_BINARY (int)Normally the input message is converted to "canonical" format which is effectively using CR and LF as end of line: as required by the S/MIME specification. When this option is present, no translation occurs. This is useful when handling binary data which may not be in MIME format.
PKCS7_NOINTERN (int)When verifying a message, certificates (if any) included in the message are normally searched for the signing certificate. With this option only the certificates specified in the untrusted_certificates_filename parameter of openssl_pkcs7_verify() are used. The supplied certificates can still be used as untrusted CAs however.
PKCS7_NOVERIFY (int)Do not verify the signers certificate of a signed message.
PKCS7_NOCHAIN (int)Do not chain verification of signers certificates: that is don't use the certificates in the signed message as untrusted CAs.
PKCS7_NOCERTS (int)When signing a message the signer's certificate is normally included - with this option it is excluded. This will reduce the size of the signed message but the verifier must have a copy of the signers certificate available locally (passed using the untrusted_certificates_filename to openssl_pkcs7_verify() for example).
PKCS7_NOATTR (int)Normally when a message is signed, a set of attributes are included which include the signing time and the supported symmetric algorithms. With this option they are not included.
PKCS7_DETACHED (int)When signing a message, use cleartext signing with the MIME type "multipart/signed". This is the default if you do not specify any flags to openssl_pkcs7_sign(). If you turn this option off, the message will be signed using opaque signing, which is more resistant to translation by mail relays but cannot be read by mail agents that do not support S/MIME.
PKCS7_NOSIGS (int)Don't try and verify the signatures on a message
PKCS7_NOOLDMIMETYPE (int)Available as of PHP 8.3.0. Sets the content-type to application/pkcs7-mime instead of application/x-pkcs7-mime to encrypt a message.
PKCS7_NOSMIMECAP (int)Available as of PHP 8.5.0. Do not include the S/MIME capabilities (SMIMECapabilities) in the signature.
PKCS7_CRLFEOL (int)Available as of PHP 8.5.0. Use CRLF as the end of line in the output.
PKCS7_NOCRL (int)Available as of PHP 8.5.0. Do not include the CRLs in the PKCS7 structure.
PKCS7_NO_DUAL_CONTENT (int)Available as of PHP 8.5.0. Do not include the duplicate content, avoiding the duplication of the signed content.

CMS Flags/Constants

The CMS functions make use of flags which are specified using a bitfield which can include one or more of the following values:

ConstantDescription
OPENSSL_CMS_TEXT (int)Adds text/plain content type headers to encrypted/signed message. If decrypting or verifying, it strips those headers from the output - if the decrypted or verified message is not of MIME type text/plain then an error will occur.
OPENSSL_CMS_BINARY (int)Normally the input message is converted to "canonical" format which is effectively using CR and LF as end of line: as required by the CMS specification. When this option is present, no translation occurs. This is useful when handling binary data which may not be in CMS format.
OPENSSL_CMS_NOINTERN (int)When verifying a message, certificates (if any) included in the message are normally searched for the signing certificate. With this option only the certificates specified in the untrusted_certificates_filename parameter of openssl_cms_verify() are used. The supplied certificates can still be used as untrusted CAs however.
OPENSSL_CMS_NOVERIFY (int)Do not verify the signers certificate of a signed message.
OPENSSL_CMS_NOCERTS (int)When signing a message the signer's certificate is normally included - with this option it is excluded. This will reduce the size of the signed message but the verifier must have a copy of the signers certificate available locally (passed using the untrusted_certificates_filename to openssl_cms_verify() for example).
OPENSSL_CMS_NOATTR (int)Normally when a message is signed, a set of attributes are included which include the signing time and the supported symmetric algorithms. With this option they are not included.
OPENSSL_CMS_DETACHED (int)When signing a message, use cleartext signing with the MIME type "multipart/signed". This is the default if you do not specify any flags to openssl_cms_sign(). If you turn this option off, the message will be signed using opaque signing, which is more resistant to translation by mail relays but cannot be read by mail agents that do not support S/MIME.
OPENSSL_CMS_NOSIGS (int)Don't try and verify the signatures on a message
OPENSSL_CMS_OLDMIMETYPE (int)Available as of PHP 8.3.0. Sets the content-type to application/x-pkcs7-mime instead of application/pkcs7-mime to encrypt a message.

Signature Algorithms

OPENSSL_ALGO_DSS1 (int)
OPENSSL_ALGO_SHA1 (int)

Used as default algorithm by openssl_sign() and openssl_verify().

OPENSSL_ALGO_SHA224 (int)
OPENSSL_ALGO_SHA256 (int)
OPENSSL_ALGO_SHA384 (int)
OPENSSL_ALGO_SHA512 (int)
OPENSSL_ALGO_RMD160 (int)
OPENSSL_ALGO_MD5 (int)
OPENSSL_ALGO_MD4 (int)
OPENSSL_ALGO_MD2 (int)

This constant is only available if PHP is compiled with MD2 support. This requires passing in the -DHAVE_OPENSSL_MD2_H CFLAG when compiling PHP, and enable-md2 when compiling OpenSSL 1.0.0+.

Ciphers

OPENSSL_DEFAULT_STREAM_CIPHERS (string)

List of default ciphers.

OPENSSL_CIPHER_RC2_40 (int)
OPENSSL_CIPHER_RC2_128 (int)
OPENSSL_CIPHER_RC2_64 (int)
OPENSSL_CIPHER_DES (int)
OPENSSL_CIPHER_3DES (int)
OPENSSL_CIPHER_AES_128_CBC (int)
OPENSSL_CIPHER_AES_192_CBC (int)
OPENSSL_CIPHER_AES_256_CBC (int)

Version constants

OPENSSL_VERSION_TEXT (string)
OPENSSL_VERSION_NUMBER (int)

Server Name Indication constants

OPENSSL_TLSEXT_SERVER_NAME (int)

Whether SNI support is available or not.

Note

This constant requires PHP to be built with OpenSSL 0.9.8j or greater.

Other Constants

OPENSSL_RAW_DATA (int)

Used with openssl_encrypt() and openssl_decrypt() to indicate that data should be in raw binary format rather than base64-encoded. See the respective function descriptions for details.

OPENSSL_DONT_ZERO_PAD_KEY (int)

Prevents openssl_encrypt() from padding keys that are shorter than the default key length.

OPENSSL_ZERO_PADDING (int)

By default encryption operations are padded using standard block padding and the padding is checked and removed when decrypting. If OPENSSL_ZERO_PADDING is set in the openssl_encrypt() or openssl_decrypt() options then no padding is performed, the total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur.

OPENSSL_ENCODING_SMIME (int)

Indicates that encoding is S/MIME.

OPENSSL_ENCODING_DER (int)

Indicates that encoding is DER.

OPENSSL_ENCODING_PEM (int)

Indicates that encoding is PEM.

Source: reference/openssl/constants.xml · from the official PHP manual (php/doc-en)