Initial code
This commit is contained in:
parent
a94415dc55
commit
eabf799e51
@ -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
|
||||
|
7
spec/crypto_secret_spec.cr
Normal file
7
spec/crypto_secret_spec.cr
Normal 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
10
spec/not_spec.cr
Normal 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
2
spec/spec_helper.cr
Normal file
@ -0,0 +1,2 @@
|
||||
require "spec"
|
||||
require "../src/crypto_secret"
|
30
src/crypto_secret.cr
Normal file
30
src/crypto_secret.cr
Normal 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
16
src/crypto_secret/not.cr
Normal 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
|
Loading…
Reference in New Issue
Block a user