Class: OpenPGP::S2K::Iterated
Overview
Constant Summary
collapse
- IDENTIFIER =
0x03
Constants inherited
from OpenPGP::S2K
DEFAULT
Instance Attribute Summary collapse
Attributes inherited from Salted
#salt
Attributes inherited from OpenPGP::S2K
#algorithm, #passphrase
Class Method Summary
collapse
Instance Method Summary
collapse
#digest, #digest_input_with_preload, #identifier, identifier, #to_key, #to_s
Constructor Details
#initialize(passphrase = nil, options = {}, &block) ⇒ Iterated
Returns a new instance of Iterated.
137
138
139
140
141
|
# File 'lib/openpgp/s2k.rb', line 137
def initialize(passphrase = nil, options = {}, &block)
super(passphrase, options, &block)
@count = 65536 unless @count
end
|
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
135
136
137
|
# File 'lib/openpgp/s2k.rb', line 135
def count
@count
end
|
Class Method Details
.parse(input) ⇒ Object
129
130
131
132
133
|
# File 'lib/openpgp/s2k.rb', line 129
def self.parse(input)
self.new(nil, :algorithm => input.read_byte, :salt => input.read_bytes(8)) do |s2k|
s2k.count = s2k.decode_count(input.read_byte)
end
end
|
Instance Method Details
152
153
154
155
156
157
158
159
160
|
# File 'lib/openpgp/s2k.rb', line 152
def digest_input
buffer = Buffer.write do |buffer|
iterations = count
while iterations > 0
buffer << (digest_input = super())
iterations -= digest_input.size
end
end
end
|
#to_hash ⇒ Object
148
149
150
|
# File 'lib/openpgp/s2k.rb', line 148
def to_hash
super.merge(:count => count)
end
|
#write(buffer) ⇒ Object
143
144
145
146
|
# File 'lib/openpgp/s2k.rb', line 143
def write(buffer)
super(buffer)
buffer.write_byte(encode_count(count))
end
|