&reftitle.constants; &extension.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`)

## Padding flags for asymmetric encryption

`OPENSSL_PKCS1_PADDING` (`int`)

`OPENSSL_SSLV23_PADDING` (`int`)

`OPENSSL_NO_PADDING` (`int`)

`OPENSSL_PKCS1_OAEP_PADDING` (`int`)

## Key types

`OPENSSL_KEYTYPE_RSA` (`int`)

`OPENSSL_KEYTYPE_DSA` (`int`)

`OPENSSL_KEYTYPE_DH` (`int`)

`OPENSSL_KEYTYPE_EC` (`int`)

- This constant is only available when PHP is compiled with OpenSSL 0.9.8+.

## 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:

## PKCS7 CONSTANTS

Constant | Description
`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 `extracerts` 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 `extracerts` 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.

## 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:

## CMS CONSTANTS

Constant | Description
`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_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.

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

## Other Constants

`OPENSSL_RAW_DATA` (`int`)

- If `OPENSSL_RAW_DATA` is set in the `openssl_encrypt` or `openssl_decrypt`, the returned data is returned as-is. When it is not specified, Base64 encoded data is returned to the caller.

`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.