Class: Themis::Smessage
- Inherits:
-
Object
- Object
- Themis::Smessage
- Includes:
- ThemisCommon, ThemisImport
- Defined in:
- lib/rubythemis.rb
Instance Method Summary collapse
-
#initialize(private_key, peer_public_key) ⇒ Smessage
constructor
A new instance of Smessage.
- #unwrap(message) ⇒ Object
- #wrap(message) ⇒ Object
Methods included from ThemisCommon
Constructor Details
#initialize(private_key, peer_public_key) ⇒ Smessage
Returns a new instance of Smessage.
212 213 214 215 |
# File 'lib/rubythemis.rb', line 212 def initialize(private_key, peer_public_key) @private_key, @private_key_length = string_to_pointer_size(private_key) @peer_public_key, @peer_public_key_length = string_to_pointer_size(peer_public_key) end |
Instance Method Details
#unwrap(message) ⇒ Object
228 229 230 231 232 233 234 235 236 237 |
# File 'lib/rubythemis.rb', line 228 def unwrap() , =string_to_pointer_size() = FFI::MemoryPointer.new(:uint) res=(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, , , nil, ) raise ThemisError, "themis_secure_message_unwrap (length determination) error: #{res}" unless res == BUFFER_TOO_SMALL = FFI::MemoryPointer.new(:char, .read_uint) res=(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, , , , ) raise ThemisError, "themis_secure_message_unwrap error: #{res}" unless res == SUCCESS return .get_bytes(0, .read_uint); end |
#wrap(message) ⇒ Object
217 218 219 220 221 222 223 224 225 226 |
# File 'lib/rubythemis.rb', line 217 def wrap() , =string_to_pointer_size() = FFI::MemoryPointer.new(:uint) res=(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, , , nil, ) raise ThemisError, "themis_secure_message_wrap (length determination) error: #{res}" unless res == BUFFER_TOO_SMALL = FFI::MemoryPointer.new(:char, .read_uint) res=(@private_key, @private_key_length, @peer_public_key, @peer_public_key_length, , , , ) raise ThemisError, "themis_secure_message_wrap error: #{res}" unless res == SUCCESS return .get_bytes(0, .read_uint); end |