{"thread":{"id":"59320","subject":"Problems with CSPRNG in wrapper.c","startedAt":"2023-02-27T23:06:17Z","lastAt":"2023-02-28T00:52:15Z","messageCount":5,"participants":["rsbecker@nexbridge.com","Junio C Hamano","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"472828","messageId":"003d01d94b00$16abc7a0$440356e0$@nexbridge.com","threadId":"59320","inReplyTo":null,"subject":"Problems with CSPRNG in wrapper.c","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2023-02-27T23:06:07Z","receivedAt":"2023-02-27T23:06:17Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"I've hit an issue with git that has me stumped at a customer site - so I\nhave limited visibility on what is actually wrong. This is pretty urgent\nthat I resolve this.\n\nIn git/wrapper (lines 477 from :\n       if (csprng_bytes(&v, sizeof(v)) < 0)\n       \treturn error_errno(\"unable to get random bytes for temporary file\");\n\nFirst, I was not aware that csprng was a git dependency - not sure why\nbecause we depend on OpenSSL_random that should return random bytes. Does\nthis still mean that there is a dependency on PRNGD, or is there another\ndependency I am missing.\n\nShould I get them to revert back to an older git version (which one)? Is a\npatch needed?\n\nThanks,\nRandall\n\n--\nBrief whoami: NonStop&UNIX developer since approximately\nUNIX(421664400)\nNonStop(211288444200000000)\n-- In real life, I talk too much.\n\n\n\n\n\n\n"},{"id":"472829","messageId":"xmqqv8jmr98f.fsf@gitster.g","threadId":"59320","inReplyTo":"003d01d94b00$16abc7a0$440356e0$@nexbridge.com","subject":"Re: Problems with CSPRNG in wrapper.c","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-02-27T23:15:12Z","receivedAt":"2023-02-27T23:15:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"<rsbecker@nexbridge.com> writes:\n\n> First, I was not aware that csprng was a git dependency ...\n\nYou can choose from implementations that depend on common external\nlibraries and system functions, but we have a fallback internal\nimplementation that only requires /dev/urandom.\n\nSee description for CSPRNG_METHOD in Makefile and 05cd988d (wrapper:\nadd a helper to generate numbers from a CSPRNG, 2022-01-17) for\nadditional background.\n"},{"id":"472831","messageId":"003e01d94b02$877c2c20$96748460$@nexbridge.com","threadId":"59320","inReplyTo":"xmqqv8jmr98f.fsf@gitster.g","subject":"RE: Problems with CSPRNG in wrapper.c","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2023-02-27T23:23:36Z","receivedAt":"2023-02-27T23:23:59Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Monday, February 27, 2023 6:15 PM, Junio C Hamano wrote:\n><rsbecker@nexbridge.com> writes:\n>\n>> First, I was not aware that csprng was a git dependency ...\n>\n>You can choose from implementations that depend on common external\nlibraries\n>and system functions, but we have a fallback internal implementation that\nonly\n>requires /dev/urandom.\n>\n>See description for CSPRNG_METHOD in Makefile and 05cd988d (wrapper:\n>add a helper to generate numbers from a CSPRNG, 2022-01-17) for additional\n>background.\n\nI have already been down that path, but not successfully. /dev/urandom is\nnot available on the platform - never has, never will to my knowledge. This\ndoes appear to work if PRNGD is correctly running, but I can't seem to get\nthat to work on this site. The config.mak.uname for NonStop does specify:\n\nCSPRNG_METHOD = openssl\n\nwhich should use OPENSSL_random(), shouldn't it? OpenSSL 3.0 uses the\n_rdrand() builtin so should ever go to PRNGD, but it seems like this is\nanyway. Debugging isn't possible as this is not on my own systems - and\nthings work here. Is there any kind of tracing I can do?\n\n"},{"id":"472832","messageId":"Y/1GpjnMHLAqFV5x@tapette.crustytoothpaste.net","threadId":"59320","inReplyTo":"003e01d94b02$877c2c20$96748460$@nexbridge.com","subject":"Re: Problems with CSPRNG in wrapper.c","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2023-02-28T00:11:32Z","receivedAt":"2023-02-28T00:12:01Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2023-02-27 at 23:23:36, rsbecker@nexbridge.com wrote:\n> I have already been down that path, but not successfully. /dev/urandom is\n> not available on the platform - never has, never will to my knowledge. This\n> does appear to work if PRNGD is correctly running, but I can't seem to get\n> that to work on this site. The config.mak.uname for NonStop does specify:\n> \n> CSPRNG_METHOD = openssl\n> \n> which should use OPENSSL_random(), shouldn't it? OpenSSL 3.0 uses the\n> _rdrand() builtin so should ever go to PRNGD, but it seems like this is\n> anyway. Debugging isn't possible as this is not on my own systems - and\n> things work here. Is there any kind of tracing I can do?\n\nIt actually uses RAND_bytes.  I've confirmed on my Debian sid/amd64\nsystem that compiling with \"make -j8 CSPRNG_METHOD=openssl\" results in\nthe binary having a dependency on RAND_bytes.  (I used \"nm -D\".)\n\nDoes your system have an nm binary that you could use to verify the\nlinkage?  (OpenBSD says it has existed since Version 1 Unix, but that\ndoesn't mean it exists everywhere.)  Once you can verify the linkage,\nyou'll know whether the problem is OpenSSL not producing CSPRNG data or\nwhether the CSPRNG_METHOD is incorrect.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"472836","messageId":"004d01d94b0e$ded4e5a0$9c7eb0e0$@nexbridge.com","threadId":"59320","inReplyTo":"Y/1GpjnMHLAqFV5x@tapette.crustytoothpaste.net","subject":"RE: Problems with CSPRNG in wrapper.c","fromName":"","fromEmail":"rsbecker@nexbridge.com","sentAt":"2023-02-28T00:51:56Z","receivedAt":"2023-02-28T00:52:15Z","isPatch":false,"sender":{"key":"randall.becker@nexbridge.ca","avatar":"https://avatars.githubusercontent.com/u/28956764?v=4"},"body":"On Monday, February 27, 2023 7:12 PM, brian m. carlson wrote:\n>On 2023-02-27 at 23:23:36, rsbecker@nexbridge.com wrote:\n>> I have already been down that path, but not successfully. /dev/urandom\n>> is not available on the platform - never has, never will to my\n>> knowledge. This does appear to work if PRNGD is correctly running, but\n>> I can't seem to get that to work on this site. The config.mak.uname for NonStop\n>does specify:\n>>\n>> CSPRNG_METHOD = openssl\n>>\n>> which should use OPENSSL_random(), shouldn't it? OpenSSL 3.0 uses the\n>> _rdrand() builtin so should ever go to PRNGD, but it seems like this\n>> is anyway. Debugging isn't possible as this is not on my own systems -\n>> and things work here. Is there any kind of tracing I can do?\n>\n>It actually uses RAND_bytes.  I've confirmed on my Debian sid/amd64 system that\n>compiling with \"make -j8 CSPRNG_METHOD=openssl\" results in the binary having a\n>dependency on RAND_bytes.  (I used \"nm -D\".)\n>\n>Does your system have an nm binary that you could use to verify the linkage?\n>(OpenBSD says it has existed since Version 1 Unix, but that doesn't mean it exists\n>everywhere.)  Once you can verify the linkage, you'll know whether the problem is\n>OpenSSL not producing CSPRNG data or whether the CSPRNG_METHOD is incorrect.\n\nI can confirm:\nCalled Procedures\n    Calling Procedures\n----------------------------------------------------------------------\n RAND_bytes\n    csprng_bytes\n\nSo that's something good. I'm wondering why this problem is showing up because my x86 OpenSSL build passes FIPS which would not if it depended on PRNGD. Both platforms call git_mkstemps_mode from csprng_bytes, but that is expected. I have opened a separate case with OpenSSL, but all tests are passing there. It seems like git is ending up in the hardware randomizer code works if PRNGD is running but fails if PRNGD is not running. I am perplexed.\n\n"}]}