123456789_123456789_123456789_123456789_123456789_

Class: OpenSSL::BN

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Comparable
Inherits: Object
Defined in: ext/openssl/ossl_bn.c,
ext/openssl/lib/openssl/bn.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(*args)

new => aBN

OpenSSL::BN.new(bn) => aBN
OpenSSL::BN.new(integer) => aBN
OpenSSL::BN.new(string) => aBN
OpenSSL::BN.new(string, 0 | 2 | 10 | 16) => aBN

Construct a new ::OpenSSL BigNum object.

Class Method Details

.generate_prime

.pseudo_rand

BN.pseudo_rand(bits [, fill [, odd]]) -> aBN

.pseudo_rand_range

BN.pseudo_rand_range(range) -> aBN

.rand

BN.rand(bits [, fill [, odd]]) -> aBN

.rand_range

BN.rand_range(range) -> aBN

Instance Attribute Details

#odd?Boolean (readonly)

bn.odd? => true | false

#one?Boolean (readonly)

bn.one? => true | false

#zero?Boolean (readonly)

bn.zero? => true | false

Instance Method Details

#%

bn % bn2 => aBN

#*

bn * bn2 => aBN

#**

bn ** bn2 => aBN

#+

bn + bn2 => aBN

#-

bn - bn2 => aBN

#/

bn1 / bn2 => [result, remainder]

Division of BN instances

#<<(bits) ⇒ BN

#<=> Also known as: #cmp

bn.cmp(bn2) => integer

#==(obj) ⇒ Boolean Also known as: #===

Returns true only if obj has the same value as bn. Contrast this with #eql?, which requires obj to be BN.

#==(obj) ⇒ Boolean #===(obj) ⇒ Boolean

Alias for #==.

#>>(bits) ⇒ BN

#bit_set?Boolean

Returns boolean of whether bit is set. Bitwise operations for openssl BIGNUMs.

bn.bit_set?(bit) => true | false

#clear_bit!

bn.clear_bit!(bit) -> self

#cmp

Alias for #<=>.

#coerce(other)

#copy(other)

bn.num_bits => integer

#eql?(obj) ⇒ Boolean

Returns true only if obj is a BN with the same value as big. Contrast this with #==, which performs type conversions.

#gcd

bn.gcd(bn2) => aBN

#hashInteger

Returns a hash code for this object.

See also Object#hash.

#lshift!

bn.lshift!(bits) -> self

#mask_bits!

#mod_add

bn.mod_add(bn1, bn2) -> aBN

#mod_exp

bn.mod_exp(bn1, bn2) -> aBN

#mod_inverse

bn.mod_inverse(bn2) => aBN

#mod_mul

bn.mod_mul(bn1, bn2) -> aBN

#mod_sqr

bn.mod_sqr(bn2) => aBN

#mod_sub

bn.mod_sub(bn1, bn2) -> aBN

#num_bits

bn.num_bits => integer

#num_bytes

bn.num_bytes => integer

#pretty_print(q)

[ GitHub ]

  
# File 'ext/openssl/lib/openssl/bn.rb', line 20

def pretty_print(q)
  q.object_group(self) {
    q.text ' '
    q.text to_i.to_s
  }
end

#prime?Boolean #prime?(checks) ⇒ Boolean

Parameters

  • checks - integer

#prime_fasttest?Boolean #prime_fasttest?(checks) ⇒ Boolean #prime_fasttest?(checks, trial_div) ⇒ Boolean

Parameters

  • checks - integer

  • trial_div - boolean

#rshift!

bn.rshift!(bits) -> self

#set_bit!

bn.set_bit!(bit) -> self

#sqr

bn.sqr => aBN

#to_bn

#to_iInteger Also known as: #to_int

#to_iInteger #to_intInteger

Alias for #to_i.

#to_sString #to_s(base) ⇒ String

Parameters

  • base - integer

    • Valid values:

      • 0 - MPI

      • 2 - binary

      • 10 - the default

      • 16 - hex

#ucmp

bn.ucmp(bn2) => integer