{"action":"created","issue":{"url":"https://api.github.com/repos/openssl/openssl/issues/5537","repository_url":"https://api.github.com/repos/openssl/openssl","labels_url":"https://api.github.com/repos/openssl/openssl/issues/5537/labels{/name}","comments_url":"https://api.github.com/repos/openssl/openssl/issues/5537/comments","events_url":"https://api.github.com/repos/openssl/openssl/issues/5537/events","html_url":"https://github.com/openssl/openssl/issues/5537","id":302947595,"number":5537,"title":"BN_mask_bits's error case doesn't make sense and is architecture-dependent","user":{"login":"davidben","id":109690,"avatar_url":"https://avatars0.githubusercontent.com/u/109690?v=4","gravatar_id":"","url":"https://api.github.com/users/davidben","html_url":"https://github.com/davidben","followers_url":"https://api.github.com/users/davidben/followers","following_url":"https://api.github.com/users/davidben/following{/other_user}","gists_url":"https://api.github.com/users/davidben/gists{/gist_id}","starred_url":"https://api.github.com/users/davidben/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidben/subscriptions","organizations_url":"https://api.github.com/users/davidben/orgs","repos_url":"https://api.github.com/users/davidben/repos","events_url":"https://api.github.com/users/davidben/events{/privacy}","received_events_url":"https://api.github.com/users/davidben/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/openssl/openssl/milestones/9","html_url":"https://github.com/openssl/openssl/milestone/9","labels_url":"https://api.github.com/repos/openssl/openssl/milestones/9/labels","id":2145708,"number":9,"title":"1.1.1","description":"","creator":{"login":"levitte","id":698918,"avatar_url":"https://avatars1.githubusercontent.com/u/698918?v=4","gravatar_id":"","url":"https://api.github.com/users/levitte","html_url":"https://github.com/levitte","followers_url":"https://api.github.com/users/levitte/followers","following_url":"https://api.github.com/users/levitte/following{/other_user}","gists_url":"https://api.github.com/users/levitte/gists{/gist_id}","starred_url":"https://api.github.com/users/levitte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/levitte/subscriptions","organizations_url":"https://api.github.com/users/levitte/orgs","repos_url":"https://api.github.com/users/levitte/repos","events_url":"https://api.github.com/users/levitte/events{/privacy}","received_events_url":"https://api.github.com/users/levitte/received_events","type":"User","site_admin":false},"open_issues":74,"closed_issues":306,"state":"open","created_at":"2016-11-19T09:18:52Z","updated_at":"2018-05-06T20:45:56Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2018-03-07T03:01:12Z","updated_at":"2018-05-06T20:49:08Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"`BN_mask_bits`'s documentation says:\r\n> An error occurs if `a` already is shorter than `n` bits.\r\n\r\nHowever the implementation only checks words, not bits:\r\nhttps://github.com/openssl/openssl/blob/72983c0eab750dfc1b6298c516df7afb1a73ba54/crypto/bn/bn_lib.c#L650-L651\r\n\r\nThis means it is inaccurate and in an architecture-dependent way. However, it also does not make much sense to have this as an error case. Indeed, looking through Debian code search, these are the callers which actually check the return value:\r\n1. https://sources.debian.org/src/u-boot/2018.01+dfsg1-2/lib/rsa/rsa-sign.c/?hl=537#L537\r\n2. https://sources.debian.org/src/bobcat/4.08.02-2/bigint/maskbits.cc/?hl=5#L5\r\n3. https://github.com/openssl/openssl/blob/72983c0eab750dfc1b6298c516df7afb1a73ba54/crypto/dsa/dsa_gen.c#L202\r\n4. https://github.com/openssl/openssl/blob/72983c0eab750dfc1b6298c516df7afb1a73ba54/crypto/dsa/dsa_gen.c#L476\r\n\r\n1, 3, and 4 would do the wrong thing were that behavior ever triggered. (Though it seems unlikely to trigger in each of these cases.) 2 is just a thin wrapper over OpenSSL, though I would be surprised if it too were expecting this behavior.\r\n\r\nRather, I suspect this was just a typo from SSLeay which got memorialized in dd8dec69b825c9fdafc26a200961702d850496b5. If one changes the branch to say `return 1`, it makes much more sense.\r\n\r\n(Fortunately, `BN_mask_bits` also does not allocate, so one may as well pretend it returns `void`.)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/openssl/openssl/issues/comments/386912409","html_url":"https://github.com/openssl/openssl/issues/5537#issuecomment-386912409","issue_url":"https://api.github.com/repos/openssl/openssl/issues/5537","id":386912409,"user":{"login":"richsalz","id":7332500,"avatar_url":"https://avatars0.githubusercontent.com/u/7332500?v=4","gravatar_id":"","url":"https://api.github.com/users/richsalz","html_url":"https://github.com/richsalz","followers_url":"https://api.github.com/users/richsalz/followers","following_url":"https://api.github.com/users/richsalz/following{/other_user}","gists_url":"https://api.github.com/users/richsalz/gists{/gist_id}","starred_url":"https://api.github.com/users/richsalz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richsalz/subscriptions","organizations_url":"https://api.github.com/users/richsalz/orgs","repos_url":"https://api.github.com/users/richsalz/repos","events_url":"https://api.github.com/users/richsalz/events{/privacy}","received_events_url":"https://api.github.com/users/richsalz/received_events","type":"User","site_admin":false},"created_at":"2018-05-06T20:49:08Z","updated_at":"2018-05-06T20:49:08Z","author_association":"CONTRIBUTOR","body":"I vote for option 3 -- fix it by documenting.  If we want, add a new API that has the \"right\" return values.  What's needed for 1.1.1?\r\n"}}
{"actor":{"display_login":"richsalz"}}