2015-04-25 04:39:40 +08:00
|
|
|
|
|
|
|
#include <openssl/crypto.h>
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
#if defined(OPENSSL_SYS_LINUX) || defined(OPENSSL_SYS_UNIX)
|
|
|
|
char *p = NULL, *q = NULL;
|
|
|
|
|
|
|
|
if (!CRYPTO_secure_malloc_init(4096, 32)) {
|
|
|
|
perror("failed");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
p = OPENSSL_secure_malloc(20);
|
|
|
|
if (!CRYPTO_secure_allocated(p)) {
|
|
|
|
perror("failed 1");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
q = OPENSSL_malloc(20);
|
|
|
|
if (CRYPTO_secure_allocated(q)) {
|
|
|
|
perror("failed 1");
|
|
|
|
return 1;
|
|
|
|
}
|
2016-02-17 18:03:55 +08:00
|
|
|
OPENSSL_secure_free(p);
|
|
|
|
OPENSSL_free(q);
|
2015-04-25 04:39:40 +08:00
|
|
|
CRYPTO_secure_malloc_done();
|
|
|
|
#else
|
|
|
|
/* Should fail. */
|
|
|
|
if (CRYPTO_secure_malloc_init(4096, 32)) {
|
|
|
|
perror("failed");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|