)]}'
{
  "commit": "e79649ba4d515a1b5f57e397431d81f079ff158e",
  "tree": "071c3076df19fa229d64b405b9e9408e0ebe6749",
  "parents": [
    "bc97b7a8e1952bab69fea961301a90e5ad3344e9"
  ],
  "author": {
    "name": "Alex Gough",
    "email": "ajgo@chromium.org",
    "time": "Thu Jun 15 09:44:35 2023 -0700"
  },
  "committer": {
    "name": "Boringssl LUCI CQ",
    "email": "boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Thu Jun 22 19:51:36 2023 +0000"
  },
  "message": "Use ProcessPrng instead of RtlGenRandom on Windows\n\nThe Windows system RNG[1] lives in bcryptprimitives.dll which exports\nthe function ProcessPrng[2] to supply random bytes from its internal\ngenerators. These are seeded and reseeded from the operating\nsystem using a device connection to \\\\Device\\CNG which is opened\nwhen bcryptprimitives.dll is first loaded.\n\nAfter this CL boringssl calls ProcessPrng() directly.\n\nBefore this CL boringssl got its system randomness (on non-UWP\ndesktop Windows) from calls to RtlGenRandom[3].\nThis function is undocumented and unsupported, but has always been\navailable by linking to SystemFunction036 in advadpi32.dll. In\nWindows 10 and later, this export simply forwards to\ncryptbase.dll!SystemFunction036 which calls ProcessPrng()\ndirectly.\n\ncryptbase!SystemFunction036 decompiled:\n\n```\nBOOLEAN SystemFunction036(PVOID RandomBuffer,ULONG RandomBufferLength)\n{\n  BOOL retval;\n  retval \u003d ProcessPrng(RandomBuffer,RandomBufferLength);\n  return retval !\u003d 0;\n}\n```\n\nLoading cryptbase.dll has the side effect of opening a device handle\nto \\\\Device\\KsecDD which is not used by boringssl\u0027s random number\nwrappers. Calling ProcessPrng() directly allows sandboxed programs\nsuch as Chromium to avoid having this handle if they do not need it.\nProcessPrng() also takes a size_t length rather than a u32 length,\nallowing some simplification of the calling code.\n\nAfter this CL we require bcryptprimitives to be loaded before the\nfirst call to CRYPTO_srand(). Applications using the library should\neither load the module themselves or call CRYPTO_pre_sandbox_init().\nBefore this CL boringssl required that advapi32, cryptbase and\nbcryptprimitives were all loaded so this should not represent a\nbreaking change.\n\n[1] https://learn.microsoft.com/en-us/windows/win32/seccng/processprng\n[2] https://download.microsoft.com/download/1/c/9/1c9813b8-089c-4fef-b2ad-ad80e79403ba/Whitepaper%20-%20The%20Windows%2010%20random%20number%20generation%20infrastructure.pdf\n[3] https://docs.google.com/document/d/13n1t5ak0yofzcadQCF7Ew5TewSUkNfQ3n-IYodjeRYc/edit\n\nBug: chromium:74242\nChange-Id: Ifb1d6ef1a4539ff6e9a2c36cc119b7700ca2be8f\nReviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/60825\nCommit-Queue: David Benjamin \u003cdavidben@google.com\u003e\nReviewed-by: David Benjamin \u003cdavidben@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "3c996f17e00be69a3075165259b36b6a2a3f3bb9",
      "old_mode": 33188,
      "old_path": "crypto/fipsmodule/rand/internal.h",
      "new_id": "56fae233ec93d202710449ff116f0abcd21c4296",
      "new_mode": 33188,
      "new_path": "crypto/fipsmodule/rand/internal.h"
    },
    {
      "type": "modify",
      "old_id": "8ade68969d126593f671f292b10ae29dc39400b5",
      "old_mode": 33188,
      "old_path": "crypto/rand_extra/windows.c",
      "new_id": "0dbc0e36018ec4a2628c28a88ab60d9667905fb6",
      "new_mode": 33188,
      "new_path": "crypto/rand_extra/windows.c"
    }
  ]
}
