Class: NemID::Crypto

Inherits:
Object
  • Object
show all
Defined in:
lib/nemid/crypto.rb

Instance Method Summary collapse

Constructor Details

#initialize(cert:, key:) ⇒ Crypto

Returns a new instance of Crypto.



6
7
8
9
# File 'lib/nemid/crypto.rb', line 6

def initialize(cert:, key:)
  @certificate = read_x509(cert)
  @rsa_instance = rsa_keypair(key)
end

Instance Method Details

#base64_encoded_der_representationObject



11
12
13
# File 'lib/nemid/crypto.rb', line 11

def base64_encoded_der_representation
  Base64.strict_encode64(@certificate.to_der)
end

#base64_encoded_digest_representation(data) ⇒ Object



15
16
17
# File 'lib/nemid/crypto.rb', line 15

def base64_encoded_digest_representation(data)
  Base64.strict_encode64(digest(data))
end

#base64_encoded_rsa_signature(data) ⇒ Object



19
20
21
# File 'lib/nemid/crypto.rb', line 19

def base64_encoded_rsa_signature(data)
  Base64.strict_encode64(sign(data))
end

#get_certificateObject



23
24
25
# File 'lib/nemid/crypto.rb', line 23

def get_certificate
  @certificate
end

#get_keyObject



27
28
29
# File 'lib/nemid/crypto.rb', line 27

def get_key
  @rsa_instance
end