From 1bb746c888347ac8f226b975c8e811baa6f3cbea Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Tue, 23 Mar 2021 15:52:15 -0700 Subject: [PATCH] Add KDF.xchacha20poly1305_ietf --- src/sodium/kdf.cr | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sodium/kdf.cr b/src/sodium/kdf.cr index c2112f4..9b71e45 100644 --- a/src/sodium/kdf.cr +++ b/src/sodium/kdf.cr @@ -91,6 +91,14 @@ module Sodium Sign::SecretKey.new seed: subkey end + # Convenience method to create a new CryptoBox::Aead::XChaCha20Poly1305Ietf without handling the key. + # + # See derive() for further information on context and subkey_id. + def derive_aead_xchacha20poly1305_ietf(context, subkey_id) : Cipher::Aead::XChaCha20Poly1305Ietf + subkey = derive context, subkey_id, Cipher::Aead::XChaCha20Poly1305Ietf::KEY_SIZE + Cipher::Aead::XChaCha20Poly1305Ietf.new subkey + end + # Convenience method to create a new SecretBox without handling the key. # # See derive() for further information on context and subkey_id.