Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-12 18:13:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-12 18:13:54 +0300
commit462b603802e45891ac5152aea8cbc9298d7d4a53 (patch)
treede7e03460744491c0d7dcc6e3340272f833fb3b7 /lib/gitlab/ssh_public_key.rb
parentda646aac6c559584f63d1fc06132d7351abcfac6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/ssh_public_key.rb')
-rw-r--r--lib/gitlab/ssh_public_key.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/gitlab/ssh_public_key.rb b/lib/gitlab/ssh_public_key.rb
index e51ec38394d..314cc5e2db6 100644
--- a/lib/gitlab/ssh_public_key.rb
+++ b/lib/gitlab/ssh_public_key.rb
@@ -2,13 +2,15 @@
module Gitlab
class SSHPublicKey
- Technology = Struct.new(:name, :key_class, :supported_sizes)
+ Technology = Struct.new(:name, :key_class, :supported_sizes, :supported_algorithms)
+ # See https://man.openbsd.org/sshd#AUTHORIZED_KEYS_FILE_FORMAT for the list of
+ # supported algorithms.
TECHNOLOGIES = [
- Technology.new(:rsa, OpenSSL::PKey::RSA, [1024, 2048, 3072, 4096]),
- Technology.new(:dsa, OpenSSL::PKey::DSA, [1024, 2048, 3072]),
- Technology.new(:ecdsa, OpenSSL::PKey::EC, [256, 384, 521]),
- Technology.new(:ed25519, Net::SSH::Authentication::ED25519::PubKey, [256])
+ Technology.new(:rsa, OpenSSL::PKey::RSA, [1024, 2048, 3072, 4096], %w(ssh-rsa)),
+ Technology.new(:dsa, OpenSSL::PKey::DSA, [1024, 2048, 3072], %w(ssh-dss)),
+ Technology.new(:ecdsa, OpenSSL::PKey::EC, [256, 384, 521], %w(ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521)),
+ Technology.new(:ed25519, Net::SSH::Authentication::ED25519::PubKey, [256], %w(ssh-ed25519))
].freeze
def self.technology(name)
@@ -24,7 +26,15 @@ module Gitlab
end
def self.supported_sizes(name)
- technology(name)&.supported_sizes
+ technology(name).supported_sizes
+ end
+
+ def self.supported_algorithms
+ TECHNOLOGIES.flat_map { |tech| tech.supported_algorithms }
+ end
+
+ def self.supported_algorithms_for_name(name)
+ technology(name).supported_algorithms
end
def self.sanitize(key_content)