Class: PQCrypto::Signature::SecretKey
- Inherits:
-
Object
- Object
- PQCrypto::Signature::SecretKey
- Defined in:
- lib/pq_crypto/signature.rb
Instance Attribute Summary collapse
-
#algorithm ⇒ Object
readonly
Returns the value of attribute algorithm.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(algorithm, bytes) ⇒ SecretKey
constructor
A new instance of SecretKey.
- #inspect ⇒ Object
- #sign(message) ⇒ Object
- #sign_io(io, chunk_size: 1 << 20, context: "".b) ⇒ Object
- #to_bytes ⇒ Object
- #to_pqc_container_der ⇒ Object
- #to_pqc_container_pem ⇒ Object
- #wipe! ⇒ Object
Constructor Details
#initialize(algorithm, bytes) ⇒ SecretKey
Returns a new instance of SecretKey.
258 259 260 261 262 |
# File 'lib/pq_crypto/signature.rb', line 258 def initialize(algorithm, bytes) @algorithm = algorithm @bytes = String(bytes).b validate_length! end |
Instance Attribute Details
#algorithm ⇒ Object (readonly)
Returns the value of attribute algorithm.
256 257 258 |
# File 'lib/pq_crypto/signature.rb', line 256 def algorithm @algorithm end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
291 292 293 294 |
# File 'lib/pq_crypto/signature.rb', line 291 def ==(other) return false unless other.is_a?(SecretKey) && other.algorithm == algorithm PQCrypto.__send__(:native_ct_equals, other.to_bytes, @bytes) end |
#hash ⇒ Object
298 299 300 |
# File 'lib/pq_crypto/signature.rb', line 298 def hash object_id.hash end |
#inspect ⇒ Object
302 303 304 |
# File 'lib/pq_crypto/signature.rb', line 302 def inspect "#<#{self.class}:0x#{object_id.to_s(16)} algorithm=#{algorithm.inspect}>" end |
#sign(message) ⇒ Object
276 277 278 279 280 |
# File 'lib/pq_crypto/signature.rb', line 276 def sign() PQCrypto.__send__(:native_sign, String().b, @bytes) rescue ArgumentError => e raise InvalidKeyError, e. end |
#sign_io(io, chunk_size: 1 << 20, context: "".b) ⇒ Object
282 283 284 |
# File 'lib/pq_crypto/signature.rb', line 282 def sign_io(io, chunk_size: 1 << 20, context: "".b) Signature.send(:_streaming_sign, self, io, chunk_size, context) end |
#to_bytes ⇒ Object
264 265 266 |
# File 'lib/pq_crypto/signature.rb', line 264 def to_bytes @bytes.dup end |
#to_pqc_container_der ⇒ Object
268 269 270 |
# File 'lib/pq_crypto/signature.rb', line 268 def to_pqc_container_der Serialization.secret_key_to_pqc_container_der(@algorithm, @bytes) end |
#to_pqc_container_pem ⇒ Object
272 273 274 |
# File 'lib/pq_crypto/signature.rb', line 272 def to_pqc_container_pem Serialization.secret_key_to_pqc_container_pem(@algorithm, @bytes) end |
#wipe! ⇒ Object
286 287 288 289 |
# File 'lib/pq_crypto/signature.rb', line 286 def wipe! PQCrypto.secure_wipe(@bytes) self end |