Skip to content

Commit 5d04775

Browse files
author
Evgeny Naumov
committed
use 2.4 OpenSSL::PKey::RSA api
1 parent 50474a1 commit 5d04775

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/auxiliary/scanner/ssl/openssl_heartbleed.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,19 +631,19 @@ def get_factors(data, n)
631631
def key_from_pqe(p, q, e)
632632
# Returns an RSA Private Key from Factors
633633
key = OpenSSL::PKey::RSA.new()
634+
key.set_factors(p, q)
634635

635-
key.p = p
636-
key.q = q
636+
n = key.p * key.q
637+
phi = (key.p - 1) * (key.q - 1 )
638+
d = OpenSSL::BN.new(e).mod_inverse(phi)
637639

638-
key.n = key.p*key.q
639-
key.e = e
640+
key.set_key(n, e, d)
640641

641-
phi = (key.p - 1) * (key.q - 1 )
642-
key.d = key.e.mod_inverse(phi)
642+
dmp1 = key.d % (key.p - 1)
643+
dmq1 = key.d % (key.q - 1)
644+
iqmp = key.q.mod_inverse(key.p)
643645

644-
key.dmp1 = key.d % (key.p - 1)
645-
key.dmq1 = key.d % (key.q - 1)
646-
key.iqmp = key.q.mod_inverse(key.p)
646+
key.set_crt_params(dmp1, dmq1, iqmp)
647647

648648
return key
649649
end

0 commit comments

Comments
 (0)