For @blacksmoke16

This commit is contained in:
Didactic Drunk 2022-05-09 20:14:53 -07:00 committed by didactic-drunk
parent f20357ca44
commit 7e91cac498
2 changed files with 23 additions and 15 deletions

View File

@ -7,10 +7,10 @@ module Crypto::Secret
# * Not access protected # * Not access protected
# * No guard pages # * No guard pages
# * Hours of fun # * Hours of fun
class Bidet class Bidet < Base
include Stateless include Stateless
def self.new(size) def self.new(size : Int32)
new references: Bytes.new(size) new references: Bytes.new(size)
end end

View File

@ -1,13 +1,6 @@
require "./lib" require "./lib"
require "./class_methods" require "./class_methods"
macro finished
{% for key, klass in Crypto::Secret::REGISTERED_USES %}
require {{ Crypto::Secret::REGISTERED_LOAD_PATHS[klass] }}
Crypto::Secret::REGISTERED[{{key.id}}] = {{klass}}
{% end %}
end
# Interface to hold sensitive information (often cryptographic keys) # Interface to hold sensitive information (often cryptographic keys)
# #
# ## Which class should I use? # ## Which class should I use?
@ -40,9 +33,14 @@ module Crypto::Secret
extend ClassMethods extend ClassMethods
REGISTERED = Hash(Symbol, Secret).new abstract class Base
REGISTERED_USES = {} of Nil => Nil end
REGISTERED_LOAD_PATHS = {} of Nil => Nil
REGISTERED = Hash(Symbol, Secret::Base.class).new
# REGISTERED_USES = {} of Nil => Nil
REGISTERED_USES = {} of Symbol => String
# REGISTERED_LOAD_PATHS = {} of Nil => Nil
REGISTERED_LOAD_PATHS = {} of String => String
macro register(klass, *args) macro register(klass, *args)
p "{{ args.id}}" p "{{ args.id}}"
@ -57,14 +55,14 @@ p "{{ args.id}}"
end end
register_class "Crypto::Secret::Bidet", "./bidet", :ksk, :key, :data register_class "Crypto::Secret::Bidet", "./bidet", :ksk, :key, :data
register_class "Crypto::Secret::Not", "./not" # register_class "Crypto::Secret::Not", "./not"
register "Crypto::Secret::Bidet", :ksk, :key, :data register "Crypto::Secret::Bidet", :ksk, :key, :data
def self.for(use) : Crypto::Secret def self.for(use : Symbol) : Crypto::Secret::Base.class
REGISTERED[use] REGISTERED[use]
end end
def self.for(use, size) def self.for(use : Symbol, size : Int32)
for(use).new(size) for(use).new(size)
end end
@ -199,3 +197,13 @@ p "{{ args.id}}"
slice.wipe slice.wipe
end end
end end
macro finished
{% for key, klass in Crypto::Secret::REGISTERED_USES %}
#puts "{{key}}={{klass}}"
puts "key=klass"
require {{ Crypto::Secret::REGISTERED_LOAD_PATHS[klass] }}
Crypto::Secret::REGISTERED[:{{key.id}}] = {{klass.id}}
{% end %}
end