2019-05-25 17:40:28 -07:00
|
|
|
require "random/secure"
|
|
|
|
|
|
|
|
|
|
module Cox
|
|
|
|
|
class Error < ::Exception
|
2019-06-28 03:30:33 -07:00
|
|
|
class VerificationFailed < Error
|
|
|
|
|
end
|
2019-06-27 17:20:02 -07:00
|
|
|
|
2019-06-28 03:30:33 -07:00
|
|
|
class DecryptionFailed < Error
|
|
|
|
|
end
|
2019-05-25 17:40:28 -07:00
|
|
|
end
|
2017-07-11 22:13:52 -05:00
|
|
|
|
2019-06-28 05:20:56 -07:00
|
|
|
def self.memzero(bytes : Bytes)
|
|
|
|
|
LibSodium.sodium_memzero bytes, bytes.bytesize
|
2017-07-11 22:13:52 -05:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2019-06-28 05:20:56 -07:00
|
|
|
require "./cox/**"
|
|
|
|
|
|
2019-06-27 17:20:02 -07:00
|
|
|
if Cox::LibSodium.sodium_init == -1
|
2019-06-27 17:35:31 -07:00
|
|
|
abort "Failed to init libsodium"
|
2017-07-11 22:13:52 -05:00
|
|
|
end
|