Sha256: baeac54c79a124edb10f934ea75fbcd73b928548c1982c4cadadeb790e5c5f68

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require_relative 'libopenssl'
require_relative 'libc'

module LibRNP

  # BIGNUM* to hexadecimal string
  def self.bn2hex(bn)
    str, ptr = LibOpenSSL::BN_bn2hex(bn)
    LibC::free(ptr)
    str
  end

  # Ruby Fixnum to BIGNUM*
  def self.num2bn(num)
    bn_ptr = FFI::MemoryPointer.new(:pointer)
    hex = num.to_s(16)
    ret = LibOpenSSL::BN_hex2bn(bn_ptr, hex)
    raise 'Fixnum to BIGNUM conversion failed' if ret == 0
    bn = bn_ptr.get_pointer(0)
    bn_ptr.free
    bn
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rnp-0.2.0 lib/rnp/lowlevel/utils.rb