Class: Ccrypto::Java::X25519PublicKey
- Inherits:
-
X25519PublicKey
- Object
- X25519PublicKey
- Ccrypto::Java::X25519PublicKey
show all
- Includes:
- DataConversion
- Defined in:
- lib/ccrypto/java/engines/x25519_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
Class Method Details
.from_pem(str) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/ccrypto/java/engines/x25519_engine.rb', line 28
def self.from_pem(str)
if str =~ /X25519 PUBLIC/
cont = str.lines[1..-2].join.strip
to_key(from_b64(cont))
else
raise KeypairEngineException, "Not an X25519 public key"
end
end
|
.to_key(bin) ⇒ Object
16
17
18
19
|
# File 'lib/ccrypto/java/engines/x25519_engine.rb', line 16
def self.to_key(bin)
pubKey = java.security.KeyFactory.getInstance("X25519", "BC").generatePublic(java.security.spec.X509EncodedKeySpec.new(bin))
X25519PublicKey.new(pubKey)
end
|
Instance Method Details
#to_bin ⇒ Object
10
11
12
13
14
|
# File 'lib/ccrypto/java/engines/x25519_engine.rb', line 10
def to_bin
res = @native_pubKey.encoded
res
end
|
#to_pem ⇒ Object
21
22
23
24
25
26
|
# File 'lib/ccrypto/java/engines/x25519_engine.rb', line 21
def to_pem
cont = ["-----BEGIN X25519 PUBLIC KEY-----\n"]
cont << to_b64(to_bin)
cont << "\n-----END X25519 PUBLIC KEY-----"
cont.join
end
|