ssh_data 1.1.0 → 1.2.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: aaa29fd598724a11d13c32aa423fdb26944b5ed7d027b852de0fb3b6c8808f54
4
- data.tar.gz: 6737375c449655f42d8f6a629065ad1e493f301e6ed118ca23a2d6b939b2516c
3
+ metadata.gz: e2a37d746413f208ac72e4dca430d8e9ad71646cdab1a86a4beb1939d538ca00
4
+ data.tar.gz: 37c066043665eb883f68f1a0bbff2c7b814a6c11a32dcef02d19cb24a7fd9b17
5
5
  SHA512:
6
- metadata.gz: 43afd3056dd763d3bfbeb44e98936a6a35a97172000772bb91107a516642c384b3398127e211a792193102351fe3ab6bafcf2d4e7674c7233f7610f743f80341
7
- data.tar.gz: e0cc819489d6ac78f0cdf2e3fb9d22ded46dda75e11e6275d9e47a354d951ed753434a1cacc82377b4c1ef4c3469e8df73cc82e981062c2d0476513f7e9a287d
6
+ metadata.gz: 2e32a7671a4bebef2e1a9035a9be8692af5f8274e9b6e8ca8043421ed8adf620eb88878a8a55deca82d9b1c1fad725d6018230c5bd7a75a8bec727a39e8823f8
7
+ data.tar.gz: e0b84d38f45eb30d9ac0a1940e26b70a83677f68bb399c206f6a599194ffddd77a9a77f18e27b2cad94de5004c67e7bf63f009f621ab9b9dabc2637fba85f1ad
@@ -12,16 +12,18 @@ module SSHData
12
12
  TYPE_HOST = 2
13
13
 
14
14
  # Certificate algorithm identifiers
15
- ALGO_RSA = "ssh-rsa-cert-v01@openssh.com"
16
- ALGO_DSA = "ssh-dss-cert-v01@openssh.com"
17
- ALGO_ECDSA256 = "ecdsa-sha2-nistp256-cert-v01@openssh.com"
18
- ALGO_ECDSA384 = "ecdsa-sha2-nistp384-cert-v01@openssh.com"
19
- ALGO_ECDSA521 = "ecdsa-sha2-nistp521-cert-v01@openssh.com"
20
- ALGO_ED25519 = "ssh-ed25519-cert-v01@openssh.com"
15
+ ALGO_RSA = "ssh-rsa-cert-v01@openssh.com"
16
+ ALGO_DSA = "ssh-dss-cert-v01@openssh.com"
17
+ ALGO_ECDSA256 = "ecdsa-sha2-nistp256-cert-v01@openssh.com"
18
+ ALGO_ECDSA384 = "ecdsa-sha2-nistp384-cert-v01@openssh.com"
19
+ ALGO_ECDSA521 = "ecdsa-sha2-nistp521-cert-v01@openssh.com"
20
+ ALGO_ED25519 = "ssh-ed25519-cert-v01@openssh.com"
21
+ ALGO_SKECDSA256 = "sk-ecdsa-sha2-nistp256-cert-v01@openssh.com"
22
+ ALGO_SKED25519 = "sk-ssh-ed25519-cert-v01@openssh.com"
21
23
 
22
24
  ALGOS = [
23
25
  ALGO_RSA, ALGO_DSA, ALGO_ECDSA256, ALGO_ECDSA384, ALGO_ECDSA521,
24
- ALGO_ED25519
26
+ ALGO_ED25519, ALGO_SKECDSA256, ALGO_SKED25519
25
27
  ]
26
28
 
27
29
  CRITICAL_OPTION_FORCE_COMMAND = "force-command"
@@ -62,27 +62,44 @@ module SSHData
62
62
  [:public_key, :string]
63
63
  ]
64
64
 
65
+ # Fields in an SK-ECDSA public key
66
+ SKECDSA_KEY_FIELDS = [
67
+ [:curve, :string],
68
+ [:public_key, :string],
69
+ [:application, :string]
70
+ ]
71
+
65
72
  # Fields in a ED25519 public key
66
73
  ED25519_KEY_FIELDS = [
67
74
  [:pk, :string]
68
75
  ]
69
76
 
