Add IPCrypt support in Sodium extension

未關閉
#25,242 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
c, php

研究方向

Start by reading PHP's Sodium extension and the linked libsodium IPCrypt documentation to understand how the requested functions map to the library API. The issue lists the constants and functions to add, but does not identify source files or tests; locate those entry points and existing Sodium tests first. Done means the listed IPCrypt constants and functions are exposed with behavior matching libsodium.

由索引模型根據 Issue 內容生成。

描述

Feature Status: Needs Triage
Description

libsodium exposes IPCrypt features since version 1.0.21 (January 6, 2026): https://libsodium.gitbook.io/doc/secret-key_cryptography/ip_address_encryption

There is IPCrypt userspace implementation for PHP: https://github.com/jedisct1/php-ipcrypt

But since we are shipping sodium in PHP, it would be nice to also natively have the sodium IPCrypt functions in PHP.

This would mean adding the following constants and functions:

const SODIUM_CRYPTO_IPCRYPT_NDX_TWEAKBYTES;

// Utils
sodium_ip2bin(string $ip): string
sodium_bin2ip(string $binary): string

// Deterministic
sodium_crypto_ipcrypt_keygen(): string
sodium_crypto_ipcrypt_encrypt(string $binary_ip, string $key): string
sodium_crypto_ipcrypt_decrypt(string $binary_encrypted_ip, string $key): string

// Non-deterministic (ND)
sodium_crypto_ipcrypt_nd_keygen(): string
sodium_crypto_ipcrypt_nd_encrypt(string $binary_ip, string $key): string
sodium_crypto_ipcrypt_nd_decrypt(string $binary_encrypted_ip, string $key): string

// Prefix-preserving encryption (PFX)
sodium_crypto_ipcrypt_pfx_keygen(): string
sodium_crypto_ipcrypt_pfx_encrypt(string $binary_ip, string $key): string
sodium_crypto_ipcrypt_pfx_decrypt(string $binary_encrypted_ip, string $key): string

// Extended non-deterministic encryption (NDX)
sodium_crypto_ipcrypt_ndx_keygen(): string
sodium_crypto_ipcrypt_ndx_encrypt(string $binary_ip, string $key, string $tweak): string
sodium_crypto_ipcrypt_ndx_decrypt(string $binary_encrypted_ip, string $key): string
主要語言
C
星號
41.8k
分支
8.5k
平均合併
2 天 12 小時
30 天內合併 PR
137

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。