Module: RbNaCl::Sodium
- Included in:
- Boxes::Curve25519XSalsa20Poly1305, Boxes::Curve25519XSalsa20Poly1305::PrivateKey, GroupElements::Curve25519, HMAC::SHA256, HMAC::SHA512256, Hash::Blake2b, Hash::SHA256, Hash::SHA512, OneTimeAuths::Poly1305, Random, RbNaCl::SecretBoxes::XSalsa20Poly1305, RbNaCl::Signatures::Ed25519, RbNaCl::Signatures::Ed25519::SigningKey, RbNaCl::Signatures::Ed25519::VerifyKey, Version, Util
- Defined in:
- lib/rbnacl/sodium.rb,
lib/rbnacl/sodium/version.rb
Overview
Provides helpers for defining the libsodium bindings
Defined Under Namespace
Modules: Version
Instance Method Summary collapse
- #primitive ⇒ Object
- #sodium_constant(constant, name = constant) ⇒ Object
- #sodium_function(name, function, arguments) ⇒ Object
- #sodium_primitive(primitive = nil) ⇒ Object
- #sodium_type(type = nil) ⇒ Object
Instance Method Details
#primitive ⇒ Object
23 24 25 |
# File 'lib/rbnacl/sodium.rb', line 23 def primitive sodium_primitive end |
#sodium_constant(constant, name = constant) ⇒ Object
27 28 29 30 31 |
# File 'lib/rbnacl/sodium.rb', line 27 def sodium_constant(constant, name=constant) fn = "crypto_#{sodium_type}_#{sodium_primitive}_#{constant.to_s.downcase}" attach_function fn, [], :ulong_long self.const_set(name, self.public_send(fn)) end |
#sodium_function(name, function, arguments) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/rbnacl/sodium.rb', line 33 def sodium_function(name, function, arguments) self.module_eval " attach_function \#{function.inspect}, \#{arguments.inspect}, :int\n def self.\#{name}(*args)\n ret = \#{function}(*args)\n ret == 0\n end\n eos\nend\n", __FILE__, __LINE__ + 1 |
#sodium_primitive(primitive = nil) ⇒ Object
18 19 20 21 |
# File 'lib/rbnacl/sodium.rb', line 18 def sodium_primitive(primitive = nil) return @primitive if primitive.nil? @primitive = primitive end |
#sodium_type(type = nil) ⇒ Object
13 14 15 16 |
# File 'lib/rbnacl/sodium.rb', line 13 def sodium_type(type = nil) return @type if type.nil? @type = type end |