Class: Ccrypto::BCryptConfig

Inherits:
KDFConfig show all
Defined in:
lib/ccrypto/configs/kdf_config.rb

Overview

BCrypt returns fixed 24 bytes (192 bits) output

Instance Attribute Summary collapse

Attributes inherited from KDFConfig

#algo

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AlgoConfig

include

Constructor Details

#initializeBCryptConfig

Returns a new instance of BCryptConfig.



159
160
161
162
163
164
165
166
167
# File 'lib/ccrypto/configs/kdf_config.rb', line 159

def initialize
  #@salt = SecureRandom.random_bytes(16)
  @cost = 16
  @outBitLength = self.class.outBitLength
  @max_input_byte_length = self.class.max_input_byte_length # 72 # bcrypt can only handle password  <= 72 bytes (Java BC)
  @salt_length = self.class.salt_length
  @cost_lowest_bound = self.class.cost_lowest_bound
  @cost_upper_bound = self.class.cost_upper_bound
end

Instance Attribute Details

#costObject

Cost is exponent 2^cost, range from 4 - 31 inclusive



129
130
131
# File 'lib/ccrypto/configs/kdf_config.rb', line 129

def cost
  @cost
end

#cost_lowest_boundObject (readonly)

Returns the value of attribute cost_lowest_bound.



133
134
135
# File 'lib/ccrypto/configs/kdf_config.rb', line 133

def cost_lowest_bound
  @cost_lowest_bound
end

#cost_upper_boundObject (readonly)

Returns the value of attribute cost_upper_bound.



133
134
135
# File 'lib/ccrypto/configs/kdf_config.rb', line 133

def cost_upper_bound
  @cost_upper_bound
end

#max_input_byte_lengthObject (readonly)

Fixed output length of 24 bytes / 192 bits



132
133
134
# File 'lib/ccrypto/configs/kdf_config.rb', line 132

def max_input_byte_length
  @max_input_byte_length
end

#outBitLengthObject (readonly)

Fixed output length of 24 bytes / 192 bits



132
133
134
# File 'lib/ccrypto/configs/kdf_config.rb', line 132

def outBitLength
  @outBitLength
end

#saltObject

Salt is 16 bytes long



127
128
129
# File 'lib/ccrypto/configs/kdf_config.rb', line 127

def salt
  @salt
end

#salt_lengthObject (readonly)

Returns the value of attribute salt_length.



133
134
135
# File 'lib/ccrypto/configs/kdf_config.rb', line 133

def salt_length
  @salt_length
end

Class Method Details

.cost_lowest_boundObject



151
152
153
# File 'lib/ccrypto/configs/kdf_config.rb', line 151

def self.cost_lowest_bound
  4
end

.cost_upper_boundObject



155
156
157
# File 'lib/ccrypto/configs/kdf_config.rb', line 155

def self.cost_upper_bound
  31
end

.max_input_byte_lengthObject



143
144
145
# File 'lib/ccrypto/configs/kdf_config.rb', line 143

def self.max_input_byte_length
  72
end

.outBitLengthObject



135
136
137
# File 'lib/ccrypto/configs/kdf_config.rb', line 135

def self.outBitLength
  192
end

.outByteLengthObject



139
140
141
# File 'lib/ccrypto/configs/kdf_config.rb', line 139

def self.outByteLength
  24
end

.salt_lengthObject



147
148
149
# File 'lib/ccrypto/configs/kdf_config.rb', line 147

def self.salt_length
  16
end