77
+ # Fields in a SK-ED25519 public key
78
+ SKED25519_KEY_FIELDS = [
79
+ [:pk, :string],
80
+ [:application, :string]
81
+ ]
82
+
70
83
  PUBLIC_KEY_ALGO_BY_CERT_ALGO = {
71
- Certificate::ALGO_RSA => PublicKey::ALGO_RSA,
72
- Certificate::ALGO_DSA => PublicKey::ALGO_DSA,
73
- Certificate::ALGO_ECDSA256 => PublicKey::ALGO_ECDSA256,
74
- Certificate::ALGO_ECDSA384 => PublicKey::ALGO_ECDSA384,
75
- Certificate::ALGO_ECDSA521 => PublicKey::ALGO_ECDSA521,
76
- Certificate::ALGO_ED25519 => PublicKey::ALGO_ED25519,
84
+ Certificate::ALGO_RSA => PublicKey::ALGO_RSA,
85
+ Certificate::ALGO_DSA => PublicKey::ALGO_DSA,
86
+ Certificate::ALGO_ECDSA256 => PublicKey::ALGO_ECDSA256,
87
+ Certificate::ALGO_ECDSA384 => PublicKey::ALGO_ECDSA384,
88
+ Certificate::ALGO_ECDSA521 => PublicKey::ALGO_ECDSA521,
89
+ Certificate::ALGO_ED25519 => PublicKey::ALGO_ED25519,
90
+ Certificate::ALGO_SKECDSA256 => PublicKey::ALGO_SKECDSA256,
91
+ Certificate::ALGO_SKED25519 => PublicKey::ALGO_SKED25519,
77
92
  }
78
93
 
79
94
  CERT_ALGO_BY_PUBLIC_KEY_ALGO = {
80
- PublicKey::ALGO_RSA => Certificate::ALGO_RSA,
81
- PublicKey::ALGO_DSA => Certificate::ALGO_DSA,
82
- PublicKey::ALGO_ECDSA256 => Certificate::ALGO_ECDSA256,
83
- PublicKey::ALGO_ECDSA384 => Certificate::ALGO_ECDSA384,
84
- PublicKey::ALGO_ECDSA521 => Certificate::ALGO_ECDSA521,
85
- PublicKey::ALGO_ED25519 => Certificate::ALGO_ED25519,
95
+ PublicKey::ALGO_RSA => Certificate::ALGO_RSA,
96
+ PublicKey::ALGO_DSA => Certificate::ALGO_DSA,
97
+ PublicKey::ALGO_ECDSA256 => Certificate::ALGO_ECDSA256,
98
+ PublicKey::ALGO_ECDSA384 => Certificate::ALGO_ECDSA384,
99
+ PublicKey::ALGO_ECDSA521 => Certificate::ALGO_ECDSA521,
100
+ PublicKey::ALGO_ED25519 => Certificate::ALGO_ED25519,
101
+ PublicKey::ALGO_SKECDSA256 => Certificate::ALGO_SKECDSA256,
102
+ PublicKey::ALGO_SKED25519 => Certificate::ALGO_SKED25519,
86
103
  }
87
104
 
88
105
  KEY_FIELDS_BY_PUBLIC_KEY_ALGO = {
@@ -92,6 +109,8 @@ module SSHData
92
109
  PublicKey::ALGO_ECDSA384 => ECDSA_KEY_FIELDS,
93
110
  PublicKey::ALGO_ECDSA521 => ECDSA_KEY_FIELDS,
94
111
  PublicKey::ALGO_ED25519 => ED25519_KEY_FIELDS,
112
+ PublicKey::ALGO_SKED25519 => SKED25519_KEY_FIELDS,
113
+ PublicKey::ALGO_SKECDSA256 => SKECDSA_KEY_FIELDS,
95
114
  }
96
115
 
