OPENSSL_VERSION_TEXT
OPENSSL_VERSION_TEXT = 'BoringSSL (node:crypto)'
| OpenSSLAsymmetricKey | A key, holding PEM text rather than a native handle. |
| OpenSSLCertificate | A certificate, holding its PEM text. |
cfw_openssl_degraded(string $capability, string $why) : void
Declares a failure to the operator, the way curl-fix.ts does.
A per-call trigger_error reaches the log and never the status report, and a failed verify had neither -- so a caller misreading -1 as "forged" was invisible from outside.
| string | $capability | The capability that degraded. |
| string | $why | Why it did. |
cfw_openssl_pem(\OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $key, string $want) : string
The PEM text for whatever ext-openssl would accept as a key or certificate.
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$key | A key object, a certificate object, a two-key array, a PEM or a file:// path. |
| string | $want | 'private' for the private half, 'public' for the public half or a certificate. |
cfw_openssl_crypt(string $dir, string $data, string $cipher_algo, string $passphrase, int $options, string $iv, string|false|null $tag, string $aad, int $tag_length) : array<string,mixed>|false
The shared half of encrypt and decrypt: key and IV sized the way ext-openssl sizes them.
A short key is padded with NUL and a long one truncated, silently, as ext-openssl does. A short IV is padded with a warning; a GCM IV keeps whatever length the caller gave.
| string | $dir | 'enc' or 'dec'. |
| string | $data | The plaintext, or the ciphertext. |
| string | $cipher_algo | A cipher name. |
| string | $passphrase | The key material. |
| int | $options | OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING flags. |
| string | $iv | The initialisation vector. |
| string|false|null | $tag | The GCM tag, on decrypt. |
| string | $aad | Additional authenticated data, for GCM. |
| int | $tag_length | The GCM tag length in bytes. |
The bridge reply, or FALSE for an unknown cipher or a malformed ciphertext.
openssl_encrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = '', string|false|null $tag = null, string $aad = '', int $tag_length = 16) : string|false
| string | $data | The plaintext. |
| string | $cipher_algo | A cipher name. |
| string | $passphrase | The key material. |
| int | $options | OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING flags. |
| string | $iv | The initialisation vector. |
| string|false|null | $tag | Set to the GCM tag. |
| string | $aad | Additional authenticated data, for GCM. |
| int | $tag_length | The GCM tag length in bytes. |
openssl_decrypt(string $data, string $cipher_algo, string $passphrase, int $options = 0, string $iv = '', string|false|null $tag = null, string $aad = '') : string|false
| string | $data | The ciphertext. |
| string | $cipher_algo | A cipher name. |
| string | $passphrase | The key material. |
| int | $options | OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING flags. |
| string | $iv | The initialisation vector. |
| string|false|null | $tag | The GCM tag. |
| string | $aad | Additional authenticated data, for GCM. |
openssl_sign(string $data, string|false|null $signature, \OpenSSLAsymmetricKey|array|string $private_key, int|string $algorithm = 1) : bool
| string | $data | The bytes to sign. |
| string|false|null | $signature | Set to the raw signature. |
| \OpenSSLAsymmetricKey|array |
$private_key | The signing key. |
| int|string | $algorithm | An OPENSSL_ALGO_* value or a digest name. |
openssl_verify(string $data, string $signature, \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key, int|string $algorithm = 1) : int
Answers 1, 0 or -1, matching ext-openssl.
-1 means the call itself failed -- an unreadable key, an unsupported digest -- and is NOT the same as 0, which means the signature was read and did not match. A caller treating -1 as "invalid" would report a broken key as a forged token.
| string | $data | The signed bytes. |
| string | $signature | The raw signature. |
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | The verification key. |
| int|string | $algorithm | An OPENSSL_ALGO_* value or a digest name. |
openssl_pkey_get_public(\OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key) : \OpenSSLAsymmetricKey|false
Turns a PEM, a certificate or a JWKS entry into a public key openssl_verify() accepts.
THE MISSING STEP IN EVERY OIDC LIBRARY. A provider publishes a key SET, the library reads the entry it needs and hands it here.
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | A PEM, a certificate, a file:// path or a JWK array. |
The public key, or FALSE.
openssl_get_publickey(\OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key) : \OpenSSLAsymmetricKey|false
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | A PEM, a certificate, a file:// path or a JWK array. |
openssl_pkey_get_private(\OpenSSLAsymmetricKey|array|string $private_key, string|null $passphrase = null) : \OpenSSLAsymmetricKey|false
Reads a private key, decrypting it with the passphrase when one was used to write it.
| \OpenSSLAsymmetricKey|array |
$private_key | A PEM, a key object or a file:// path. |
| string|null | $passphrase | The passphrase the PEM was written with. |
The key, or FALSE.
openssl_get_privatekey(\OpenSSLAsymmetricKey|array|string $private_key, string|null $passphrase = null) : \OpenSSLAsymmetricKey|false
| \OpenSSLAsymmetricKey|array |
$private_key | A PEM, a key object or a file:// path. |
| string|null | $passphrase | The passphrase the PEM was written with. |
openssl_pkey_get_details(\OpenSSLAsymmetricKey|array|string $key) : array<string,mixed>|false
What ext-openssl reports about a key: bits, the public PEM, the type and its parameters.
| \OpenSSLAsymmetricKey|array |
$key | The key to describe. |
The details, or FALSE.
openssl_pkey_export(\OpenSSLAsymmetricKey|array|string $key, string|null $out, string|null $passphrase = null) : bool
Writes a private key out as PEM.
PASSPHRASES ARE REFUSED rather than ignored. ext-openssl encrypts the output when one is given, and answering with an UNENCRYPTED key to a caller who asked for an encrypted one would hand them a secret they believe is protected.
| \OpenSSLAsymmetricKey|array |
$key | The key to export. |
| string|null | $out | Set to the PEM. |
| string|null | $passphrase | Refused when not empty. |
TRUE on success.
openssl_pkey_derive(\OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key, \OpenSSLAsymmetricKey|array |string $private_key, int $key_length = 0) : string|false
ECDH: the shared secret between a private key and a peer public key.
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | The peer's public key. |
| \OpenSSLAsymmetricKey|array |
$private_key | This side's private key. |
| int | $key_length | Truncate the secret to this many bytes, or 0 for all of it. |
The secret, or FALSE.
openssl_private_encrypt(string $data, string|false|null $encrypted_data, \OpenSSLAsymmetricKey|array|string $private_key, int $padding = 1) : bool
RSA sign-with-private, which is what a legacy licence check or an older SSO handshake uses.
| string | $data | The bytes to encrypt. |
| string|false|null | $encrypted_data | Set to the result. |
| \OpenSSLAsymmetricKey|array |
$private_key | The key. |
| int | $padding | An OPENSSL_*_PADDING value; ignored here. |
TRUE on success.
openssl_public_decrypt(string $data, string|false|null $decrypted_data, \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key, int $padding = 1) : bool
The other half of the pair above.
| string | $data | The bytes to decrypt. |
| string|false|null | $decrypted_data | Set to the result. |
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | The key. |
| int | $padding | An OPENSSL_*_PADDING value; ignored here. |
TRUE on success.
openssl_public_encrypt(string $data, string|false|null $encrypted_data, \OpenSSLAsymmetricKey|\OpenSSLCertificate|array|string $public_key, int $padding = 1) : bool
Encrypt to a public key, PKCS#1 v1.5 or OAEP, which is how XML encryption wraps its key.
| string | $data | The bytes to encrypt. |
| string|false|null | $encrypted_data | Set to the result. |
| \OpenSSLAsymmetricKey|\OpenSSLCertificate|array |
$public_key | The key. |
| int | $padding | OPENSSL_PKCS1_PADDING or OPENSSL_PKCS1_OAEP_PADDING. |
TRUE on success.
openssl_private_decrypt(string $data, string|false|null $decrypted_data, \OpenSSLAsymmetricKey|array|string $private_key, int $padding = 1) : bool
| string | $data | The bytes to decrypt. |
| string|false|null | $decrypted_data | Set to the result. |
| \OpenSSLAsymmetricKey|array |
$private_key | The key. |
| int | $padding | OPENSSL_PKCS1_PADDING or OPENSSL_PKCS1_OAEP_PADDING. |
openssl_x509_read(\OpenSSLCertificate|string $certificate) : \OpenSSLCertificate|false
Reads a certificate from PEM, a file:// path or another certificate.
| \OpenSSLCertificate|string | $certificate | A PEM, a file:// path or a certificate object. |
The certificate, or FALSE.
openssl_x509_export(\OpenSSLCertificate|string $certificate, string|null $output, bool $no_text = true) : bool
| \OpenSSLCertificate|string | $certificate | A PEM, a file:// path or a certificate object. |
| string|null | $output | Set to the PEM. |
| bool | $no_text | Ignored. |
openssl_x509_fingerprint(\OpenSSLCertificate|string $certificate, string $digest_algo = 'sha1', bool $binary = false) : string|false
| \OpenSSLCertificate|string | $certificate | A PEM, a file:// path or a certificate object. |
| string | $digest_algo | A digest name. |
| bool | $binary | Return raw bytes instead of hex. |
openssl_x509_parse(\OpenSSLCertificate|string $certificate, bool $short_names = true) : array<string,mixed>|false
The fields of a certificate that node:crypto exposes, under ext-openssl's key names.
| \OpenSSLCertificate|string | $certificate | A PEM, a file:// path or a certificate object. |
| bool | $short_names | Ignored. |
The parsed certificate, or FALSE.
openssl_x509_checkpurpose(\OpenSSLCertificate|string $certificate, int $purpose, array$ca_info = [], string|null $untrusted_certificates_file = null) : int
Purpose checking needs a trust store and purpose table this runtime does not carry.
| \OpenSSLCertificate|string | $certificate | The certificate to check. |
| int | $purpose | An X509_PURPOSE_* value. |
| array |
$ca_info | Trusted CA locations. |
| string|null | $untrusted_certificates_file | Intermediate certificates. |
-1, which ext-openssl uses for "could not be determined".