{"action":"created","issue":{"url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/48","repository_url":"https://api.github.com/repos/open-quantum-safe/liboqs","labels_url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/48/comments","events_url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/48/events","html_url":"https://github.com/open-quantum-safe/liboqs/issues/48","id":187175328,"number":48,"title":"Zeroing Memory","user":{"login":"aparent","id":359114,"avatar_url":"https://avatars.githubusercontent.com/u/359114?v=3","gravatar_id":"","url":"https://api.github.com/users/aparent","html_url":"https://github.com/aparent","followers_url":"https://api.github.com/users/aparent/followers","following_url":"https://api.github.com/users/aparent/following{/other_user}","gists_url":"https://api.github.com/users/aparent/gists{/gist_id}","starred_url":"https://api.github.com/users/aparent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aparent/subscriptions","organizations_url":"https://api.github.com/users/aparent/orgs","repos_url":"https://api.github.com/users/aparent/repos","events_url":"https://api.github.com/users/aparent/events{/privacy}","received_events_url":"https://api.github.com/users/aparent/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-03T20:03:58Z","updated_at":"2016-11-11T02:42:17Z","closed_at":null,"body":"We should be zeroing memory that is used to store secret data in our free functions.  It turns out that it is pretty difficult to do this in a way that is portable and guaranteed not to be optimized away.  We could do something a bit ugly as show below (from libsodium): \r\n\r\n```\r\n#ifdef HAVE_WEAK_SYMBOLS\r\n__attribute__ ((weak)) void\r\n_sodium_memzero_as_a_weak_symbol_to_prevent_lto(void * const pnt, const size_t len)\r\n{\r\n    unsigned char *pnt_ = (unsigned char *) pnt;;\r\n    size_t         i = (size_t) 0U;\r\n\r\n    while (i < len) {\r\n        pnt_[i++] = 0U;\r\n    }\r\n}\r\n#endif\r\n\r\nvoid\r\nsodium_memzero(void * const pnt, const size_t len)\r\n{\r\n#ifdef _WIN32\r\n    SecureZeroMemory(pnt, len);\r\n#elif defined(HAVE_MEMSET_S)\r\n    if (len > 0U && memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {\r\n        abort(); /* LCOV_EXCL_LINE */\r\n    }\r\n#elif defined(HAVE_EXPLICIT_BZERO)\r\n    explicit_bzero(pnt, len);\r\n#elif HAVE_WEAK_SYMBOLS\r\n    _sodium_memzero_as_a_weak_symbol_to_prevent_lto(pnt, len);\r\n#else\r\n    volatile unsigned char *volatile pnt_ =\r\n        (volatile unsigned char * volatile) pnt;\r\n    size_t i = (size_t) 0U;\r\n\r\n    while (i < len) {\r\n        pnt_[i++] = 0U;\r\n    }\r\n#endif\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/comments/259867097","html_url":"https://github.com/open-quantum-safe/liboqs/issues/48#issuecomment-259867097","issue_url":"https://api.github.com/repos/open-quantum-safe/liboqs/issues/48","id":259867097,"user":{"login":"dstebila","id":8843219,"avatar_url":"https://avatars.githubusercontent.com/u/8843219?v=3","gravatar_id":"","url":"https://api.github.com/users/dstebila","html_url":"https://github.com/dstebila","followers_url":"https://api.github.com/users/dstebila/followers","following_url":"https://api.github.com/users/dstebila/following{/other_user}","gists_url":"https://api.github.com/users/dstebila/gists{/gist_id}","starred_url":"https://api.github.com/users/dstebila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstebila/subscriptions","organizations_url":"https://api.github.com/users/dstebila/orgs","repos_url":"https://api.github.com/users/dstebila/repos","events_url":"https://api.github.com/users/dstebila/events{/privacy}","received_events_url":"https://api.github.com/users/dstebila/received_events","type":"User","site_admin":false},"created_at":"2016-11-11T02:42:17Z","updated_at":"2016-11-11T02:42:17Z","body":"Looks good to me.  Mike, any comments?\r\n\r\nWith the same pull request, could you go through the rest of the codebase and put in these cleanse calls everywhere memory that could contain a secret value is freed?"}}
{"actor":{"display_login":"dstebila"}}