From c7cd7c91eb29a88114180f3fdc1c42ee57f16b66 Mon Sep 17 00:00:00 2001 From: Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com> Date: Sun, 22 May 2022 13:33:00 -0700 Subject: [PATCH] Config: Split :key in to [:secret_key, :public_key] --- spec/crypto_secret_spec.cr | 3 ++- src/crypto-secret/config.cr | 14 ++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/spec/crypto_secret_spec.cr b/spec/crypto_secret_spec.cr index 051b2ed..f43af39 100644 --- a/spec/crypto_secret_spec.cr +++ b/spec/crypto_secret_spec.cr @@ -4,10 +4,11 @@ require "../src/crypto-secret" test_secret_class Crypto::Secret::Not test_secret_class Crypto::Secret::Bidet +# test_secret_class Crypto::Secret::Guarded describe Crypto::Secret do it ".for" do - [:kgk, :key, :data, :not].each do |sym| + [:kgk, :secret_key, :public_key, :data, :not].each do |sym| secret = Crypto::Secret.for 2, sym secret.bytesize.should eq 2 end diff --git a/src/crypto-secret/config.cr b/src/crypto-secret/config.cr index 7fd2de3..692d937 100644 --- a/src/crypto-secret/config.cr +++ b/src/crypto-secret/config.cr @@ -18,20 +18,22 @@ module Crypto::Secret::Config # None end - def self.setup(level : SecurityLevel = SecurityLevel::Default) : Nil + def self.setup(level : SecurityLevel = :default) : Nil register_use Not, :not case level in SecurityLevel::Paranoid - register_use Bidet, :not - register_use CRYPTO_SECRET_KEY_CLASS, :kgk, :key, :data + register_use Bidet, :not, :public_key + register_use CRYPTO_SECRET_KEY_CLASS, :kgk, :secret_key, :data in SecurityLevel::Default + register_use Not, :public_key register_use Crypto::Secret::Bidet, :data - register_use CRYPTO_SECRET_KEY_CLASS, :kgk, :key + register_use CRYPTO_SECRET_KEY_CLASS, :kgk, :secret_key in SecurityLevel::Lax - register_use Bidet, :kgk, :key, :data + register_use Not, :public_key + register_use Bidet, :kgk, :secret_key, :data # in SecurityLevel::None - # register_use Not, :kgk, :key, :data + # register_use Not, :kgk, :secret_key, :data end end