Crypt_RSA
[ class tree: Crypt_RSA ] [ index: Crypt_RSA ] [ all elements ]

Class: Crypt_RSA_Math_GMP

Source Location: /Crypt_RSA-1.2.1/RSA/Math/GMP.php

Class Overview


Crypt_RSA_Math_GMP class.


Author(s):

Version:

  • @package_version@

Copyright:

  • 2005, 2006 Alexander Valyalkin

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 41]
Crypt_RSA_Math_GMP class.

Provides set of math functions, which are used by Crypt_RSA package This class is a wrapper for PHP GMP extension. See http://php.net/gmp for details.



[ Top ]


Class Variables

$errstr =  ''

[line 49]

error description
  • Access: public

Type:   string


[ Top ]



Method Detail

Crypt_RSA_Math_GMP (Constructor)   [line 60]

Crypt_RSA_Math_GMP Crypt_RSA_Math_GMP( )

Crypt_RSA_Math_GMP constructor.

Checks an existance of PHP GMP package. See http://php.net/gmp for details.

On failure saves error description in $this->errstr

  • Access: public

[ Top ]

bin2int   [line 83]

gmp bin2int( string $str)

Transforms binary representation of large integer into its native form.

Example of transformation: $str = "\x12\x34\x56\x78\x90"; $num = 0x9078563412;

  • Return: resource
  • Access: public

Parameters:

string   $str   — 

[ Top ]

bitLen   [line 278]

int bitLen( gmp $num)

Returns bit length of number $num
  • Access: public

Parameters:

gmp   $num   —  resource $num

[ Top ]

bitOr   [line 305]

gmp bitOr( gmp $num1, gmp $num2, int $start_pos)

Calculates bitwise or of $num1 and $num2, starting from bit $start_pos for number $num1
  • Return: resource
  • Access: public

Parameters:

int   $start_pos   — 
gmp   $num1   —  resource $num1
gmp   $num2   —  resource $num2

[ Top ]

cmpAbs   [line 168]

int cmpAbs( gmp $num1, gmp $num2)

Compares abs($num1) to abs($num2).

Returns: -1, if abs($num1) < abs($num2) 0, if abs($num1) == abs($num2) 1, if abs($num1) > abs($num2)

  • Access: public

Parameters:

gmp   $num1   —  resource $num1
gmp   $num2   —  resource $num2

[ Top ]

dec   [line 227]

gmp dec( gmp $num)

Calculates $num - 1
  • Return: resource
  • Access: public

Parameters:

gmp   $num   —  resource $num

[ Top ]

GCD   [line 252]

gmp GCD( gmp $num1, gmp $num2)

Finds greatest common divider (GCD) of $num1 and $num2
  • Return: resource
  • Access: public

Parameters:

gmp   $num1   —  resource $num1
gmp   $num2   —  resource $num2

[ Top ]

getPrime   [line 194]

void getPrime( int $bits_cnt, $random_generator, string $rnd_generator)

Generates prime number with length $bits_cnt using $random_generator as random generator function.
  • Access: public

Parameters:

int   $bits_cnt   — 
string   $rnd_generator   — 
   $random_generator   — 

[ Top ]

getWrapperName   [line 355]

string getWrapperName( )

Returns name of current wrapper
  • Return: name of current wrapper
  • Access: public

[ Top ]

int2bin   [line 106]

string int2bin( gmp $num)

Transforms large integer into binary representation.

Example of transformation: $num = 0x9078563412; $str = "\x12\x34\x56\x78\x90";

  • Access: public

Parameters:

gmp   $num   —  resource $num

[ Top ]

invmod   [line 266]

gmp invmod( gmp $num, gmp $mod)

Finds inverse number $inv for $num by modulus $mod, such as: $inv * $num = 1 (mod $mod)
  • Return: resource
  • Access: public

Parameters:

gmp   $num   —  resource $num
gmp   $mod   —  resource $mod

[ Top ]

isOne   [line 239]

bool isOne( gmp $num)

Returns true, if $num is equal to one. Else returns false
  • Access: public

Parameters:

gmp   $num   —  resource $num

[ Top ]

mod   [line 151]

string mod( string $num1, string $num2)

Calculates $num1 % $num2
  • Access: public

Parameters:

string   $num1   — 
string   $num2   — 

[ Top ]

mul   [line 138]

gmp mul( gmp $num1, gmp $num2)

Calculates $num1 * $num2
  • Return: resource
  • Access: public

Parameters:

gmp   $num1   —  resource $num1
gmp   $num2   —  resource $num2

[ Top ]

powmod   [line 125]

gmp powmod( gmp $num, gmp $pow, gmp $mod)

Calculates pow($num, $pow) (mod $mod)
  • Return: resource
  • Access: public

Parameters:

gmp   $num   —  resource $num
gmp   $pow   —  resource $pow
gmp   $mod   —  resource $mod

[ Top ]

subint   [line 333]

gmp subint( gmp $num, int $start, int $length)

Returns part of number $num, starting at bit position $start with length $length
  • Return: resource
  • Access: public

Parameters:

gmp   $num   —  resource $num
int   $start   —  start
int   $length   —  length

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:28:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.