Class: Gitlab::InsecureKeyFingerprint

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/insecure_key_fingerprint.rb

Overview

Calculates the fingerprint of a given key without using openssh key validations. For this reason, only use for calculating the fingerprint to find the key with it.

DO NOT use it for checking the validity of a ssh key.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key_base64) ⇒ InsecureKeyFingerprint

Gets the base64 encoded string representing a rsa or dsa key


18
19
20
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 18

def initialize(key_base64)
  @key = key_base64
end

Instance Attribute Details

#keyObject

Returns the value of attribute key


12
13
14
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 12

def key
  @key
end

Instance Method Details

#fingerprintObject


22
23
24
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 22

def fingerprint
  OpenSSL::Digest::MD5.hexdigest(Base64.decode64(@key)).scan(/../).join(':')
end

#fingerprint_sha256Object


26
27
28
# File 'lib/gitlab/insecure_key_fingerprint.rb', line 26

def fingerprint_sha256
  Digest::SHA256.base64digest(Base64.decode64(@key)).scan(/../).join('').delete("=")
end