openssl_sign() cannot sign a precomputed digest
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại điểm vào openssl_sign() trong ext/openssl của PHP và so sánh hành vi digest hiện tại của nó với các API EVP_PKEY_sign() và EVP_PKEY_verify() đã đề cập. Xác định một giao diện cho đầu vào được tính toán trước, bao quát cả việc ký và xác minh; hoàn thành nghĩa là các bên gọi có thể ký và xác minh một digest hiện có mà không băm lại nó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- backend, cryptography, security
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100