lazy_rsa 0.3.4 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lazy_rsa.rb +10 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 755ac237d936d4039dfb3747d5cd08b6bcdfbd87659d43e24421c9076a85c191
4
- data.tar.gz: 2ce50dd2483a2810ab657b81f4ce007324d4aaf088713bdb2be175c0510ea7b9
3
+ metadata.gz: aec4c9558e64d74ae8530e14ba5110cce7278010b4f80db751bfeb35e67bcdb4
4
+ data.tar.gz: ac1eae2fdaa2336001689e072746137aaad168d99c1253e7c885770ba5acfca6
5
5
  SHA512:
6
- metadata.gz: 1c40648e208b53aed1ef062e02b472750f6453250ab4c9bc25e67ae993c7059375b47b7a68d798efa9710a47a6a71dd575e3520aa47816cdd90d38688d7cf6c8
7
- data.tar.gz: 547ee01457bf706399f4a850fcb98c851f5780694a5dec268f6852222e2f157c2a1f50b7f5fd6c85767eac0e8e4d89bdf073737e6696b52781d53fcf571a873b
6
+ metadata.gz: ea9d42065fe7a1495369808a1d66695affa5d27009d4d9385e789f985479fc848ee289ff917a9a026364a62b2441c44becdde8174e5b1f8a2681e4e307d99c99
7
+ data.tar.gz: 6800a222e1b068fd55e75924a3fd9a2480ce9a90302eabb605a8358e9dda64a6e179d3a59acac6aaddf88b3723c488d2b39fcbf6ef2fa8e2db799cef36690c95
data/lib/lazy_rsa.rb CHANGED
@@ -18,9 +18,10 @@ module LazyRsa
18
18
  def generate_key
19
19
  q = OpenSSL::BN.generate_prime(512)
20
20
  phi = OpenSSL::BN.new(0)
21
- while q.gcd(phi) != 1
21
+ loop do
22
22
  p = OpenSSL::BN.generate_prime(512)
23
23
  phi = (p - 1) * (q - 1)
24
+ break if q.gcd(phi) == 1
24
25
  end
25
26
  n = p * q
26
27
  e = p.mod_exp(SECURE_EXPONENT, SECURE_MODULUS)
@@ -31,9 +32,15 @@ module LazyRsa
31
32
 
32
33
  def build_key(e: nil, d: nil, n:)
33
34
  data_sequence = OpenSSL::ASN1::Sequence([
35
+ OpenSSL::ASN1::Integer.new(0),
34
36
  OpenSSL::ASN1::Integer(n),
35
- OpenSSL::ASN1::Integer(e),
36
- OpenSSL::ASN1::Integer(d),
37
+ e.nil? ? OpenSSL::ASN1::Integer.new(0) : OpenSSL::ASN1::Integer(e),
38
+ d.nil? ? OpenSSL::ASN1::Integer.new(0) : OpenSSL::ASN1::Integer(d),
39
+ OpenSSL::ASN1::Integer.new(0),
40
+ OpenSSL::ASN1::Integer.new(0),
41
+ OpenSSL::ASN1::Integer.new(0),
42
+ OpenSSL::ASN1::Integer.new(0),
43
+ OpenSSL::ASN1::Integer.new(0),
37
44
  ])
38
45
  asn1 = OpenSSL::ASN1::Sequence(data_sequence)
39
46
  OpenSSL::PKey::RSA.new(asn1.to_der)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_rsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Quaranto