Class: Ccrypto::Java::ED25519Engine
- Inherits:
-
Object
- Object
- Ccrypto::Java::ED25519Engine
show all
- Includes:
- DataConversion, TR::CondUtils, TeLogger::TeLogHelper
- 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_bin, #to_hex, #to_java_bytes, #to_str
Constructor Details
#initialize(*args, &block) ⇒ ED25519Engine
Returns a new instance of ED25519Engine.
141
142
143
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 141
def initialize(*args, &block)
@config = args.first
end
|
Class Method Details
.supported_params ⇒ Object
137
138
139
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 137
def self.supported_params
[]
end
|
.verify(pubKey, val, sign) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 180
def self.verify(pubKey, val, sign)
ver = java.security.Signature.getInstance("EdDSA", JCEProvider::BCProv.name)
case pubKey
when ED25519PublicKey
uPubKey = pubKey.native_pubKey
else
raise KeypairEngineException, "Unsupported public key type '#{pubKey.class}'"
end
ver.initVerify(uPubKey)
case val
when java.io.InputStream
buf = Java::byte[102400].new
while((read = val.read(buf, 0 ,buf.length)) != nil)
ver.update(buf,0, read)
end
else
ver.update(to_java_bytes(val))
end
ver.verify(to_java_bytes(sign))
end
|
Instance Method Details
#generate_keypair(&block) ⇒ Object
145
146
147
148
149
150
151
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 145
def generate_keypair(&block)
JCEProvider.instance.add_bc_provider
kg = java.security.KeyPairGenerator.getInstance("ED25519", JCEProvider::BCProv.name)
ED25519KeyBundle.new(kg.generateKeyPair)
end
|
#sign(val, &block) ⇒ Object
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/ccrypto/java/engines/ed25519_engine.rb', line 153
def sign(val, &block)
sign = java.security.Signature.getInstance("EdDSA", JCEProvider::BCProv.name)
case @config.keypair
when ED25519KeyBundle
privKey = @config.keypair.nativeKeypair.getPrivate
else
raise KeypairEngineException,"Unsupported keypair type '#{@config.keypair.class}'"
end
sign.initSign(privKey)
case val
when java.io.InputStream
buf = Java::byte[102400].new
while((read = val.read(buf, 0, buf.length)) != nil)
sign.update(buf,0,read)
end
else
sign.update(to_java_bytes(val))
end
sign.sign
end
|