Class: CcipherFactory::Digest::SupportedDigest

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/ccipher_factory/digest/supported_digest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSupportedDigest

Returns a new instance of SupportedDigest.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ccipher_factory/digest/supported_digest.rb', line 10

def initialize
  #@possible = [:sha1, :sha224, :sha256, :sha384, :sha512, :sha3_224, :sha3_256, :sha3_384, :sha3_512, :shake128, :shake256]
  #@supported = []
  #test_algo

  @dig = Ccrypto::AlgoFactory.engine(Ccrypto::DigestConfig)

  @possible = @dig.engineKeys.keys
  @supported = @possible

  if @dig.is_supported?(:sha3_256)
    @default_digest = :sha3_256
  elsif @dig.is_supported?(:sha256)
    @default_digest = :sha256
  else
    raise DigestError, "Failed to set default digest" 
  end
end

Instance Attribute Details

#default_digestObject (readonly)

Returns the value of attribute default_digest.



9
10
11
# File 'lib/ccipher_factory/digest/supported_digest.rb', line 9

def default_digest
  @default_digest
end

#possibleObject (readonly)

Returns the value of attribute possible.



9
10
11
# File 'lib/ccipher_factory/digest/supported_digest.rb', line 9

def possible
  @possible
end

#supportedObject (readonly)

Returns the value of attribute supported.



9
10
11
# File 'lib/ccipher_factory/digest/supported_digest.rb', line 9

def supported
  @supported
end

Instance Method Details

#is_supported?(algo) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/ccipher_factory/digest/supported_digest.rb', line 29

def is_supported?(algo)
  #@supported.include?(algo)
  @dig.is_supported?(algo)
end