diff --git a/Crypto/Internal/ByteArray.hs b/Crypto/Internal/ByteArray.hs index 612833c..63c458a 100644 --- a/Crypto/Internal/ByteArray.hs +++ b/Crypto/Internal/ByteArray.hs @@ -16,6 +16,7 @@ module Crypto.Internal.ByteArray , byteArrayAlloc , byteArrayAllocAndFreeze , empty + , byteArrayZero , byteArrayCopy , byteArrayCopyRet , byteArrayCopyAndFreeze @@ -39,7 +40,7 @@ import Data.SecureMem import Crypto.Internal.Memory import Crypto.Internal.Compat import Crypto.Internal.Endian -import Crypto.Internal.Bytes (bufXor, bufCopy) +import Crypto.Internal.Bytes (bufXor, bufCopy, bufSet) import Crypto.Internal.Words import Foreign.Ptr import Foreign.Storable @@ -147,6 +148,9 @@ byteArrayCopyAndFreeze bs f = withByteArray bs $ \s -> bufCopy d s (byteArrayLength bs) f (castPtr d) +byteArrayZero :: ByteArray ba => Int -> ba +byteArrayZero n = byteArrayAllocAndFreeze n $ \ptr -> bufSet ptr 0 n + byteArrayEq :: (ByteArrayAccess bs1, ByteArrayAccess bs2) => bs1 -> bs2 -> Bool byteArrayEq b1 b2 | l1 /= l2 = False