pgp-rb 0.2.1-x86_64-linux → 0.2.2-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pgp-rb/3.2/pgp_rb.so +0 -0
- data/lib/pgp-rb/3.4/pgp_rb.so +0 -0
- data/lib/pgp-rb/version.rb +1 -1
- data/lib/pgp.rb +89 -0
- 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: f152c37e3d96b85ce6ffa1cbf4857e09d2ae4f6ea8b53a09d743502b3a399334
|
|
4
|
+
data.tar.gz: 5a979e0ccd0d4ba4f6e753905926cd700d1dd8454c4891769b6e6bcd8798d32c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 66dc75b7916765c43908100ae012d5c33b8607a727f1b6c58c01c2b9837d0842a3bd5d52f91c5bb48796242351dca7b5f79b199278786363ecb09ef3adc6cf6c
|
|
7
|
+
data.tar.gz: 3b955a6d0a66d7bd0511b945577b2e3bb6273118ef2a444b5486b86bb6e456aa1f0d299ce98610b03f7a0fcd7eb78e5c04ac1f8b9bcb281de4b699c5456edf76
|
data/lib/pgp-rb/3.2/pgp_rb.so
CHANGED
|
Binary file
|
data/lib/pgp-rb/3.4/pgp_rb.so
CHANGED
|
Binary file
|
data/lib/pgp-rb/version.rb
CHANGED
data/lib/pgp.rb
CHANGED
|
@@ -52,6 +52,26 @@ module PGP
|
|
|
52
52
|
ENCRIPTION_ALGORITHM_CAMELLIA_192 = 12
|
|
53
53
|
ENCRIPTION_ALGORITHM_CAMELLIA_256 = 13
|
|
54
54
|
|
|
55
|
+
HASH_ALGORITHM_MD5 = 1
|
|
56
|
+
HASH_ALGORITHM_SHA1 = 2
|
|
57
|
+
HASH_ALGORITHM_SHA256 = 8
|
|
58
|
+
HASH_ALGORITHM_SHA384 = 9
|
|
59
|
+
HASH_ALGORITHM_SHA512 = 10
|
|
60
|
+
HASH_ALGORITHM_SHA224 = 11
|
|
61
|
+
HASH_ALGORITHM_SHA3_256 = 12
|
|
62
|
+
HASH_ALGORITHM_SHA3_512 = 14
|
|
63
|
+
|
|
64
|
+
HASH_ALGORITHM_NAMES = {
|
|
65
|
+
HASH_ALGORITHM_MD5 => 'MD5',
|
|
66
|
+
HASH_ALGORITHM_SHA1 => 'SHA1',
|
|
67
|
+
HASH_ALGORITHM_SHA256 => 'SHA256',
|
|
68
|
+
HASH_ALGORITHM_SHA384 => 'SHA384',
|
|
69
|
+
HASH_ALGORITHM_SHA512 => 'SHA512',
|
|
70
|
+
HASH_ALGORITHM_SHA224 => 'SHA224',
|
|
71
|
+
HASH_ALGORITHM_SHA3_256 => 'SHA3-256',
|
|
72
|
+
HASH_ALGORITHM_SHA3_512 => 'SHA3-512'
|
|
73
|
+
}.freeze
|
|
74
|
+
|
|
55
75
|
# Public Key class provides an native extension representation for working with PGP public keys.
|
|
56
76
|
class PublicKey
|
|
57
77
|
private_class_method :new
|
|
@@ -123,4 +143,73 @@ module PGP
|
|
|
123
143
|
encrypt_with_algorithm(data, algorithm)
|
|
124
144
|
end
|
|
125
145
|
end
|
|
146
|
+
|
|
147
|
+
# Private Key class provides an native extension representation for working with PGP private keys.
|
|
148
|
+
class PrivateKey
|
|
149
|
+
private_class_method :new
|
|
150
|
+
|
|
151
|
+
# @!method self.parse
|
|
152
|
+
# Parses a PGP private key from a given string input.
|
|
153
|
+
# @param input [String] the PGP private key in string format.
|
|
154
|
+
# @return [PrivateKey] an instance of PrivateKey if parsing is successful.
|
|
155
|
+
|
|
156
|
+
# @!method fingerprint
|
|
157
|
+
# Returns the fingerprint of the private key.
|
|
158
|
+
# @return [String] the fingerprint of the private key.
|
|
159
|
+
|
|
160
|
+
# @!method algorithm
|
|
161
|
+
# Returns the algorithm used by the private key.
|
|
162
|
+
# @return [Integer] the algorithm identifier.
|
|
163
|
+
|
|
164
|
+
# @!method signing_supported?
|
|
165
|
+
# Checks if the private key supports signing.
|
|
166
|
+
# @return [Boolean] true if the key supports signing, false otherwise.
|
|
167
|
+
|
|
168
|
+
# @!method encryption_supported?
|
|
169
|
+
# Checks if the private key supports encryption.
|
|
170
|
+
# @return [Boolean] true if the key supports encryption, false otherwise.
|
|
171
|
+
|
|
172
|
+
# @!method version
|
|
173
|
+
# Returns the version of the private key.
|
|
174
|
+
# @return [Integer] the version of the private key.
|
|
175
|
+
|
|
176
|
+
# @!method created_at
|
|
177
|
+
# Returns the creation time of the private key.
|
|
178
|
+
# @return [Time] the creation time of the private key.
|
|
179
|
+
|
|
180
|
+
# @!method expires_at
|
|
181
|
+
# Returns the expiration time of the private key, if any.
|
|
182
|
+
# @return [Time, nil] the expiration time of the private key or nil if it does not expire.
|
|
183
|
+
|
|
184
|
+
# @!method sign_with_algorithm(input, algorithm)
|
|
185
|
+
# Signs data with the specified hash algorithm.
|
|
186
|
+
# @param input [String] the data to be signed.
|
|
187
|
+
# @param algorithm [Integer] the hash algorithm identifier.
|
|
188
|
+
# @return [String] the signed data encoded by base64.
|
|
189
|
+
|
|
190
|
+
# @!method sign(input)
|
|
191
|
+
# Signs data with the default hash algorithm (SHA256).
|
|
192
|
+
# @param input [String] the data to be signed.
|
|
193
|
+
# @return [String] the signed data encoded by base64.
|
|
194
|
+
|
|
195
|
+
# Returns a string representation of the PrivateKey object, including its fingerprint, algorithm name, and version.
|
|
196
|
+
# @return [String] the string representation of the PrivateKey object.
|
|
197
|
+
def inspect
|
|
198
|
+
"#<#{self.class} #{fingerprint} #{algorithm_name} v#{version}>"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Fetches the name of the algorithm used by the private key from a predefined list of names.
|
|
202
|
+
# @return [String] the name of the algorithm.
|
|
203
|
+
def algorithm_name
|
|
204
|
+
KEY_ALGORITHM_NAMES.fetch(algorithm, 'Unknown')
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Checks whether the private key has expired.
|
|
208
|
+
# @return [Boolean] true if the key has expired, false otherwise.
|
|
209
|
+
def expired?
|
|
210
|
+
return false if expires_at.nil?
|
|
211
|
+
|
|
212
|
+
expires_at.to_i <= Time.now.to_i
|
|
213
|
+
end
|
|
214
|
+
end
|
|
126
215
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pgp-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: x86_64-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Kirill Zaitsev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: pry
|