From b90d9bf117ecf687f84c5c9600e961c2bbc9ba98 Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Sat, 26 Jun 2021 17:27:16 -0700 Subject: [PATCH] Sodium::Cipher::Aead::XChaCha20Poly1305IetfL: Add #nonce_size --- src/sodium/cipher/aead/chalsa.cr | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/sodium/cipher/aead/chalsa.cr b/src/sodium/cipher/aead/chalsa.cr index 92bd1bf..f9d20ff 100644 --- a/src/sodium/cipher/aead/chalsa.cr +++ b/src/sodium/cipher/aead/chalsa.cr @@ -78,8 +78,9 @@ module Sodium::Cipher::Aead abstract def encrypt_detached(src : Bytes, dst : Bytes? = nil, *, nonce : Sodium::Nonce? = nil, mac : Bytes? = nil, additional : String | Bytes | Nil = nil) : {Bytes, Bytes, Sodium::Nonce} abstract def decrypt_detached(src : Bytes, dst : Bytes? = nil, *, nonce : Sodium::Nonce, mac : Bytes, additional : String | Bytes | Nil = nil) : Bytes - protected abstract def key_size : Int32 - protected abstract def mac_size : Int32 + abstract def key_size : Int32 + abstract def mac_size : Int32 + abstract def nonce_size : Int32 def dup self.class.new @key.dup @@ -143,13 +144,17 @@ module Sodium::Cipher::Aead dst end - protected def key_size : Int32 + def key_size : Int32 KEY_SIZE end - protected def mac_size : Int32 + def mac_size : Int32 MAC_SIZE end + + def nonce_size : Int32 + NONCE_SIZE + end end {% end %} end