Initial code

This commit is contained in:
Didactic Drunk 2021-06-12 16:04:49 -07:00
parent a94415dc55
commit eabf799e51
6 changed files with 66 additions and 1 deletions

View File

@ -4,6 +4,6 @@ version: 0.1.0
authors:
- Didactic Drunk <1479616+didactic-drunk@users.noreply.github.com>
crystal: 1.0.0
crystal: ">= 0.37"
license: MIT

View File

@ -0,0 +1,7 @@
require "./spec_helper"
describe Crypto::Secret do
pending "works" do
false.should eq(true)
end
end

10
spec/not_spec.cr Normal file
View File

@ -0,0 +1,10 @@
require "./spec_helper"
require "../src/crypto_secret/not"
describe Crypto::Secret::Not do
it "works" do
ksize = 32
secret = Crypto::Secret::Not.new ksize
secret.to_slice.should eq Bytes.new ksize
end
end

2
spec/spec_helper.cr Normal file
View File

@ -0,0 +1,2 @@
require "spec"
require "../src/crypto_secret"

30
src/crypto_secret.cr Normal file
View File

@ -0,0 +1,30 @@
# Interface to hold sensitive information (often cryptographic keys)
#
#
@[Experimental]
module Crypto::Secret
abstract def to_slice : Bytes
def readwrite
end
def readonly
end
def noaccess
end
def wipe
# Todo: implement wiping
end
def wipe
yield
ensure
wipe
end
def finalize
wipe
end
end

16
src/crypto_secret/not.cr Normal file
View File

@ -0,0 +1,16 @@
# A not very secret secret
#
# Not locked in memory
# Not access protected
# No guard pages
struct Crypto::Secret::Not
include Crypto::Secret
def initialize(size)
@bytes = Bytes.new size
end
def to_slice : Bytes
@bytes
end
end