1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

shielding requires memory protection

This commit is contained in:
Frank Denis 2019-07-09 20:29:36 +02:00
parent a73f8f15e4
commit e97760ad68

View File

@ -52,10 +52,18 @@ main(void)
}
randombytes_buf(buf, size);
memcpy(buf2, buf, size);
sodium_mshield(buf);
assert(size == 0U || memcmp(buf, buf2, size) != 0);
sodium_munshield(buf);
assert(size == 0U || memcmp(buf, buf2, size) == 0);
errno = EINVAL;
if (sodium_mshield(buf) != 0) {
assert(errno == ENOSYS);
} else {
assert(size == 0U || memcmp(buf, buf2, size) != 0);
}
errno = EINVAL;
if (sodium_munshield(buf) != 0) {
assert(errno == ENOSYS);
} else {
assert(size == 0U || memcmp(buf, buf2, size) == 0);
}
sodium_free(buf2);
sodium_free(buf);