Class: Ccrypto::Java::RSAPublicKey
- Inherits:
-
RSAPublicKey
- Object
- RSAPublicKey
- Ccrypto::Java::RSAPublicKey
show all
- Includes:
- DataConversion
- Defined in:
- lib/ccrypto/java/engines/rsa_engine.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#from_b64, #from_b64_mime, #from_hex, included, #logger, #to_b64, #to_b64_mime, #to_hex, #to_java_bytes, #to_str
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(mtd, *args, &block) ⇒ Object
35
36
37
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 35
def method_missing(mtd, *args, &block)
@native_pubKey.send(mtd, *args, &block)
end
|
Class Method Details
.from_pem(str) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 26
def self.from_pem(str)
if str =~ /RSA PUBLIC/
cont = str.lines[1..-2].join.strip
to_key(from_b64(cont))
else
raise KeypairEngineException, "Not an RSA public key"
end
end
|
.to_key(bin) ⇒ Object
14
15
16
17
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 14
def self.to_key(bin)
pubKey = java.security.KeyFactory.getInstance("RSA", "BC").generatePublic(java.security.spec.X509EncodedKeySpec.new(bin))
RSAPublicKey.new(pubKey)
end
|
Instance Method Details
#to_bin ⇒ Object
10
11
12
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 10
def to_bin
@native_pubKey.encoded
end
|
#to_pem ⇒ Object
19
20
21
22
23
24
|
# File 'lib/ccrypto/java/engines/rsa_engine.rb', line 19
def to_pem
cont = ["-----BEGIN RSA PUBLIC KEY-----\n"]
cont << to_b64(to_bin)
cont << "\n-----END RSA PUBLIC KEY-----"
cont.join
end
|