Config: Split :key in to [:secret_key, :public_key]

This commit is contained in:
Didactic Drunk 2022-05-22 13:33:00 -07:00
parent 9de2acf26a
commit c7cd7c91eb
2 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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