Module: Tripwire::Server::CryptoSupport

Defined in:
lib/tripwire/server/crypto_support.rb

Constant Summary collapse

MIN_SUPPORTED_RUBY_VERSION =
Gem::Version.new("3.3.0")
UNSUPPORTED_RUNTIME_MESSAGE =
"Tripwire Ruby cryptography helpers require Ruby 3.3+ with modern OpenSSL support.".freeze

Class Method Summary collapse

Class Method Details

.ensure_supported_runtime!Object

Raises:



22
23
24
25
26
# File 'lib/tripwire/server/crypto_support.rb', line 22

def ensure_supported_runtime!
  return if supported_runtime?

  raise ConfigurationError, UNSUPPORTED_RUNTIME_MESSAGE
end

.minimum_supported_ruby_versionObject



28
29
30
# File 'lib/tripwire/server/crypto_support.rb', line 28

def minimum_supported_ruby_version
  MIN_SUPPORTED_RUBY_VERSION
end

.supported_runtime?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/tripwire/server/crypto_support.rb', line 12

def supported_runtime?
  return @supported_runtime unless @supported_runtime.nil?

  @supported_runtime = Gem::Version.new(RUBY_VERSION) >= MIN_SUPPORTED_RUBY_VERSION &&
    OpenSSL::PKey.respond_to?(:generate_key) &&
    defined?(OpenSSL::KDF) &&
    OpenSSL::KDF.respond_to?(:hkdf) &&
    aead_auth_data_supported?
end

.unsupported_runtime_messageObject



32
33
34
# File 'lib/tripwire/server/crypto_support.rb', line 32

def unsupported_runtime_message
  UNSUPPORTED_RUNTIME_MESSAGE
end