Class: Themis::SKeyPairGen
- Inherits:
-
Object
- Object
- Themis::SKeyPairGen
- Includes:
- ThemisCommon, ThemisImport
- Defined in:
- lib/rubythemis.rb
Instance Method Summary collapse
Methods included from ThemisCommon
Instance Method Details
#ec ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rubythemis.rb', line 111 def ec() private_key_length=FFI::MemoryPointer.new(:uint) public_key_length= FFI::MemoryPointer.new(:uint) res=themis_gen_ec_key_pair(nil, private_key_length, nil, public_key_length) raise ThemisError, "themis_gen_ec_key_pair (length determination) error: #{res}" unless res == BUFFER_TOO_SMALL private_key = FFI::MemoryPointer.new(:char, private_key_length.read_uint) public_key = FFI::MemoryPointer.new(:char, public_key_length.read_uint) res=themis_gen_ec_key_pair(private_key, private_key_length, public_key, public_key_length) raise ThemisError, "themis_gen_ec_key_pair error: #{res}" unless res == SUCCESS return private_key.get_bytes(0, private_key_length.read_uint), public_key.get_bytes(0, public_key_length.read_uint) end |
#rsa ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/rubythemis.rb', line 123 def rsa() private_key_length=FFI::MemoryPointer.new(:uint) public_key_length= FFI::MemoryPointer.new(:uint) res=themis_gen_rsa_key_pair(nil, private_key_length, nil, public_key_length) raise ThemisError, "themis_gen_ec_key_pair (length determination) error: #{res}" unless res == BUFFER_TOO_SMALL private_key = FFI::MemoryPointer.new(:char, private_key_length.read_uint) public_key = FFI::MemoryPointer.new(:char, public_key_length.read_uint) res=themis_gen_rsa_key_pair(private_key, private_key_length, public_key, public_key_length) raise ThemisError, "themis_gen_ec_key_pair error: #{res}" unless res == SUCCESS return private_key.get_bytes(0, private_key_length.read_uint), public_key.get_bytes(0, public_key_length.read_uint) end |