Class
Constants
No documentation available
No documentation available
No documentation available
Class Methods

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

  • bits - integer

  • safe - boolean

  • add - BN

  • rem - BN

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 - Hexadeciaml number representation, with a leading ‘-’ for a negative number.

Generates a cryptographically strong pseudo-random number of bits.

See also the man page BN_rand(3).

Generates a cryptographically strong pseudo-random number in the range 0…range.

See also the man page BN_rand_range(3).

Instance Methods
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Division of OpenSSL::BN instances

No documentation available
An alias for cmp

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

An alias for ==
No documentation available
No documentation available

Tests bit bit in bn and returns true if set, false if not set.

No documentation available
No documentation available
No documentation available
An alias for initialize_copy

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

No documentation available

Returns the flags on the BN object. The argument is used as a bit mask.

Parameters

  • flags - integer

Returns a hash code for this object.

See also Object#hash.

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Performs a Miller-Rabin probabilistic primality test for bn.

checks parameter is deprecated in version 3.0. It has no effect.

Performs a Miller-Rabin probabilistic primality test for bn.

Deprecated in version 3.0. Use prime? instead.

checks and trial_div parameters no longer have any effect.

No documentation available
No documentation available

Enables the flags on the BN object. Currently, the flags argument can contain zero of OpenSSL::BN::CONSTTIME.

No documentation available
No documentation available
No documentation available
An alias for to_i

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 - Hexadeciaml number representation, with a leading ‘-’ for a negative bignum.

No documentation available
No documentation available