Class: Ccrypto::Java::RSAKeyBundle
- Inherits:
-
Object
- Object
- Ccrypto::Java::RSAKeyBundle
show all
- Includes:
- PKCS12, RSAKeyBundle, TR::CondUtils, TeLogger::TeLogHelper
- Defined in:
- lib/ccrypto/java/engines/rsa_engine.rb
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from PKCS12
included, #to_pkcs12
#from_b64, #from_hex, included, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str
Constructor Details
Returns a new instance of RSAKeyBundle.
37
38
39
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 37
def initialize(kp)
@nativeKeypair = kp
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mtd, *args, &block) ⇒ Object
109
110
111
112
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 109
def method_missing(mtd, *args, &block)
teLogger.debug "Sending to native #{mtd}"
@nativeKeypair.send(mtd, *args, &block)
end
|
Class Method Details
.from_storage(bin, &block) ⇒ Object
83
84
85
86
87
88
89
90
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 83
def self.from_storage(bin, &block)
if is_pem?(bin)
else
from_pkcs12(bin, &block)
end
end
|
.is_pem?(bin) ⇒ Boolean
92
93
94
95
96
97
98
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 92
def self.is_pem?(bin)
begin
(bin =~ /BEGIN/) != nil
rescue ArgumentError => ex
false
end
end
|
Instance Method Details
#equal?(kp) ⇒ Boolean
100
101
102
103
104
105
106
107
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 100
def equal?(kp)
case kp
when Ccrypto::RSAKeyBundle
@nativeKeypair.encoded == kp.private.encoded
else
false
end
end
|
#private_key ⇒ Object
48
49
50
51
52
53
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 48
def private_key
if @privKey.nil?
@privKey = RSAPrivateKey.new(@nativeKeypair.private)
end
@privKey
end
|
#public_key ⇒ Object
41
42
43
44
45
46
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 41
def public_key
if @pubKey.nil?
@pubKey = RSAPublicKey.new(@nativeKeypair.public)
end
@pubKey
end
|
#respond_to_missing?(mtd, incPriv = false) ⇒ Boolean
114
115
116
117
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 114
def respond_to_missing?(mtd, incPriv = false)
teLogger.debug "Respond to missing #{mtd}"
@nativeKeypair.respond_to?(mtd)
end
|
#to_storage(type, &block) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 55
def to_storage(type, &block)
case type
when :p12, :pkcs12
to_pkcs12 do |key|
case key
when :keypair
@nativeKeypair
else
block.call(key) if block
end
end
when :jks
to_pkcs12 do |key|
case key
when :storeType
"JKS"
when :keypair
@nativeKeypair
else
block.call(key) if block
end
end
end
end
|