openssl_sign() cannot sign a precomputed digest
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C
- Estrellas
- 40.4k
- Forks
- 8.2k
- Merge medio
- 2 d 13 h
- PR fusionados (30 d)
- 96
Descripción
Description
Description
openssl_sign() currently always performs the digest operation internally before signing the data.
This causes a problem when the input is already a precomputed digest.
For example, when a SHA-256 digest is passed to openssl_sign() together with OPENSSL_ALGO_SHA256, the digest is hashed again:
signature = sign(SHA256(precomputed_sha256_digest))
instead of signing the existing digest directly:
signature = sign(precomputed_sha256_digest)
As a result, PHP currently has no straightforward way to sign an already computed digest using ext/openssl.
Expected behavior
It should be possible to pass a precomputed digest to the OpenSSL extension and sign it directly without applying another hashing operation.
The same should be possible for verification of a signature over a precomputed digest.
Actual behavior
openssl_sign() combines hashing and signing. Therefore, when the caller already has the digest, an additional hashing operation is performed.
Additional information
OpenSSL provides lower-level APIs such as EVP_PKEY_sign() and EVP_PKEY_verify() that can operate on already prepared input.
PHP's OpenSSL extension currently does not expose an equivalent way to perform this operation.
PHP Version
PHP 8.5
Operating System
all
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en el punto de entrada openssl_sign() de ext/openssl de PHP y compara su comportamiento actual de digestión con las API mencionadas EVP_PKEY_sign() y EVP_PKEY_verify(). Determina una interfaz para entradas precalculadas que cubra tanto la firma como la verificación; se considera terminado cuando los llamadores pueden firmar y verificar un digest existente sin volver a aplicarle hashing.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- c, php
- Área
- backend, cryptography, security
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100