Finish OpenSSL arginfo stubs

This commit is contained in:
Christoph M. Becker 2019-11-01 15:19:57 +01:00
parent 8ea2be387e
commit 5dd5f1bc4a
3 changed files with 261 additions and 178 deletions

View File

@ -25,7 +25,6 @@
#include "php.h"
#include "php_ini.h"
#include "openssl_arginfo.h"
#include "php_openssl.h"
#include "zend_exceptions.h"
@ -84,6 +83,8 @@
#define HAVE_EVP_PKEY_EC 1
#endif
#include "openssl_arginfo.h"
ZEND_DECLARE_MODULE_GLOBALS(openssl)
/* FIXME: Use the openssl constants instead of
@ -129,183 +130,6 @@ PHP_FUNCTION(openssl_dh_compute_key);
PHP_FUNCTION(openssl_pkey_derive);
PHP_FUNCTION(openssl_random_pseudo_bytes);
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_encrypt, 0, 0, 4)
ZEND_ARG_INFO(0, infile)
ZEND_ARG_INFO(0, outfile)
ZEND_ARG_INFO(0, recipcerts)
ZEND_ARG_INFO(0, headers) /* array */
ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, cipher)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_sign, 0, 0, 5)
ZEND_ARG_INFO(0, infile)
ZEND_ARG_INFO(0, outfile)
ZEND_ARG_INFO(0, signcert)
ZEND_ARG_INFO(0, signkey)
ZEND_ARG_INFO(0, headers) /* array */
ZEND_ARG_INFO(0, flags)
ZEND_ARG_INFO(0, extracertsfilename)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_decrypt, 0, 0, 3)
ZEND_ARG_INFO(0, infilename)
ZEND_ARG_INFO(0, outfilename)
ZEND_ARG_INFO(0, recipcert)
ZEND_ARG_INFO(0, recipkey)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_read, 0, 0, 2)
ZEND_ARG_INFO(0, infilename)
ZEND_ARG_INFO(1, certs)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_private_encrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, crypted)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, padding)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_private_decrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, crypted)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, padding)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_public_encrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, crypted)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, padding)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_public_decrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, crypted)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, padding)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_error_string, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_sign, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, signature)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, method)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_verify, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, signature)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, method)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_seal, 0, 0, 4)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, sealdata)
ZEND_ARG_INFO(1, ekeys) /* array */
ZEND_ARG_INFO(0, pubkeys) /* array */
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(1, iv)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_open, 0, 0, 4)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(1, opendata)
ZEND_ARG_INFO(0, ekey)
ZEND_ARG_INFO(0, privkey)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, iv)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_get_md_methods, 0, 0, 0)
ZEND_ARG_INFO(0, aliases)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_get_cipher_methods, 0, 0, 0)
ZEND_ARG_INFO(0, aliases)
ZEND_END_ARG_INFO()
#ifdef HAVE_EVP_PKEY_EC
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_get_curve_names, 0, 0, 0)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_digest, 0, 0, 2)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_encrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, iv)
ZEND_ARG_INFO(1, tag)
ZEND_ARG_INFO(0, aad)
ZEND_ARG_INFO(0, tag_length)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_decrypt, 0, 0, 3)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, method)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, iv)
ZEND_ARG_INFO(0, tag)
ZEND_ARG_INFO(0, aad)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_cipher_iv_length, 0)
ZEND_ARG_INFO(0, method)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_dh_compute_key, 0)
ZEND_ARG_INFO(0, pub_key)
ZEND_ARG_INFO(0, dh_key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkey_derive, 0, 0, 2)
ZEND_ARG_INFO(0, peer_pub_key)
ZEND_ARG_INFO(0, priv_key)
ZEND_ARG_INFO(0, keylen)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_random_pseudo_bytes, 0, 0, 1)
ZEND_ARG_INFO(0, length)
ZEND_ARG_INFO(1, result_is_strong)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_spki_new, 0, 0, 2)
ZEND_ARG_INFO(0, privkey)
ZEND_ARG_INFO(0, challenge)
ZEND_ARG_INFO(0, algo)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_verify, 0)
ZEND_ARG_INFO(0, spki)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_export, 0)
ZEND_ARG_INFO(0, spki)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_spki_export_challenge, 0)
ZEND_ARG_INFO(0, spki)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_openssl_get_cert_locations, 0)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ openssl_functions[]
*/
static const zend_function_entry openssl_functions[] = {

View File

@ -101,3 +101,106 @@ function openssl_pbkdf2(string $password, string $salt, int $key_length, int $it
/** @return bool|int */
function openssl_pkcs7_verify(string $filename, int $flags, string $signerscerts = UNKNOWN, array $cainfo = UNKNOWN, string $extracerts = UNKNOWN, string $content = UNKNOWN, string $pk7 = UNKNOWN) {}
/** @param resource|string|array $recipcerts */
function openssl_pkcs7_encrypt(string $infile, string $outfile, $recipcerts, ?array $headers, int $flags = 0, int $cipher = OPENSSL_CIPHER_RC2_40): bool {}
/**
* @param resource|string $signcert
* @param resource|string|array $signkey
*/
function openssl_pkcs7_sign(string $infile, string $outfile, $signcert, $signkey, ?array $headers, int $flags = PKCS7_DETACHED, ?string $extracertsfilename = null): bool {}
/**
* @param resource|string $recipcert
* @param resource|string|array $recipkey
*/
function openssl_pkcs7_decrypt(string $infilename, string $outfilename, $recipcert, $recipkey = UNKNOWN): bool {}
function openssl_pkcs7_read(string $infilename, &$certs): bool {}
/** @param resource|string|array $key */
function openssl_private_encrypt(string $data, &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): bool {}
/** @param resource|string|array $key */
function openssl_private_decrypt(string $data, &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): bool {}
/** @param resource|string|array $key */
function openssl_public_encrypt(string $data, &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): bool {}
/** @param resource|string|array $key */
function openssl_public_decrypt(string $data, &$crypted, $key, int $padding = OPENSSL_PKCS1_PADDING): bool {}
/** @return string|false */
function openssl_error_string() {}
/**
* @param resource|string|array $key
* @param int|string $method
*/
function openssl_sign(string $data, &$signature, $key, $method = OPENSSL_ALGO_SHA1): bool {}
/**
* @param resource|string|array $key
* @param int|string $method
* @return int|false
*/
function openssl_verify(string $data, string $signature, $key, $method = OPENSSL_ALGO_SHA1) {}
/** @return int|false */
function openssl_seal(string $data, &$sealdata, &$ekeys, array $pubkeys, string $method = UNKNOWN, &$iv = UNKNOWN) {}
/** @param resource|string|array $privkey */
function openssl_open(string $data, &$opendata, string $ekey, $privkey, string $method = UNKNOWN, string $iv = UNKNOWN): bool {}
function openssl_get_md_methods($aliases = false): array {}
function openssl_get_cipher_methods($aliases = false): array {}
#ifdef HAVE_EVP_PKEY_EC
/** @return array|false */
function openssl_get_curve_names() {}
#endif
/** @return string|false */
function openssl_digest(string $data, string $method, bool $raw_output = false) {}
/** @return string|false */
function openssl_encrypt(string $data, string $method, string $password, int $options = 0, string $iv = '', &$tag = UNKNOWN, string $aad = '', int $tag_length = 16) {}
/** @return string|false */
function openssl_decrypt(string $data, string $method, string $password, int $options = 0, string $iv = '', string $tag = UNKNOWN, string $aad = '') {}
/** @return int|false */
function openssl_cipher_iv_length(string $method) {}
/**
* @param resource $dh_key
* @return string|false
*/
function openssl_dh_compute_key(string $pub_key, $dh_key) {}
/**
* @param resource|string|array $peer_pub_key
* @param resource|string|array $priv_key
* @return string|false
*/
function openssl_pkey_derive($peer_pub_key, $priv_key, int $keylen = 0) {}
function openssl_random_pseudo_bytes(int $length, &$result_is_strong = UNKNOWN): string {}
/**
* @param resource $privkey
* @return string|false
*/
function openssl_spki_new($privkey, string $challenge, int $algo = OPENSSL_ALGO_MD5) {}
function openssl_spki_verify(string $spki): bool {}
/** @return string|false */
function openssl_spki_export(string $spki) {}
/** @return string|false */
function openssl_spki_export_challenge(string $spki) {}
function openssl_get_cert_locations(): array {}

View File

@ -155,3 +155,159 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkcs7_verify, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, content, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, pk7, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_pkcs7_encrypt, 0, 4, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, infile, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, outfile, IS_STRING, 0)
ZEND_ARG_INFO(0, recipcerts)
ZEND_ARG_TYPE_INFO(0, headers, IS_ARRAY, 1)
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cipher, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_pkcs7_sign, 0, 5, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, infile, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, outfile, IS_STRING, 0)
ZEND_ARG_INFO(0, signcert)
ZEND_ARG_INFO(0, signkey)
ZEND_ARG_TYPE_INFO(0, headers, IS_ARRAY, 1)
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, extracertsfilename, IS_STRING, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_pkcs7_decrypt, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, infilename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, outfilename, IS_STRING, 0)
ZEND_ARG_INFO(0, recipcert)
ZEND_ARG_INFO(0, recipkey)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_pkcs7_read, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, infilename, IS_STRING, 0)
ZEND_ARG_INFO(1, certs)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_private_encrypt, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_INFO(1, crypted)
ZEND_ARG_INFO(0, key)
ZEND_ARG_TYPE_INFO(0, padding, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_openssl_private_decrypt arginfo_openssl_private_encrypt
#define arginfo_openssl_public_encrypt arginfo_openssl_private_encrypt
#define arginfo_openssl_public_decrypt arginfo_openssl_private_encrypt
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_error_string, 0, 0, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_sign, 0, 3, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_INFO(1, signature)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, method)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_verify, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, signature, IS_STRING, 0)
ZEND_ARG_INFO(0, key)
ZEND_ARG_INFO(0, method)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_seal, 0, 0, 4)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_INFO(1, sealdata)
ZEND_ARG_INFO(1, ekeys)
ZEND_ARG_TYPE_INFO(0, pubkeys, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_ARG_INFO(1, iv)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_open, 0, 4, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_INFO(1, opendata)
ZEND_ARG_TYPE_INFO(0, ekey, IS_STRING, 0)
ZEND_ARG_INFO(0, privkey)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, iv, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_get_md_methods, 0, 0, IS_ARRAY, 0)
ZEND_ARG_INFO(0, aliases)
ZEND_END_ARG_INFO()
#define arginfo_openssl_get_cipher_methods arginfo_openssl_get_md_methods
#if defined(HAVE_EVP_PKEY_EC)
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_get_curve_names, 0, 0, 0)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_digest, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, raw_output, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_encrypt, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, iv, IS_STRING, 0)
ZEND_ARG_INFO(1, tag)
ZEND_ARG_TYPE_INFO(0, aad, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tag_length, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_decrypt, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, iv, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, tag, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, aad, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_cipher_iv_length, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, method, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_dh_compute_key, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, pub_key, IS_STRING, 0)
ZEND_ARG_INFO(0, dh_key)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_pkey_derive, 0, 0, 2)
ZEND_ARG_INFO(0, peer_pub_key)
ZEND_ARG_INFO(0, priv_key)
ZEND_ARG_TYPE_INFO(0, keylen, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_random_pseudo_bytes, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
ZEND_ARG_INFO(1, result_is_strong)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_spki_new, 0, 0, 2)
ZEND_ARG_INFO(0, privkey)
ZEND_ARG_TYPE_INFO(0, challenge, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, algo, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_spki_verify, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, spki, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_openssl_spki_export, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, spki, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_openssl_spki_export_challenge arginfo_openssl_spki_export
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_get_cert_locations, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()