From 70a1dfe2c4400e45d4bdf55684aebd5f30fcb672 Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Wed, 16 Jun 2021 15:16:51 -0700 Subject: [PATCH] readwrite/readonly/noaccess return self --- src/crypto-secret/stateful.cr | 6 +++--- src/crypto-secret/stateless.cr | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/crypto-secret/stateful.cr b/src/crypto-secret/stateful.cr index 036a724..c552645 100644 --- a/src/crypto-secret/stateful.cr +++ b/src/crypto-secret/stateful.cr @@ -30,7 +30,7 @@ module Crypto::Secret # Marks a region allocated as readable and writable # WARNING: Not thread safe - def readwrite + def readwrite : self raise Error::KeyWiped.new if @state == State::Wiped readwrite_impl @state = State::Readwrite @@ -49,7 +49,7 @@ module Crypto::Secret # Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only. # WARNING: Not thread safe - def readonly + def readonly : self raise Error::KeyWiped.new if @state == State::Wiped readonly_impl @state = State::Readonly @@ -58,7 +58,7 @@ module Crypto::Secret # Makes a region inaccessible. It cannot be read or written, but the data are preserved. # WARNING: Not thread safe - def noaccess + def noaccess : self raise Error::KeyWiped.new if @state == State::Wiped noaccess_impl @state = State::Noaccess diff --git a/src/crypto-secret/stateless.cr b/src/crypto-secret/stateless.cr index fdbae57..b71b8ac 100644 --- a/src/crypto-secret/stateless.cr +++ b/src/crypto-secret/stateless.cr @@ -11,7 +11,8 @@ module Crypto::Secret::Stateless end # Not thread safe - def readwrite + def readwrite : self + self end # Yields a Slice that is readable and writable @@ -26,7 +27,8 @@ module Crypto::Secret::Stateless end # Not thread safe - def readonly + def readonly : self + self end # Yields a Slice that is readable possibly writable depending on the prior protection level and underlying implementation @@ -40,7 +42,8 @@ module Crypto::Secret::Stateless end # Not thread safe - def noaccess + def noaccess : self + self end # Not thread safe