Class: Ccrypto::Java::ED25519PrivateKey
- Inherits:
-
ED25519PrivateKey
- Object
- ED25519PrivateKey
- Ccrypto::Java::ED25519PrivateKey
show all
- Includes:
- DataConversion
- Defined in:
- lib/ccrypto/java/engines/ed25519_engine.rb
Overview
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
60
61
62
63
64
65
66
67
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 60
def self.from_pem(str)
if str =~ /ED25519 PRIVATE/
cont = str.lines[1..-2].join.strip
to_key(from_b64(cont))
else
raise KeypairEngineException, "Not an ED25519 private key"
end
end
|
.to_key(bin, &block) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 40
def self.to_key(bin, &block)
if block
prov = block.call(:jce_provider)
else
prov = JCEProvider::BCProv
end
kf = java.security.KeyFactory.getInstance("ED25519",prov)
priv = kf.generate_private(java.security.spec.PKCS8EncodedKeySpec.new(bin))
ED25519PrivateKey.new(priv)
end
|
Instance Method Details
#equals?(privKey) ⇒ Boolean
Also known as:
key_equals?
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 73
def equals?(privKey)
if not @native_privKey.nil?
case privKey
when ED25519PrivateKey
@native_privKey.encoded == privKey.to_bin
else
logger.warn "Unmatched private key : (native) #{@native_privKey} vs. (subject) #{privKey}"
false
end
else
logger.warn "ED25519PrivateKey equals? returned false because native_privKey is nil"
false
end
end
|
#to_bin ⇒ Object
69
70
71
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 69
def to_bin
@native_privKey.encoded
end
|
#to_pem ⇒ Object
53
54
55
56
57
58
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 53
def to_pem
cont = ["-----BEGIN ED25519 PRIVATE KEY-----\n"]
cont << to_b64(@native_privKey.encoded)
cont << "\n-----END ED25519 PRIVATE KEY-----"
cont.join
end
|