openssl-additions 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openssl/ssh_pkey.rb +41 -18
- 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: 9d01b46bfb7b9b7ede0a8bb827bcd9471fc77b9b742e0c05f48e3f087d5825fe
|
4
|
+
data.tar.gz: 997750442f217b63103d55aef642d668f2979075cf8e7d96fd50e4e00e13ee5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9baca53d9a137c51dc68e1dc57187864cad7aba656616752a7d5c7d8493a0650372923969313f080623283990e31d81d4fe6ecdf55b28d31b8cb8a5c9e160b1a
|
7
|
+
data.tar.gz: 0a6ce69fa390f8295e81dad132b5994031eeb28fa8df962c6aad957404bf3eb36e7f877a37e9e4d96f82a08b6d95567187bfdc14ed17006d314af85f373aa04d
|
data/lib/openssl/ssh_pkey.rb
CHANGED
@@ -296,7 +296,7 @@ module OpenSSL::PKey
|
|
296
296
|
end
|
297
297
|
|
298
298
|
def self.decode_public_ssh_key(s)
|
299
|
-
if s =~ /\A(ssh|ecdsa)
|
299
|
+
if s =~ /\A(sk-)?(ssh|ecdsa)-/
|
300
300
|
# WHOOP WHOOP prefixed key detected.
|
301
301
|
s = s.split(" ")[1]
|
302
302
|
else
|
@@ -313,27 +313,50 @@ module OpenSSL::PKey
|
|
313
313
|
|
314
314
|
case parts.first
|
315
315
|
when "ssh-rsa"
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
316
|
+
e = ssh_key_mpi_decode(parts[1])
|
317
|
+
n = ssh_key_mpi_decode(parts[2])
|
318
|
+
|
319
|
+
# OpenSSL 3.0 stole our set_key, so we now have to play silly DER round-trip games... sigh
|
320
|
+
OpenSSL::PKey.read(
|
321
|
+
OpenSSL::ASN1::Sequence.new([
|
322
|
+
OpenSSL::ASN1::Sequence.new([
|
323
|
+
OpenSSL::ASN1::ObjectId.new("rsaEncryption"),
|
324
|
+
OpenSSL::ASN1::Null.new(nil),
|
325
|
+
]),
|
326
|
+
OpenSSL::ASN1::BitString.new(
|
327
|
+
OpenSSL::ASN1::Sequence.new([
|
328
|
+
OpenSSL::ASN1::Integer.new(n),
|
329
|
+
OpenSSL::ASN1::Integer.new(e),
|
330
|
+
]).to_der
|
331
|
+
),
|
332
|
+
]).to_der
|
333
|
+
)
|
325
334
|
when /ecdsa-sha2-/
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
end
|
330
|
-
rescue TypeError
|
331
|
-
raise OpenSSL::PKey::PKeyError.new,
|
332
|
-
"Unknown curve identifier #{parts[1]}"
|
335
|
+
curve_name = SSH_CURVE_NAME_MAP[parts[1]]
|
336
|
+
if curve_name.nil?
|
337
|
+
raise OpenSSL::PKey::PKeyError.new, "Unknown curve identifier #{parts[1]}"
|
333
338
|
end
|
339
|
+
point = parts[2]
|
340
|
+
|
341
|
+
# OpenSSL 3.0 stole our set_key, so we now have to play silly DER round-trip games... sigh
|
342
|
+
OpenSSL::PKey.read(
|
343
|
+
OpenSSL::ASN1::Sequence.new([
|
344
|
+
OpenSSL::ASN1::Sequence.new([
|
345
|
+
OpenSSL::ASN1::ObjectId.new("id-ecPublicKey"),
|
346
|
+
OpenSSL::ASN1::ObjectId.new(curve_name),
|
347
|
+
]),
|
348
|
+
OpenSSL::ASN1::BitString.new(point),
|
349
|
+
]).to_der
|
350
|
+
)
|
351
|
+
when "ssh-ed25519", "sk-ssh-ed25519@openssh.com"
|
352
|
+
# The Ruby OpenSSL bindings don't appear to provide a way to directly construct
|
353
|
+
# an ed25519 key from its parts; instead, we've got to encode our own public key
|
354
|
+
# DER and then get OpenSSL to read it. Thankfully, ed25519 keys aren't too
|
355
|
+
# complicated to construct in DER.
|
356
|
+
OpenSSL::PKey.read(OpenSSL::ASN1::Sequence.new([OpenSSL::ASN1::Sequence.new([OpenSSL::ASN1::ObjectId.new("ED25519")]), OpenSSL::ASN1::BitString.new(parts[1])]).to_der)
|
334
357
|
else
|
335
358
|
raise OpenSSL::PKey::PKeyError,
|
336
|
-
"
|
359
|
+
"Unsupported key type #{parts.first.inspect}"
|
337
360
|
end
|
338
361
|
end
|
339
362
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openssl-additions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Palmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|