pgp-rb 0.1.0-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 +7 -0
- data/lib/pgp-rb/3.1/pgp_rb.so +0 -0
- data/lib/pgp-rb/3.2/pgp_rb.so +0 -0
- data/lib/pgp-rb/3.3/pgp_rb.so +0 -0
- data/lib/pgp-rb/version.rb +5 -0
- data/lib/pgp.rb +113 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 93e0f7ca670f1c6a6b91c7bcd248c8efa3788ad84c00cc32c02868edff2feb34
|
4
|
+
data.tar.gz: 86cdf53fe9835ec56e08bb28706be0db484c40f16961dd28d12dab8e3c729d06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f7872e15ffc3f8d852f9fe9857c040b93c9bc5b3aba84293fd36fd644087b02cf72491f9316a590a105191d2feed4eebe2bb8d4f91d4087537b10e4f519736e5
|
7
|
+
data.tar.gz: d0014beb0bdb8774e077d901232f79bdb3a1922d4fe4453fffc1283ab491b197b9d3d04cf5504737f9e262d4027a0e155a368dbbe87dd034a196d845ef0aa451
|
Binary file
|
Binary file
|
Binary file
|
data/lib/pgp.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'pgp-rb/pgp_rb'
|
4
|
+
|
5
|
+
module PGP
|
6
|
+
KEY_ALGORITHM_RSA = 1
|
7
|
+
KEY_ALGORITHM_RSA_ENCRYPT = 2
|
8
|
+
KEY_ALGORITHM_RSA_SIGN = 3
|
9
|
+
KEY_ALGORITHM_ELGAMAL_SIGN = 16
|
10
|
+
KEY_ALGORITHM_DSA = 17
|
11
|
+
KEY_ALGORITHM_ECDH = 18
|
12
|
+
KEY_ALGORITHM_ECDSA = 19
|
13
|
+
KEY_ALGORITHM_ELGAMAL = 20
|
14
|
+
KEY_ALGORITHM_DIFFIE_HELLMAN = 21
|
15
|
+
KEY_ALGORITHM_EDDSA = 22
|
16
|
+
|
17
|
+
KEY_ALGORITHM_NAMES = {
|
18
|
+
KEY_ALGORITHM_RSA => 'RSA (Encrypt and Sign)',
|
19
|
+
KEY_ALGORITHM_RSA_ENCRYPT => 'RSA (Encrypt-Only)',
|
20
|
+
KEY_ALGORITHM_RSA_SIGN => 'RSA (Sign-Only)',
|
21
|
+
KEY_ALGORITHM_ELGAMAL_SIGN => 'Elgamal (Sign-Only)',
|
22
|
+
KEY_ALGORITHM_DSA => 'DSA (Digital Signature Algorithm)',
|
23
|
+
KEY_ALGORITHM_ECDH => 'Elliptic Curve: RFC-6637',
|
24
|
+
KEY_ALGORITHM_ECDSA => 'ECDSA: RFC-6637',
|
25
|
+
KEY_ALGORITHM_ELGAMAL => 'Elgamal (Encrypt and Sign)',
|
26
|
+
KEY_ALGORITHM_DIFFIE_HELLMAN => 'Diffie-Hellman (X9.42, as defined for IETF-S/MIME)',
|
27
|
+
KEY_ALGORITHM_EDDSA => 'EdDSA'
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
ENCRIPTION_ALGORITHM_IDEA = 1
|
31
|
+
ENCRIPTION_ALGORITHM_TRIPLE_DES = 2
|
32
|
+
ENCRIPTION_ALGORITHM_CAST5 = 3
|
33
|
+
ENCRIPTION_ALGORITHM_BLOWFISH = 4
|
34
|
+
ENCRIPTION_ALGORITHM_AES_128 = 7
|
35
|
+
ENCRIPTION_ALGORITHM_AES_192 = 8
|
36
|
+
ENCRIPTION_ALGORITHM_AES_256 = 9
|
37
|
+
ENCRIPTION_ALGORITHM_TWOFISH = 10
|
38
|
+
ENCRIPTION_ALGORITHM_CAMELLIA_128 = 11
|
39
|
+
ENCRIPTION_ALGORITHM_CAMELLIA_192 = 12
|
40
|
+
ENCRIPTION_ALGORITHM_CAMELLIA_256 = 13
|
41
|
+
|
42
|
+
# Public Key class provides an native extension representation for working with PGP public keys.
|
43
|
+
class PublicKey
|
44
|
+
private_class_method :new
|
45
|
+
|
46
|
+
# @!method self.parse
|
47
|
+
# Parses a PGP public key from a given string input.
|
48
|
+
# @param input [String] the PGP public key in string format.
|
49
|
+
# @return [PublicKey] an instance of PublicKey if parsing is successful.
|
50
|
+
|
51
|
+
# @!method fingerprint
|
52
|
+
# Returns the fingerprint of the public key.
|
53
|
+
# @return [String] the fingerprint of the public key.
|
54
|
+
|
55
|
+
# @!method algorithm
|
56
|
+
# Returns the algorithm used by the public key.
|
57
|
+
# @return [Integer] the algorithm identifier.
|
58
|
+
|
59
|
+
# @!method signing_supported?
|
60
|
+
# Checks if the public key supports signing.
|
61
|
+
# @return [Boolean] true if the key supports signing, false otherwise.
|
62
|
+
|
63
|
+
# @!method encryption_supported?
|
64
|
+
# Checks if the public key supports encryption.
|
65
|
+
# @return [Boolean] true if the key supports encryption, false otherwise.
|
66
|
+
|
67
|
+
# @!method version
|
68
|
+
# Returns the version of the public key.
|
69
|
+
# @return [Integer] the version of the public key.
|
70
|
+
|
71
|
+
# @!method created_at
|
72
|
+
# Returns the creation time of the public key.
|
73
|
+
# @return [Time] the creation time of the public key.
|
74
|
+
|
75
|
+
# @!method expires_at
|
76
|
+
# Returns the expiration time of the public key, if any.
|
77
|
+
# @return [Time, nil] the expiration time of the public key or nil if it does not expire.
|
78
|
+
|
79
|
+
# @!method encrypt_with_algorithm(input, algorithm)
|
80
|
+
# Encrypts data with the specified algorithm.
|
81
|
+
# @param input [String] the data to be encrypted.
|
82
|
+
# @param algorithm [Integer] the encryption algorithm identifier.
|
83
|
+
# @return [String] the encrypted data encoded by base64.
|
84
|
+
|
85
|
+
# Returns a string representation of the PublicKey object, including its fingerprint, algorithm name, and version.
|
86
|
+
# @return [String] the string representation of the PublicKey object.
|
87
|
+
def inspect
|
88
|
+
"#<#{self.class} #{fingerprint} #{algorithm_name} v#{version}>"
|
89
|
+
end
|
90
|
+
|
91
|
+
# Fetches the name of the algorithm used by the public key from a predefined list of names.
|
92
|
+
# @return [String] the name of the algorithm.
|
93
|
+
def algorithm_name
|
94
|
+
KEY_ALGORITHM_NAMES.fetch(algorithm, 'Unknown')
|
95
|
+
end
|
96
|
+
|
97
|
+
# Checks whether the public key has expired.
|
98
|
+
# @return [Boolean] true if the key has expired, false otherwise.
|
99
|
+
def expired?
|
100
|
+
return false if expires_at.nil?
|
101
|
+
|
102
|
+
expires_at.to_i <= Time.now.to_i
|
103
|
+
end
|
104
|
+
|
105
|
+
# Encrypts data using the specified encryption algorithm.
|
106
|
+
# @param data [String] the data to be encrypted.
|
107
|
+
# @param algorithm [Integer] the encryption algorithm to use, defaults to AES-128.
|
108
|
+
# @return [String] the encrypted data encoded by base64.
|
109
|
+
def encrypt(data, algorithm = ENCRIPTION_ALGORITHM_AES_128)
|
110
|
+
encrypt_with_algorithm(data, algorithm)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pgp-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: x86_64-linux
|
6
|
+
authors:
|
7
|
+
- Kirill Zaitsev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rb_sys
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.13'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.13'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- kirik910@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- lib/pgp-rb/3.1/pgp_rb.so
|
91
|
+
- lib/pgp-rb/3.2/pgp_rb.so
|
92
|
+
- lib/pgp-rb/3.3/pgp_rb.so
|
93
|
+
- lib/pgp-rb/version.rb
|
94
|
+
- lib/pgp.rb
|
95
|
+
homepage: https://some
|
96
|
+
licenses:
|
97
|
+
- Apache
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options:
|
101
|
+
- "--main"
|
102
|
+
- README.rdoc
|
103
|
+
- "--charset"
|
104
|
+
- utf-8
|
105
|
+
- "--exclude"
|
106
|
+
- ext/
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '3.1'
|
114
|
+
- - "<"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 3.4.dev
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubygems_version: 3.4.4
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: rPGP ruby wrapper
|
127
|
+
test_files: []
|