pgp-rb 0.1.2-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- 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 +118 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f09073ab5941f742295315ab0cc03e3691ff3402f3a48c962379c0d24a48f4d1
|
4
|
+
data.tar.gz: 4dd5ff7a98677acab9440f329077f520e399ffe9fd83a8406e30985a46628e8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eca00c7de8893b94905b5ed2c1c3e8404fe63e804a209451d3c28846ef769751169538e5aef44ab5c04c73d341d1cd9c9c6ec70ef172ac77a7a6804bafc818f5
|
7
|
+
data.tar.gz: 72fdd0e5d877cf8ac1698d9dcc2403faad06a9df961aa876c06c26864a6f561c74e734e0bf798bf7e77dd89626e4373bb7c49d641b97458f091b08074b317b35
|
Binary file
|
Binary file
|
Binary file
|
data/lib/pgp.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
/(?<ruby_version>\d+\.\d+)/ =~ RUBY_VERSION
|
5
|
+
require_relative "pgp-rb/#{ruby_version}/pgp_rb"
|
6
|
+
rescue LoadError
|
7
|
+
require_relative 'pgp-rb/pgp_rb'
|
8
|
+
end
|
9
|
+
|
10
|
+
module PGP
|
11
|
+
KEY_ALGORITHM_RSA = 1
|
12
|
+
KEY_ALGORITHM_RSA_ENCRYPT = 2
|
13
|
+
KEY_ALGORITHM_RSA_SIGN = 3
|
14
|
+
KEY_ALGORITHM_ELGAMAL_SIGN = 16
|
15
|
+
KEY_ALGORITHM_DSA = 17
|
16
|
+
KEY_ALGORITHM_ECDH = 18
|
17
|
+
KEY_ALGORITHM_ECDSA = 19
|
18
|
+
KEY_ALGORITHM_ELGAMAL = 20
|
19
|
+
KEY_ALGORITHM_DIFFIE_HELLMAN = 21
|
20
|
+
KEY_ALGORITHM_EDDSA = 22
|
21
|
+
|
22
|
+
KEY_ALGORITHM_NAMES = {
|
23
|
+
KEY_ALGORITHM_RSA => 'RSA (Encrypt and Sign)',
|
24
|
+
KEY_ALGORITHM_RSA_ENCRYPT => 'RSA (Encrypt-Only)',
|
25
|
+
KEY_ALGORITHM_RSA_SIGN => 'RSA (Sign-Only)',
|
26
|
+
KEY_ALGORITHM_ELGAMAL_SIGN => 'Elgamal (Sign-Only)',
|
27
|
+
KEY_ALGORITHM_DSA => 'DSA (Digital Signature Algorithm)',
|
28
|
+
KEY_ALGORITHM_ECDH => 'Elliptic Curve: RFC-6637',
|
29
|
+
KEY_ALGORITHM_ECDSA => 'ECDSA: RFC-6637',
|
30
|
+
KEY_ALGORITHM_ELGAMAL => 'Elgamal (Encrypt and Sign)',
|
31
|
+
KEY_ALGORITHM_DIFFIE_HELLMAN => 'Diffie-Hellman (X9.42, as defined for IETF-S/MIME)',
|
32
|
+
KEY_ALGORITHM_EDDSA => 'EdDSA'
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
ENCRYPTION_ALGORITHM_IDEA = 1
|
36
|
+
ENCRYPTION_ALGORITHM_TRIPLE_DES = 2
|
37
|
+
ENCRYPTION_ALGORITHM_CAST5 = 3
|
38
|
+
ENCRYPTION_ALGORITHM_BLOWFISH = 4
|
39
|
+
ENCRYPTION_ALGORITHM_AES_128 = 7
|
40
|
+
ENCRYPTION_ALGORITHM_AES_192 = 8
|
41
|
+
ENCRYPTION_ALGORITHM_AES_256 = 9
|
42
|
+
ENCRYPTION_ALGORITHM_TWOFISH = 10
|
43
|
+
ENCRYPTION_ALGORITHM_CAMELLIA_128 = 11
|
44
|
+
ENCRYPTION_ALGORITHM_CAMELLIA_192 = 12
|
45
|
+
ENCRYPTION_ALGORITHM_CAMELLIA_256 = 13
|
46
|
+
|
47
|
+
# Public Key class provides an native extension representation for working with PGP public keys.
|
48
|
+
class PublicKey
|
49
|
+
private_class_method :new
|
50
|
+
|
51
|
+
# @!method self.parse
|
52
|
+
# Parses a PGP public key from a given string input.
|
53
|
+
# @param input [String] the PGP public key in string format.
|
54
|
+
# @return [PublicKey] an instance of PublicKey if parsing is successful.
|
55
|
+
|
56
|
+
# @!method fingerprint
|
57
|
+
# Returns the fingerprint of the public key.
|
58
|
+
# @return [String] the fingerprint of the public key.
|
59
|
+
|
60
|
+
# @!method algorithm
|
61
|
+
# Returns the algorithm used by the public key.
|
62
|
+
# @return [Integer] the algorithm identifier.
|
63
|
+
|
64
|
+
# @!method signing_supported?
|
65
|
+
# Checks if the public key supports signing.
|
66
|
+
# @return [Boolean] true if the key supports signing, false otherwise.
|
67
|
+
|
68
|
+
# @!method encryption_supported?
|
69
|
+
# Checks if the public key supports encryption.
|
70
|
+
# @return [Boolean] true if the key supports encryption, false otherwise.
|
71
|
+
|
72
|
+
# @!method version
|
73
|
+
# Returns the version of the public key.
|
74
|
+
# @return [Integer] the version of the public key.
|
75
|
+
|
76
|
+
# @!method created_at
|
77
|
+
# Returns the creation time of the public key.
|
78
|
+
# @return [Time] the creation time of the public key.
|
79
|
+
|
80
|
+
# @!method expires_at
|
81
|
+
# Returns the expiration time of the public key, if any.
|
82
|
+
# @return [Time, nil] the expiration time of the public key or nil if it does not expire.
|
83
|
+
|
84
|
+
# @!method encrypt_with_algorithm(input, algorithm)
|
85
|
+
# Encrypts data with the specified algorithm.
|
86
|
+
# @param input [String] the data to be encrypted.
|
87
|
+
# @param algorithm [Integer] the encryption algorithm identifier.
|
88
|
+
# @return [String] the encrypted data encoded by base64.
|
89
|
+
|
90
|
+
# Returns a string representation of the PublicKey object, including its fingerprint, algorithm name, and version.
|
91
|
+
# @return [String] the string representation of the PublicKey object.
|
92
|
+
def inspect
|
93
|
+
"#<#{self.class} #{fingerprint} #{algorithm_name} v#{version}>"
|
94
|
+
end
|
95
|
+
|
96
|
+
# Fetches the name of the algorithm used by the public key from a predefined list of names.
|
97
|
+
# @return [String] the name of the algorithm.
|
98
|
+
def algorithm_name
|
99
|
+
KEY_ALGORITHM_NAMES.fetch(algorithm, 'Unknown')
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks whether the public key has expired.
|
103
|
+
# @return [Boolean] true if the key has expired, false otherwise.
|
104
|
+
def expired?
|
105
|
+
return false if expires_at.nil?
|
106
|
+
|
107
|
+
expires_at.to_i <= Time.now.to_i
|
108
|
+
end
|
109
|
+
|
110
|
+
# Encrypts data using the specified encryption algorithm.
|
111
|
+
# @param data [String] the data to be encrypted.
|
112
|
+
# @param algorithm [Integer] the encryption algorithm to use, defaults to AES-128.
|
113
|
+
# @return [String] the encrypted data encoded by base64.
|
114
|
+
def encrypt(data, algorithm = ENCRYPTION_ALGORITHM_AES_128)
|
115
|
+
encrypt_with_algorithm(data, algorithm)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
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.2
|
5
|
+
platform: aarch64-linux-musl
|
6
|
+
authors:
|
7
|
+
- Kirill Zaitsev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-05-23 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: 3.3.22
|
122
|
+
requirements: []
|
123
|
+
rubygems_version: 3.4.4
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: rPGP ruby wrapper
|
127
|
+
test_files: []
|