summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-10-19 13:26:12 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-10-20 13:50:00 +0200
commitb893e3a63f899e276ebb5c88c9458ebed2eb08a0 (patch)
treea16c868644174a3b8668ef23329c9a2432ff4e22 /sal
parent281e5f982008741bb6f7f03c578e47e342f4543e (diff)
use rtl_secureZeroMemory when we're zeroing temporaries before returning
Change-Id: I0c3efa394511e479d925f5320977d071e8301f8d Reviewed-on: https://gerrit.libreoffice.org/62002 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/cipher.cxx13
-rw-r--r--sal/rtl/digest.cxx16
2 files changed, 16 insertions, 13 deletions
diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx
index df0631b928d7..70a26cd3fe62 100644
--- a/sal/rtl/cipher.cxx
+++ b/sal/rtl/cipher.cxx
@@ -659,8 +659,8 @@ static rtlCipherError BF_init(
key->m_P[i] ^= D;
}
- DL = 0;
- DR = 0;
+ rtl_secureZeroMemory(&DL, sizeof(DL));
+ rtl_secureZeroMemory(&DR, sizeof(DR));
for (i = 0; i < CIPHER_ROUNDS_BF + 2; i += 2)
{
@@ -808,7 +808,8 @@ static void BF_updateECB(
RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength);
}
- DL = DR = 0;
+ rtl_secureZeroMemory(&DL, sizeof(DL));
+ rtl_secureZeroMemory(&DR, sizeof(DR));
}
static void BF_updateCBC(
@@ -857,7 +858,8 @@ static void BF_updateCBC(
RTL_CIPHER_HTONL64(DL, DR, pBuffer, nLength);
}
- DL = DR = 0;
+ rtl_secureZeroMemory(&DL, sizeof(DL));
+ rtl_secureZeroMemory(&DR, sizeof(DR));
}
static void BF_updateCFB(
@@ -880,7 +882,8 @@ static void BF_updateCFB(
BF_encode(&(ctx->m_key), &IVL, &IVR);
RTL_CIPHER_HTONL64(IVL, IVR, iv, 8);
- IVL = IVR = 0;
+ rtl_secureZeroMemory(&IVL, sizeof(IVL));
+ rtl_secureZeroMemory(&IVR, sizeof(IVR));
}
if (direction == rtl_Cipher_DirectionEncode)
diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx
index 3bd2dfa214dd..706d1ffc5c67 100644
--- a/sal/rtl/digest.cxx
+++ b/sal/rtl/digest.cxx
@@ -283,7 +283,7 @@ static void updateMD2(DigestContextMD2 *ctx)
}
memcpy(sp1, state, 16 * sizeof(sal_uInt32));
- memset(state, 0, 48 * sizeof(sal_uInt32));
+ rtl_secureZeroMemory(state, 48 * sizeof(sal_uInt32));
}
static void endMD2(DigestContextMD2 *ctx)
@@ -320,7 +320,7 @@ rtlDigestError SAL_CALL rtl_digest_MD2(
if (result == rtl_Digest_E_None)
result = rtl_digest_getMD2(&digest, pBuffer, nBufLen);
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -658,7 +658,7 @@ rtlDigestError SAL_CALL rtl_digest_MD5(
if (result == rtl_Digest_E_None)
result = rtl_digest_getMD5(&digest, pBuffer, nBufLen);
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -1101,7 +1101,7 @@ rtlDigestError SAL_CALL rtl_digest_SHA(
if (result == rtl_Digest_E_None)
result = rtl_digest_getSHA(&digest, pBuffer, nBufLen);
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -1261,7 +1261,7 @@ rtlDigestError SAL_CALL rtl_digest_SHA1(
if (result == rtl_Digest_E_None)
result = rtl_digest_getSHA1(&digest, pBuffer, nBufLen);
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -1476,7 +1476,7 @@ rtlDigestError SAL_CALL rtl_digest_HMAC_MD5(
result = rtl_digest_getHMAC_MD5(&digest, pBuffer, nBufLen);
}
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -1672,7 +1672,7 @@ rtlDigestError SAL_CALL rtl_digest_HMAC_SHA1(
result = rtl_digest_getHMAC_SHA1(&digest, pBuffer, nBufLen);
}
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return result;
}
@@ -1872,7 +1872,7 @@ rtlDigestError SAL_CALL rtl_digest_PBKDF2(
rtl_secureZeroMemory(T, DIGEST_CBLOCK_PBKDF2);
}
- memset(&digest, 0, sizeof(digest));
+ rtl_secureZeroMemory(&digest, sizeof(digest));
return rtl_Digest_E_None;
}