lazy_rsa 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lazy_rsa.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c8aba055f8175f3bd6149e29ceb1dbfe9a19664ddb350e16a80238b84f5ba48
|
4
|
+
data.tar.gz: d673fd5393b4c83c40551d7de2b2a52efb7ffef5ca6b03d3ccd014622f191a03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa10c9d3755c5cdd660a31ec532be9e5018ab34b6c5025eb11c5a55ee4548f8f273f7af0a224e4905e46c271bed18edbaee499162df64d113ac77907a3f172cc
|
7
|
+
data.tar.gz: c524ab6edbc2ab893a5b8e94d8e6011b6f4e47c8da5f25a01769dc2db50bd713b7417bafac09ee8b96f1de8a66414b05c760dfa6df8e754640c117f6f3325ad8
|
data/lib/lazy_rsa.rb
CHANGED
@@ -9,7 +9,8 @@ module LazyRsa
|
|
9
9
|
|
10
10
|
def decrypt(key, ciphertext)
|
11
11
|
key = read_key(key)
|
12
|
-
OpenSSL::BN.new(ciphertext).mod_exp(key.d, key.n)
|
12
|
+
integer = OpenSSL::BN.new(ciphertext).mod_exp(key.d, key.n)
|
13
|
+
integer_to_text(integer)
|
13
14
|
end
|
14
15
|
|
15
16
|
def generate_key
|
@@ -20,13 +21,13 @@ module LazyRsa
|
|
20
21
|
phi = (p - 1) * (q - 1)
|
21
22
|
end
|
22
23
|
n = p * q
|
23
|
-
e = p.mod_exp(Constants::SECURE_EXPONENT, Constants::SECURE_MODULUS)
|
24
|
+
e = p.mod_exp(LazyRsa::Constants::SECURE_EXPONENT, LazyRsa::Constants::SECURE_MODULUS)
|
24
25
|
d = e.mod_inverse(phi)
|
25
26
|
|
26
27
|
build_key(e:, d:, n:)
|
27
28
|
end
|
28
29
|
|
29
|
-
def build_key(e
|
30
|
+
def build_key(e: nil, d: nil, n:)
|
30
31
|
data_sequence = OpenSSL::ASN1::Sequence([
|
31
32
|
OpenSSL::ASN1::Integer(n),
|
32
33
|
OpenSSL::ASN1::Integer(e),
|
@@ -45,5 +46,9 @@ module LazyRsa
|
|
45
46
|
def text_to_integer(text)
|
46
47
|
OpenSSL::BN.new(text.unpack("H*").first.to_i(16))
|
47
48
|
end
|
49
|
+
|
50
|
+
def integer_to_text(integer)
|
51
|
+
[integer.to_s(16)].pack("H*")
|
52
|
+
end
|
48
53
|
end
|
49
54
|
end
|
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
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Quaranto
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
40
|
+
rubygems_version: 3.1.2
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Easy RSA
|