Class: Themis::Scomparator
- Inherits:
-
Object
- Object
- Themis::Scomparator
- Includes:
- ThemisCommon, ThemisImport
- Defined in:
- lib/rbthemis.rb
Constant Summary collapse
- MATCH =
21
- NOT_MATCH =
22
- NOT_READY =
0
Constants included from ThemisImport
ThemisImport::THEMIS_KEY_EC_PRIVATE, ThemisImport::THEMIS_KEY_EC_PUBLIC, ThemisImport::THEMIS_KEY_INVALID, ThemisImport::THEMIS_KEY_RSA_PRIVATE, ThemisImport::THEMIS_KEY_RSA_PUBLIC
Instance Method Summary collapse
- #begin_compare ⇒ Object
- #finalize ⇒ Object
-
#initialize(shared_secret) ⇒ Scomparator
constructor
A new instance of Scomparator.
- #proceed_compare(control_message) ⇒ Object
- #result ⇒ Object
Methods included from ThemisImport
canonical_themis_paths, load_themis
Methods included from ThemisCommon
empty?, string_to_pointer_size
Constructor Details
#initialize(shared_secret) ⇒ Scomparator
Returns a new instance of Scomparator.
967 968 969 970 971 972 973 974 975 976 977 |
# File 'lib/rbthemis.rb', line 967 def initialize(shared_secret) shared_secret_buf, shared_secret_length = string_to_pointer_size(shared_secret) @comparator = secure_comparator_create raise ThemisError, 'Secure Comparator failed creating' if @comparator.null? res = secure_comparator_append_secret( @comparator, shared_secret_buf, shared_secret_length) if res != SUCCESS raise ThemisError, 'Secure Comparator failed appending secret' end end |
Instance Method Details
#begin_compare ⇒ Object
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 |
# File 'lib/rbthemis.rb', line 986 def begin_compare res_length = FFI::MemoryPointer.new(:uint) res = secure_comparator_begin_compare(@comparator, nil, res_length) if res != BUFFER_TOO_SMALL raise(ThemisError, 'Secure Comparator failed making initialisation message') end res_buffer = FFI::MemoryPointer.new(:char, res_length.read_uint) res = secure_comparator_begin_compare(@comparator, res_buffer, res_length) if res != SUCCESS && res != SEND_AS_IS raise(ThemisError, 'Secure Comparator failed making initialisation message') end res_buffer.get_bytes(0, res_length.read_uint) end |
#finalize ⇒ Object
979 980 981 982 983 984 |
# File 'lib/rbthemis.rb', line 979 def finalize res = secure_comparator_destroy(@comparator) if res != SUCCESS raise ThemisError, 'Secure Comparator failed destroying' end end |
#proceed_compare(control_message) ⇒ Object
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
# File 'lib/rbthemis.rb', line 1004 def proceed_compare() , = string_to_pointer_size() res_length = FFI::MemoryPointer.new(:uint) res = secure_comparator_proceed_compare( @comparator, , , nil, res_length) return '' if res == SUCCESS if res != BUFFER_TOO_SMALL raise ThemisError, 'Secure Comparator failed proceeding message' end res_buffer = FFI::MemoryPointer.new(:char, res_length.read_uint) res = secure_comparator_proceed_compare( @comparator, , , res_buffer, res_length) if res != SUCCESS && res != SEND_AS_IS raise ThemisError, 'Secure Comparator failed proceeding message' end res_buffer.get_bytes(0, res_length.read_uint) end |
#result ⇒ Object
1025 1026 1027 |
# File 'lib/rbthemis.rb', line 1025 def result secure_comparator_get_result(@comparator) end |