class Themis::SKeyPairGen

Public Instance Methods

ec() click to toggle source
# File lib/rubythemis.rb, line 113
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 failed generating EC KeyPair: #{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 failed generating EC KeyPair: #{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() click to toggle source
# File lib/rubythemis.rb, line 125
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 failed generating RSA KeyPair: #{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 failed generating RSA KeyPair: #{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