97
116
  KEY_FIELDS_BY_PRIVATE_KEY_ALGO = {
@@ -1,7 +1,8 @@
1
1
  module SSHData
2
- Error = Class.new(StandardError)
3
- DecodeError = Class.new(Error)
4
- VerifyError = Class.new(Error)
5
- AlgorithmError = Class.new(Error)
6
- DecryptError = Class.new(Error)
2
+ Error = Class.new(StandardError)
3
+ DecodeError = Class.new(Error)
4
+ VerifyError = Class.new(Error)
5
+ AlgorithmError = Class.new(Error)
6
+ DecryptError = Class.new(Error)
7
+ UnsupportedError = Class.new(Error)
7
8
  end
@@ -65,7 +65,7 @@ module SSHData
65
65
  [Encoding.encode_mpint(r.value), Encoding.encode_mpint(s.value)].join
66
66
  end
67
67
 
68
- def initialize(algo:, curve:, public_key:)
68
+ def self.check_algorithm!(algo, curve)
69
69
  unless [ALGO_ECDSA256, ALGO_ECDSA384, ALGO_ECDSA521].include?(algo)
70
70
  raise DecodeError, "bad algorithm: #{algo.inspect}"
71
71
  end
@@ -73,6 +73,10 @@ module SSHData
73
73
  unless algo == "ecdsa-sha2-#{curve}"
74
74
  raise DecodeError, "bad curve: #{curve.inspect}"
75
75
  end
76
+ end
77
+
78
+ def initialize(algo:, curve:, public_key:)
79
+ self.class.check_algorithm!(algo, curve)
76
80
 
77
81
  @curve = curve
78
82
  @public_key_bytes = public_key
@@ -16,8 +16,12 @@ module SSHData
16
16
  raise AlgorithmError, "the ed25519 gem is not loaded" unless enabled?
17
17
  end
18
18
 
19
+ def self.algorithm_identifier
20
+ ALGO_ED25519
21
+ end
22
+
19
23
  def initialize(algo:, pk:)
20
- unless algo == ALGO_ED25519
24
+ unless algo == self.class.algorithm_identifier
21
25
  raise DecodeError, "bad algorithm: #{algo.inspect}"
22
26
  end
23
27
 
@@ -40,7 +44,7 @@ module SSHData
40
44
  self.class.ed25519_gem_required!
41
45
 
42
46
  sig_algo, raw_sig, _ = Encoding.decode_signature(signature)
43
- if sig_algo != ALGO_ED25519
47
+ if sig_algo != self.class.algorithm_identifier
44
48
  raise DecodeError, "bad signature algorithm: #{sig_algo.inspect}"
45
49
  end
46
50
 
@@ -0,0 +1,46 @@
1
+ module SSHData
2
+ module PublicKey
3
+ class SKECDSA < ECDSA
4
+ attr_reader :application
5
+
6
+ OPENSSL_CURVE_NAME_FOR_CURVE = {
7
+ NISTP256 => "prime256v1",
8
+ }
9
+
10
+ def self.check_algorithm!(algo, curve)
11
+ unless algo == ALGO_SKECDSA256
12
+ raise DecodeError, "bad algorithm: #{algo.inspect}"
13
+ end
14
+
15
+ unless algo == "sk-ecdsa-sha2-#{curve}@openssh.com"
16
+ raise DecodeError, "bad curve: #{curve.inspect}"
17
+ end
18
+ end
19
+
20
+ def initialize(algo:, curve:, public_key:, application:)
21
+ @application = application
22
+ super(algo: algo, curve: curve, public_key: public_key)
23
+ end
24
+
25
+ # RFC4253 binary encoding of the public key.
26
+ #
27
+ # Returns a binary String.
28
+ def rfc4253
29
+ Encoding.encode_fields(
30
+ [:string, algo],
31
+ [:string, curve],
32
+ [:string, public_key_bytes],
33
+ [:string, application],
34
+ )
35
+ end
36
+
37
+ def verify(signed_data, signature)
38
+ raise UnsupportedError, "SK-ECDSA verification is not supported."
39
+ end
40
+
41
+ def ==(other)
42
+ super && other.application == application
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,35 @@
1
+ module SSHData
2
+ module PublicKey
3
+ class SKED25519 < ED25519
4
+ attr_reader :application
5
+
6
+ def initialize(algo:, pk:, application:)
7
+ @application = application
8
+ super(algo: algo, pk: pk)
9
+ end
10
+
11
+ def self.algorithm_identifier
12
+ ALGO_SKED25519
13
+ end
14
+
15
+ # RFC4253 binary encoding of the public key.
16
+ #
17
+ # Returns a binary String.
18
+ def rfc4253
19
+ Encoding.encode_fields(
20
+ [:string, algo],
21
+ [:string, pk],
22
+ [:string, application],
23
+ )
24
+ end
25
+
26
+ def verify(signed_data, signature)
27
+ raise UnsupportedError, "SK-Ed25519 verification is not supported."
28
+ end
29
+
30
+ def ==(other)
31
+ super && other.application == application
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,12 +1,14 @@
1
1
  module SSHData
2
2
  module PublicKey
3
3
  # Public key algorithm identifiers
4
- ALGO_RSA = "ssh-rsa"
5
- ALGO_DSA = "ssh-dss"
6
- ALGO_ECDSA256 = "ecdsa-sha2-nistp256"
7
- ALGO_ECDSA384 = "ecdsa-sha2-nistp384"
8
- ALGO_ECDSA521 = "ecdsa-sha2-nistp521"
9
- ALGO_ED25519 = "ssh-ed25519"
4
+ ALGO_RSA = "ssh-rsa"
5
+ ALGO_DSA = "ssh-dss"
6
+ ALGO_ECDSA256 = "ecdsa-sha2-nistp256"
7
+ ALGO_ECDSA384 = "ecdsa-sha2-nistp384"
8
+ ALGO_ECDSA521 = "ecdsa-sha2-nistp521"
9
+ ALGO_ED25519 = "ssh-ed25519"
10
+ ALGO_SKED25519 = "sk-ssh-ed25519@openssh.com"
11
+ ALGO_SKECDSA256 = "sk-ecdsa-sha2-nistp256@openssh.com"
10
12
 
11
13
  # RSA SHA2 *signature* algorithms used with ALGO_RSA keys.
12
14
  # https://tools.ietf.org/html/draft-rsa-dsa-sha2-256-02
@@ -15,7 +17,7 @@ module SSHData
15
17
 
16
18
  ALGOS = [
17
19
  ALGO_RSA, ALGO_DSA, ALGO_ECDSA256, ALGO_ECDSA384, ALGO_ECDSA521,
18
- ALGO_ED25519
20
+ ALGO_ED25519, ALGO_SKECDSA256, ALGO_SKED25519
19
21
  ]
20
22
 
21
23
  # Parse an OpenSSH public key in authorized_keys format (see sshd(8) manual
@@ -64,6 +66,10 @@ module SSHData
64
66
  ECDSA.new(**data)
65
67
  when ALGO_ED25519
66
68
  ED25519.new(**data)
69
+ when ALGO_SKED25519
70
+ SKED25519.new(**data)
71
+ when ALGO_SKECDSA256
72
+ SKECDSA.new(**data)
67
73
  else
68
74
  raise DecodeError, "unkown algo: #{data[:algo].inspect}"
69
75
  end
@@ -76,3 +82,5 @@ require "ssh_data/public_key/rsa"
76
82
  require "ssh_data/public_key/dsa"
77
83
  require "ssh_data/public_key/ecdsa"
78
84
  require "ssh_data/public_key/ed25519"
85
+ require "ssh_data/public_key/sked25519"
86
+ require "ssh_data/public_key/skecdsa"
@@ -1,3 +1,3 @@
1
1
  module SSHData
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mastahyeti
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ed25519
@@ -30,43 +30,43 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.10'
33
+ version: '0.14'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.10'
40
+ version: '0.14'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.5'
47
+ version: '3.10'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.5'
54
+ version: '3.10'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-mocks
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '3.10'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
69
- description:
68
+ version: '3.10'
69
+ description:
70
70
  email: opensource+ssh_data@github.com
71
71
  executables: []
72
72
  extensions: []
@@ -89,18 +89,20 @@ files:
89
89
  - "./lib/ssh_data/public_key/ecdsa.rb"
90
90
  - "./lib/ssh_data/public_key/ed25519.rb"
91
91
  - "./lib/ssh_data/public_key/rsa.rb"
92
+ - "./lib/ssh_data/public_key/skecdsa.rb"
93
+ - "./lib/ssh_data/public_key/sked25519.rb"
92
94
  - "./lib/ssh_data/version.rb"
93
95
  homepage: https://github.com/github/ssh_data
94
96
  licenses:
95
97
  - MIT
96
98
  metadata: {}
97
- post_install_message:
99
+ post_install_message:
98
100
  rdoc_options: []
99
101
  require_paths:
100
102
  - lib
101
103
  required_ruby_version: !ruby/object:Gem::Requirement
102
104
  requirements:
103
- - - "~>"
105
+ - - ">="
104
106
  - !ruby/object:Gem::Version
105
107
  version: '2.3'
106
108
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -109,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
111
  - !ruby/object:Gem::Version
110
112
  version: '0'
111
113
  requirements: []
112
- rubygems_version: 3.0.4
113
- signing_key:
114
+ rubygems_version: 3.1.2
115
+ signing_key:
114
116
  specification_version: 4
115
117
  summary: Library for parsing SSH certificates
116
118
  test_files: []