php / php/php-src

AES-GCM-SIV encrypts message incorrectly

Đang mở
#22,188 4 bình luận 0 reaction 1 người được giao Xem trên GitHub

@bukka đang làm issue này rồi.

Từ ngày 29/5/2026.

Bug Extension: openssl Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.1k
Merge trung bình
2 ngày 13 giờ
Pull request đã merge (30 ngày)
96

Mô tả

Description

The following code:

<?php
$algo = 'AES-256-GCM-SIV';
$data = 'plain text';
$pass = random_bytes(32);
$iv = str_repeat("\0", 12);
$enc = openssl_encrypt($data, $algo, $pass, OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY, $iv, $tag);
$dec = openssl_decrypt($enc, $algo, $pass, OPENSSL_RAW_DATA | OPENSSL_DONT_ZERO_PAD_KEY, $iv, $tag);
$result = $data === $dec;
var_dump($result, $enc, $dec, $tag, openssl_error_string());

Resulted in this output:

bool(false)
string(10) "cipertext"
bool(false)
NULL
bool(false)

But I expected this output instead:
$result must be true

According to the AES-GCM-SIV spec, the ciphertext $enc must be exactly $data length + 16 bytes for the authentication tag. Alternatively, the tag can be passed separately via the $tag parameter.

PHP Version
PHP 8.5.6 (cli) (built: May  6 2026 09:31:05) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Built by The PHP Group
Zend Engine v4.5.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.6, Copyright (c), by Zend Technologies

OpenSSL 3.5.6 7 Apr 2026

---

PHP 8.5.6 (cli) (built: May 19 2026 23:08:03) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.6, Copyright (c), by Zend Technologies

OpenSSL 3.5.6 7 Apr 2026
Operating System

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.