diff --git a/shard.yml b/shard.yml index 0978cfc..fa7c972 100644 --- a/shard.yml +++ b/shard.yml @@ -4,7 +4,7 @@ version: 1.1.0 authors: - Andrew Hamon - Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> -crystal: 0.29.0 +crystal: 0.31.1 targets: pwhash_selector: main: examples/pwhash_selector.cr diff --git a/src/sodium/cipher/chalsa.cr b/src/sodium/cipher/chalsa.cr index 1c1cacd..eb46423 100644 --- a/src/sodium/cipher/chalsa.cr +++ b/src/sodium/cipher/chalsa.cr @@ -72,8 +72,8 @@ module Sodium::Cipher end abstract def update(src : Bytes, dst : Bytes) - abstract def key_size - abstract def nonce_size + abstract def key_size : Int32 + abstract def nonce_size : Int32 end {% for key, val in {"XSalsa20" => "xsalsa20", "Salsa20" => "salsa20", "XChaCha20" => "xchacha20", "ChaCha20Ietf" => "chacha20_ietf", "ChaCha20" => "chacha20"} %} diff --git a/src/sodium/crypto_box/public_key.cr b/src/sodium/crypto_box/public_key.cr index 0ce79a8..b93b7c8 100644 --- a/src/sodium/crypto_box/public_key.cr +++ b/src/sodium/crypto_box/public_key.cr @@ -7,7 +7,7 @@ class Sodium::CryptoBox SEAL_SIZE = LibSodium.crypto_box_sealbytes # Returns key - delegate to_slice, to: @bytes + delegate_to_slice to: @bytes # :nodoc: # Only used by SecretKey diff --git a/src/sodium/crypto_box/secret_key.cr b/src/sodium/crypto_box/secret_key.cr index ffbd753..c019ab5 100644 --- a/src/sodium/crypto_box/secret_key.cr +++ b/src/sodium/crypto_box/secret_key.cr @@ -42,7 +42,7 @@ class Sodium::CryptoBox getter public_key : PublicKey # Returns key - delegate to_slice, to: @sbuf + delegate_to_slice to: @sbuf @seed : SecureBuffer? diff --git a/src/sodium/kdf.cr b/src/sodium/kdf.cr index 806952d..c2112f4 100644 --- a/src/sodium/kdf.cr +++ b/src/sodium/kdf.cr @@ -23,7 +23,7 @@ module Sodium CONTEXT_SIZE = LibSodium.crypto_kdf_contextbytes # Returns key - delegate to_slice, to: @sbuf + delegate_to_slice to: @sbuf # Use an existing KDF key. # diff --git a/src/sodium/lib_sodium.cr b/src/sodium/lib_sodium.cr index b79ee2d..8e6e954 100644 --- a/src/sodium/lib_sodium.cr +++ b/src/sodium/lib_sodium.cr @@ -1,6 +1,12 @@ require "random/secure" require "./error" +macro delegate_to_slice(to object) + def to_slice() : Bytes + {{object.id}}.to_slice + end +end + module Sodium @[Link(ldflags: "`#{__DIR__}/../../build/pkg-libs.sh #{__DIR__}/../..`")] lib LibSodium diff --git a/src/sodium/nonce.cr b/src/sodium/nonce.cr index 9c045f0..4484ef1 100644 --- a/src/sodium/nonce.cr +++ b/src/sodium/nonce.cr @@ -16,7 +16,7 @@ module Sodium property? reusable = false # Returns bytes - delegate to_slice, to: @bytes + delegate_to_slice to: @bytes delegate bytesize, to: @bytes diff --git a/src/sodium/secret_box.cr b/src/sodium/secret_box.cr index c179e06..d22e37e 100644 --- a/src/sodium/secret_box.cr +++ b/src/sodium/secret_box.cr @@ -20,7 +20,7 @@ module Sodium MAC_SIZE = LibSodium.crypto_secretbox_macbytes.to_i # Returns key - delegate to_slice, to: @key + delegate_to_slice to: @key # Encryption key getter key : SecureBuffer diff --git a/src/sodium/sign/public_key.cr b/src/sodium/sign/public_key.cr index f4eaedd..e89d584 100644 --- a/src/sodium/sign/public_key.cr +++ b/src/sodium/sign/public_key.cr @@ -6,7 +6,7 @@ module Sodium SIG_SIZE = LibSodium.crypto_sign_bytes.to_i # Returns key - delegate to_slice, to: @bytes + delegate_to_slice to: @bytes # :nodoc: # Only used by SecretKey diff --git a/src/sodium/sign/secret_key.cr b/src/sodium/sign/secret_key.cr index 8114d1e..86bb807 100644 --- a/src/sodium/sign/secret_key.cr +++ b/src/sodium/sign/secret_key.cr @@ -21,7 +21,7 @@ module Sodium getter public_key : PublicKey # Returns key - delegate to_slice, to: @sbuf + delegate_to_slice to: @sbuf @seed : SecureBuffer?