rfc:openssl.bignum
Differences
This shows you the differences between two versions of the page.
rfc:openssl.bignum [2016/10/18 01:34] pollita created |
rfc:openssl.bignum [2017/09/22 13:28] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Add BigNum support to OpenSSL extension ====== | ||
- | * Version: 1.0 | ||
- | * Date: 2016-10-17 | ||
- | * Author: Sara Golemon, pollita@php.net | ||
- | * Status: Under Discussion | ||
- | * First Published at: http:// | ||
- | |||
- | ===== Introduction ===== | ||
- | |||
- | The OpenSSL library has long supported arbitrarily large integer math, however we've simply never exposed it. Add a new class `OpenSSL\BigNum` to expose this functionality. | ||
- | |||
- | ===== Proposal ===== | ||
- | |||
- | This class will expose similar functionality to the GMP class, however it will do so via instance methods rather than global functions. Like GMP, OpenSSL\BigNum will behave as an immutable, producing new objects from all binary and unary ops. | ||
- | |||
- | The following is a psuedo definition of the class: | ||
- | |||
- | |||
- | namespace OpenSSL; | ||
- | class BigNum { | ||
- | public function __construct(int|string $initval = 0); | ||
- | static public function createFromBinary(string $bin): BigNum; | ||
- | | ||
- | public function add(BigNum $val): BigNum; | ||
- | public function sub(BigNum $val): BigNum; | ||
- | public function mul(BigNum $val): BigNum; | ||
- | public function div(BigNum $val): array; /* tuple(BigNum $quotient, BigNum $remainder) */ | ||
- | public function intdiv(BigNum $val): BigNum; | ||
- | public function mod(BigNum $val): BigNum; | ||
- | public function pow(BigNum $exp): BigNum; | ||
- | public function powmod(BigNum $exp, BigNum $mod): BigNum; | ||
- | public function cmp(BigNum $val): int; /* trinary compare */ | ||
- | public function gcd(BigNum $val): BigNum; /* Greatest Common Divisor */ | ||
- | public function shr(int $bits): BigNum; | ||
- | public function shl(int $bits): BigNum; | ||
- | | ||
- | public function toDec(): string; | ||
- | public function toHex(): string; | ||
- | public function toBin(): string; | ||
- | | ||
- | public function __toString() { return $this-> | ||
- | public function __debugInfo() { return [ ' | ||
- | } | ||
- | |||
- | |||
- | Additionally, | ||
- | |||
- | ===== Proposed PHP Version(s) ===== | ||
- | PHP 7.2, with an independent BC module `openssl-bignum` for 7.1 and 7.0 | ||
- | |||
- | ===== Proposed Voting Choices ===== | ||
- | Simple 50%+1 Yes/No for including the porposed patch | ||
- | |||
- | ===== Patches and Tests ===== | ||
- | |||
- | * https:// | ||
rfc/openssl.bignum.txt · Last modified: 2017/09/22 13:28 (external edit)