Revision aa797c6b
Added by Timo Goebel about 6 years ago
app/services/password_crypt.rb | ||
---|---|---|
class PasswordCrypt
|
||
ALGORITHMS = {'SHA256' => '$5$', 'SHA512' => '$6$', 'Base64' => ''}
|
||
|
||
if Foreman::Fips.md5_available?
|
||
ALGORITHMS['MD5']= '$1$'
|
||
end
|
||
|
||
def self.passw_crypt(passwd, hash_alg = 'SHA256')
|
||
raise Foreman::Exception.new(N_("Unsupported password hash function '%s'"), hash_alg) unless ALGORITHMS.has_key?(hash_alg)
|
||
result = (hash_alg == 'Base64') ? Base64.strict_encode64(passwd) : passwd.crypt("#{ALGORITHMS[hash_alg]}#{SecureRandom.base64(6)}")
|
lib/foreman/fips.rb | ||
---|---|---|
module Foreman
|
||
module Fips
|
||
def self.md5_available?
|
||
@md5_available ||= begin
|
||
OpenSSL::Digest::MD5.digest('')
|
||
true
|
||
rescue OpenSSL::Digest::DigestError
|
||
false
|
||
end
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
fixes #23621 - passwords can be md5 hashed