Wipe bugfix for StaticArray.

Thanks (in no particular order shuffled randomly until alphabetical)
  @asterite @bcardiff @blacksmoke16
This commit is contained in:
Didactic Drunk 2019-06-30 14:03:08 -07:00
parent 731a3d7a4c
commit 7745e2f912
2 changed files with 17 additions and 16 deletions

View File

@ -17,17 +17,17 @@ module Sodium::Digest
include OpenSSL::DigestBase include OpenSSL::DigestBase
include Wipe include Wipe
KEY_SIZE = LibSodium.crypto_generichash_blake2b_keybytes KEY_SIZE = LibSodium.crypto_generichash_blake2b_keybytes # 32
KEY_SIZE_MIN = LibSodium.crypto_generichash_blake2b_keybytes_min KEY_SIZE_MIN = LibSodium.crypto_generichash_blake2b_keybytes_min # 16
KEY_SIZE_MAX = LibSodium.crypto_generichash_blake2b_keybytes_max KEY_SIZE_MAX = LibSodium.crypto_generichash_blake2b_keybytes_max # 64
SALT_SIZE = LibSodium.crypto_generichash_blake2b_saltbytes SALT_SIZE = LibSodium.crypto_generichash_blake2b_saltbytes # 16
PERSONAL_SIZE = LibSodium.crypto_generichash_blake2b_personalbytes PERSONAL_SIZE = LibSodium.crypto_generichash_blake2b_personalbytes # 16
OUT_SIZE = LibSodium.crypto_generichash_blake2b_bytes.to_i32 OUT_SIZE = LibSodium.crypto_generichash_blake2b_bytes.to_i32 # 32
OUT_SIZE_MIN = LibSodium.crypto_generichash_blake2b_bytes_min.to_i32 OUT_SIZE_MIN = LibSodium.crypto_generichash_blake2b_bytes_min.to_i32 # 16
OUT_SIZE_MAX = LibSodium.crypto_generichash_blake2b_bytes_max.to_i32 OUT_SIZE_MAX = LibSodium.crypto_generichash_blake2b_bytes_max.to_i32 # 64
getter digest_size getter digest_size

View File

@ -15,16 +15,17 @@ module Sodium::Wipe
{% for ivar in @type.instance_vars %} {% for ivar in @type.instance_vars %}
{% if ann = ivar.annotation(Wipe::Var) %} {% if ann = ivar.annotation(Wipe::Var) %}
if var = @{{ ivar.id }} {% if ivar.type <= StaticArray %}
case var Sodium.memzero @{{ivar.id}}.to_slice
when StaticArray {% else %}
#puts "wiping {{ivar}}" case var = @{{ ivar.id }}
# Sodium.memzero var.to_slice when Slice
# @{{ ivar.id }} = var Sodium.memzero var
when nil
else else
Sodium.memzero var.to_slice raise "unsupported wipe type for #{typeof(@{{ ivar.id }})} {{ ivar.id }}"
end end
end {% end %}
{% end %} {% end %}
{% end %} {% end %}
end end