class OpenSSL::BN
Public Class Methods
(::Integer bits, ?boolish safe, ?bn add, ?bn rem) → instance
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1530
def self.generate_prime: (::Integer bits, ?boolish safe, ?bn add, ?bn rem) -> instance
Generates a random prime number of bit length bits. If safe is set to true, generates a safe prime. If add is specified, generates a prime that fulfills condition p % add = rem.
Parameters
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1942
def initialize: (self) -> void
| (Integer) -> void
| (string) -> void
| (string, 0 | 2 | 10 | 16) -> void
Construct a new OpenSSL BIGNUM object.
If bn is an Integer or OpenSSL::BN, a new instance of OpenSSL::BN representing the same value is returned. See also Integer#to_bn for the short-hand.
If a String is given, the content will be parsed according to base.
string-
The string to be parsed.
base-
The format. Must be one of the following: *
0- MPI format. See the man page BN_mpi2bn(3) for details. *2- Variable-length and big-endian binary encoding of a positive number. *10- Decimal number representation, with a leading ‘-’ for a negative number. *16- Hexadecimal number representation, with a leading ‘-’ for a negative number.
(*untyped) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1532
def self.pseudo_rand: (*untyped) -> untyped
(untyped) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1534
def self.pseudo_rand_range: (untyped) -> untyped
(*untyped) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1544
def self.rand: (*untyped) -> untyped
Generates a cryptographically strong pseudo-random number of bits.
See also the man page BN_rand(3).
(untyped) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1555
def self.rand_range: (untyped) -> untyped
Generates a cryptographically strong pseudo-random number in the range 0...range.
See also the man page BN_rand_range(3).
Public Instance Methods
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1562
def %: (bn) -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1569
def *: (bn) -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1576
def **: (bn) -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1583
def +: (bn) -> self
() → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1590
def +@: () -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1597
def -: (bn) -> self
() → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1604
def -@: () -> self
(bn) → [ self, self ]
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1612
def /: (bn) -> [ self, self ]
Division of OpenSSL::BN instances
(int) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1619
def <<: (int) -> self
(untyped) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1635
def ==: (untyped) -> bool
Returns true only if obj has the same value as bn. Contrast this with OpenSSL::BN#eql?, which requires obj to be OpenSSL::BN.
(untyped) → bool
Returns true only if obj has the same value as bn. Contrast this with OpenSSL::BN#eql?, which requires obj to be OpenSSL::BN.
(int) → int
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1648
def >>: (int) -> int
(int) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1656
def bit_set?: (int) -> bool
Tests bit bit in bn and returns true if set, false if not set.
(int) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1663
def clear_bit!: (int) -> void
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1670
def cmp: (bn) -> Integer
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1677
def coerce: (::Integer) -> Array[Integer]
| (BN) -> Array[BN]
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1685
def copy: (bn) -> self
(untyped other) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1694
def eql?: (untyped other) -> bool
Returns true only if obj is a OpenSSL::BN with the same value as bn. Contrast this with OpenSSL::BN#==, which performs type conversions.
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1701
def gcd: (bn) -> self
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1711
def hash: () -> Integer
Returns a hash code for this object.
See also Object#hash.
(self other) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1952
def initialize_copy: (self other) -> self
(int bits) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1718
def lshift!: (int bits) -> self
(int) → void
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1720
def mask_bits!: (int) -> void
(bn, bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1727
def mod_add: (bn, bn) -> self
(bn, bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1734
def mod_exp: (bn, bn) -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1741
def mod_inverse: (bn) -> self
(bn, bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1748
def mod_mul: (bn, bn) -> self
(bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1755
def mod_sqr: (bn) -> self
(bn, bn) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1762
def mod_sub: (bn, bn) -> self
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1769
def negative?: () -> bool
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1776
def num_bits: () -> ::Integer
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1783
def num_bytes: () -> ::Integer
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1790
def odd?: () -> bool
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1797
def one?: () -> bool
(untyped q) → untyped
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1804
def pretty_print: (untyped q) -> untyped
(?int checks) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1816
def prime?: (?int checks) -> bool
Performs a Miller-Rabin probabilistic primality test for bn.
<strong>checks parameter is deprecated in version 3.0.</strong> It has no effect.
(?int checks, ?int trial_div) → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1830
def prime_fasttest?: (?int checks, ?int trial_div) -> bool
Performs a Miller-Rabin probabilistic primality test for bn.
<strong>Deprecated in version 3.0.</strong> Use prime? instead.
checks and trial_div parameters no longer have any effect.
(int bits) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1837
def rshift!: (int bits) -> self
(int bit) → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1844
def set_bit!: (int bit) -> self
() → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1851
def sqr: () -> self
() → self
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1858
def to_bn: () -> self
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1865
def to_i: () -> ::Integer
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1892
def to_s: () -> String
| (0) -> String
| (2) -> String
| (10) -> String
| (16) -> String
| (int base) -> String
Returns the string representation of the bignum.
BN.new can parse the encoded string to convert back into an OpenSSL::BN.
base-
The format. Must be one of the following: *
0- MPI format. See the man page BN_bn2mpi(3) for details. *2- Variable-length and big-endian binary encoding. The sign of the bignum is ignored. *10- Decimal number representation, with a leading ‘-’ for a negative bignum. *16- Hexadecimal number representation, with a leading ‘-’ for a negative bignum.
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1904
def ucmp: (bn bn2) -> ::Integer
() → bool
Source
# File vendor/bundle/ruby/4.0.0/gems/rbs-4.0.3/stdlib/openssl/0/openssl.rbs, line 1911
def zero?: () -> bool