Class: Ccrypto::Java::ECCKeyBundle

Inherits:
Object
  • Object
show all
Includes:
ECCKeyBundle, DataConversion, TR::CondUtils
Defined in:
lib/ccrypto/java/engines/ecc_engine.rb

Overview

class ECCPrivateKey

Instance Method Summary collapse

Methods included from DataConversion

#from_b64, #from_b64_mime, #from_hex, included, #logger, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str

Constructor Details

#initialize(kp, conf) ⇒ ECCKeyBundle

Returns a new instance of ECCKeyBundle.



151
152
153
154
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 151

def initialize(kp, conf)
  @nativeKeypair = kp
  @config = conf
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mtd, *args, &block) ⇒ Object (private)



261
262
263
264
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 261

def method_missing(mtd, *args, &block)
  teLogger.debug "Sending to native #{mtd}"
  @nativeKeypair.send(mtd, *args, &block)
end

Instance Method Details

#curveObject



156
157
158
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 156

def curve
  @config.provider_config[:curve]
end

#derive_dec_shared_secret(*args, &block) ⇒ Object

standardize external API



184
185
186
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 184

def derive_dec_shared_secret(*args, &block)
  derive_dh_shared_secret(*args, &block)
end

#derive_enc_shared_secret(*args, &block) ⇒ Object

standardize external API



179
180
181
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 179

def derive_enc_shared_secret(*args, &block)
  derive_dh_shared_secret(*args, &block) 
end

#equal?(kp) ⇒ Boolean

Returns:

  • (Boolean)


192
193
194
195
196
197
198
199
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 192

def equal?(kp)
  case kp
  when Ccrypto::ECCKeyBundle
    private_key.encoded == kp.private_key.encoded
  else
    false
  end
end

#is_public_key_equal?(pubKey) ⇒ Boolean

Returns:

  • (Boolean)


188
189
190
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 188

def is_public_key_equal?(pubKey)
  public_key.equals?(pubKey)
end

#key_paramObject

standardize external API



161
162
163
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 161

def key_param
  @config
end

#private_keyObject

standardize external API



174
175
176
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 174

def private_key
  ECCPrivateKey.new(@nativeKeypair.private)
end

#public_keyObject

standardize external API



166
167
168
169
170
171
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 166

def public_key
  if @pubKey.nil?
    @pubKey = ECCPublicKey.new(@nativeKeypair.public, @config.curve)
  end
  @pubKey
end

#write_keystore(type, &block) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/ccrypto/java/engines/ecc_engine.rb', line 201

def write_keystore(type, &block)
  ksType = Keystore.map_keystore_type(type)
  case ksType
  when :pkcs12
    Keystore::PKCS12Keystore.to_p12 do |key, *val|
      case key
      when :keypair
        @nativeKeypair
      else
        block.call(key) if block
      end
    end
  when :jks
    Keystore::JKSKeystore.to_jks do |key, *val|
      case key
      when :keypair
        @nativeKeypair
      else
        block.call(key) if block
      end
    end

  else
    raise Ccrypto::Keystore::KeystoreException, "Unsupported keystore type '#{type}' for engine '#{self.class.name}'"
  end
end