[#3419] Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...>

Hello list,

19 messages 2004/09/17
[#3422] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3423] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 12:01, ts wrote:

[#3424] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3425] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 12:37, ts wrote:

[#3426] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

[#3428] Re: Valgrind analysis of [BUG] unknown node type 0 — Andrew Walrond <andrew@...> 2004/09/17

On Friday 17 Sep 2004 13:05, ts wrote:

[#3429] Re: Valgrind analysis of [BUG] unknown node type 0 — ts <decoux@...> 2004/09/17

>>>>> "A" == Andrew Walrond <andrew@walrond.org> writes:

Suggestion: OpenSSL::PKey::RSA.new_from_parameters

From: Brian Candler <B.Candler@...>
Date: 2004-09-09 13:46:53 UTC
List: ruby-core #3367
I would like to propose that a new constructor method be added to the Ruby
OpenSSL library to allow an RSA key to be build from its parameters. A Ruby
implementation is given below, or it could be rewritten in C.

This method takes parameters (n, e, d, p, q) and calculates d from p and q
if necessary, in the same way as Perl's
Crypt::OpenSSL::RSA->new_key_from_parameters() does.

It's useful when you've factored 'n' from a public key and want to generate
a PEM file containing the private key :-)

Regards,

Brian Candler.

module OpenSSL
  module PKey
    class RSA

      # Construct an RSA key from parameters.
      # For private keys, if d is nil then it is calculated from p and q

      def self.new_from_parameters(n, e, d=nil, p=nil, q=nil)
        a = self.new   # self.new(64) for ruby < 1.8.2
        a.n = n        # converted to OpenSSL::BN automatically
        a.e = e
        if p and q
          a.p = p
          a.q = q
          raise "n != p * q" unless a.n == a.p * a.q
          a.d = d || a.e.mod_inverse((a.p-1)*(a.q-1))
          a.dmp1 = a.d % (a.p-1)
          a.dmq1 = a.d % (a.q-1)
          a.iqmp = a.q.mod_inverse(a.p)
        else
          a.d = d
          a.p = nil
          a.q = nil
        end
        a
      end
    end
  end
end

In This Thread

Prev Next