ssh_data 1.3.0 → 2.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d17ebf6c761d5e15b35c4fe273dd0431b327c41456e36971c402763a5ddcdfa
4
- data.tar.gz: c48ac30c8c9d53b022b8f06bfe5deaf8a16954f2fcdc91cfd3178fbd6804cc88
3
+ metadata.gz: a33f8e3096dba56186df0bf3288d36c0fda79f75d7a02e6a58c585b468d4cd76
4
+ data.tar.gz: 3f5f652b61e4fbbb06bc24154c51683e97be194a70565d993ee27ff87ec8eb2f
5
5
  SHA512:
6
- metadata.gz: c262a0c7c00ebab56b9c302625b3de59ced3b140e362c96cfddc4fb7d150d0d6515eab600177cb18b068a526b4e5d72314508a0ceec7bd89422321c85289dfbb
7
- data.tar.gz: 0b794f39c77676fcbab5c545a7b172c95fd37cd72048d9eb1d9e5de26efd70e971ab318b32fa428752e364e1f24c8afa2841b9d582aab59fc4ea66abb396123a
6
+ metadata.gz: b6b1324539e847dd7e7d858cd0f64a8c369de781bdb8f5fcde7667ad9a61748e347209f7d6f06f7e5400d9147e67a9289f6f99aa187ec368bfc4a38ddccc22b9
7
+ data.tar.gz: 7c1a063701138b853aebff7adb7f7a9d8bccabdf04d58d81dffb16ab2a499706401355ac01f2f4e8e91789140fd051569ecf8056eae27a76d0ae1425128e62c7
@@ -424,7 +424,7 @@ module SSHData
424
424
  [hash, total_read]
425
425
  end
426
426
 
427
- # Encode the series of fiends into a binary string.
427
+ # Encode the series of fields into a binary string.
428
428
  #
429
429
  # fields - A series of Arrays, each containing a Symbol type and a value to
430
430
  # encode.
@@ -13,7 +13,7 @@ module SSHData
13
13
  openssl_curve = PublicKey::ECDSA::OPENSSL_CURVE_NAME_FOR_CURVE[curve]
14
14
  raise AlgorithmError, "unknown curve: #{curve}" if openssl_curve.nil?
15
15
 
16
- openssl_key = OpenSSL::PKey::EC.new(openssl_curve).tap(&:generate_key)
16
+ openssl_key = OpenSSL::PKey::EC.generate(openssl_curve)
17
17
  from_openssl(openssl_key)
18
18
  end
19
19
 
@@ -21,9 +21,9 @@ module SSHData
21
21
 
22
22
  # Import an openssl private key.
23
23
  #
24
- # key - An OpenSSL::PKey::DSA instance.
24
+ # key - An OpenSSL::PKey::RSA instance.
25
25
  #
26
- # Returns a DSA instance.
26
+ # Returns a RSA instance.
27
27
  def self.from_openssl(key)
28
28
  new(
29
29
  algo: PublicKey::ALGO_RSA,
@@ -67,7 +67,7 @@ module SSHData
67
67
  # Verify an SSH signature.
68
68
  #
69
69
  # signed_data - The String message that the signature was calculated over.
70
- # signature - The binarty String signature with SSH encoding.
70
+ # signature - The binary String signature with SSH encoding.
71
71
  #
72
72
  # Returns boolean.
73
73
  def verify(signed_data, signature)
@@ -93,7 +93,7 @@ module SSHData
93
93
  # Verify an SSH signature.
94
94
  #
95
95
  # signed_data - The String message that the signature was calculated over.
96
- # signature - The binarty String signature with SSH encoding.
96
+ # signature - The binary String signature with SSH encoding.
97
97
  #
98
98
  # Returns boolean.
99
99
  def verify(signed_data, signature)
@@ -37,7 +37,7 @@ module SSHData
37
37
  # Verify an SSH signature.
38
38
  #
39
39
  # signed_data - The String message that the signature was calculated over.
40
- # signature - The binarty String signature with SSH encoding.
40
+ # signature - The binary String signature with SSH encoding.
41
41
  #
42
42
  # Returns boolean.
43
43
  def verify(signed_data, signature)
@@ -26,7 +26,7 @@ module SSHData
26
26
  # Verify an SSH signature.
27
27
  #
28
28
  # signed_data - The String message that the signature was calculated over.
29
- # signature - The binarty String signature with SSH encoding.
29
+ # signature - The binary String signature with SSH encoding.
30
30
  #
31
31
  # Returns boolean.
32
32
  def verify(signed_data, signature)
@@ -37,6 +37,12 @@ module SSHData
37
37
  raise DecodeError, "bad signature algorithm: #{sig_algo.inspect}"
38
38
  end
39
39
 
40
+ # OpenSSH compatibility: if a the number of bytes in the signature is less than the number of bytes of the RSA
41
+ # modulus, prepend the signature with zeros.
42
+ # See https://github.com/openssh/openssh-portable/blob/ac383f3a5c6f529a2e8a5bc44af79a08c7da294e/ssh-rsa.c#L531
43
+ difference = n.num_bytes - raw_sig.bytesize
44
+ raw_sig = "\0" * difference + raw_sig if difference.positive?
45
+
40
46
  openssl.verify(digest.new, raw_sig, signed_data)
41
47
  end
42
48
 
@@ -108,6 +108,10 @@ module SSHData
108
108
  # If the signature was created from a certificate, this will be an
109
109
  # SSHData::Certificate. Otherwise, this will be a PublicKey algorithm.
110
110
  def public_key
111
+ @data_public_key ||= load_public_key
112
+ end
113
+
114
+ private def load_public_key
111
115
  public_key_algorithm, _ = Encoding.decode_string(@publickey)
112
116
 
113
117
  if PublicKey::ALGOS.include?(public_key_algorithm)
@@ -1,3 +1,3 @@
1
1
  module SSHData
2
- VERSION = "1.3.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mastahyeti
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-01-21 00:00:00.000000000 Z
10
+ date: 2025-01-06 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '0.1'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '0.1'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: ed25519
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +65,20 @@ dependencies:
52
65
  - - "~>"
53
66
  - !ruby/object:Gem::Version
54
67
  version: '3.10'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec-parameterized
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.0'
55
82
  - !ruby/object:Gem::Dependency
56
83
  name: rspec-mocks
57
84
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +93,6 @@ dependencies:
66
93
  - - "~>"
67
94
  - !ruby/object:Gem::Version
68
95
  version: '3.10'
69
- description:
70
96
  email: opensource+ssh_data@github.com
71
97
  executables: []
72
98
  extensions: []
@@ -98,7 +124,6 @@ homepage: https://github.com/github/ssh_data
98
124
  licenses:
99
125
  - MIT
100
126
  metadata: {}
101
- post_install_message:
102
127
  rdoc_options: []
103
128
  require_paths:
104
129
  - lib
@@ -106,15 +131,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
131
  requirements:
107
132
  - - ">="
108
133
  - !ruby/object:Gem::Version
109
- version: '2.3'
134
+ version: '3.1'
110
135
  required_rubygems_version: !ruby/object:Gem::Requirement
111
136
  requirements:
112
137
  - - ">="
113
138
  - !ruby/object:Gem::Version
114
139
  version: '0'
115
140
  requirements: []
116
- rubygems_version: 3.1.2
117
- signing_key:
141
+ rubygems_version: 3.6.2
118
142
  specification_version: 4
119
143
  summary: Library for parsing SSH certificates
120
144
  test_files: []