Bug 1518728 - Pass key length to libprio public key export function and use long long for output. r=hsivonen, a=RyanVM
authorRobert Helmer <rhelmer@mozilla.com>
Fri, 11 Jan 2019 08:25:42 +0000
changeset 509519 548bb5b013ffd0bfac11879c6fe89b276dddae24
parent 509518 7f847507d3bb84ed438fe58b898d07e15cab9a32
child 509520 5a50ebe155c4c2b3e76bb01c57e77f452a6c4dca
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen, RyanVM
bugs1518728
milestone65.0
Bug 1518728 - Pass key length to libprio public key export function and use long long for output. r=hsivonen, a=RyanVM Depends on D16266 Differential Revision: https://phabricator.services.mozilla.com/D16267
dom/prio/test/gtest/TestPrioEncoder.cpp
--- a/dom/prio/test/gtest/TestPrioEncoder.cpp
+++ b/dom/prio/test/gtest/TestPrioEncoder.cpp
@@ -108,17 +108,17 @@ TEST(PrioEncoder, VerifyFull) {
   // Number of different boolean data fields we collect.
   const int ndata = 3;
 
   unsigned char batchIDStr[32];
   memset(batchIDStr, 0, sizeof batchIDStr);
   snprintf((char*)batchIDStr, sizeof batchIDStr, "%d", rand());
 
   bool dataItems[ndata];
-  unsigned long output[ndata];
+  unsigned long long output[ndata];
 
   // The client's data submission is an arbitrary boolean vector.
   for (int i = 0; i < ndata; i++) {
     // Arbitrary data
     dataItems[i] = rand() % 2;
   }
 
   // Initialize NSS random number generator.
@@ -128,22 +128,23 @@ TEST(PrioEncoder, VerifyFull) {
   // Generate keypairs for servers
   prioRv = Keypair_new(&skA, &pkA);
   ASSERT_TRUE(prioRv == SECSuccess);
 
   prioRv = Keypair_new(&skB, &pkB);
   ASSERT_TRUE(prioRv == SECSuccess);
 
   // Export public keys to hex and print to stdout
-  unsigned char pkHexA[CURVE25519_KEY_LEN_HEX + 1];
-  unsigned char pkHexB[CURVE25519_KEY_LEN_HEX + 1];
-  prioRv = PublicKey_export_hex(pkA, pkHexA);
+  const int keyLength = CURVE25519_KEY_LEN_HEX + 1;
+  unsigned char pkHexA[keyLength];
+  unsigned char pkHexB[keyLength];
+  prioRv = PublicKey_export_hex(pkA, pkHexA, keyLength);
   ASSERT_TRUE(prioRv == SECSuccess);
 
-  prioRv = PublicKey_export_hex(pkB, pkHexB);
+  prioRv = PublicKey_export_hex(pkB, pkHexB, keyLength);
   ASSERT_TRUE(prioRv == SECSuccess);
 
   // Use the default configuration parameters.
   cfg = PrioConfig_new(ndata, pkA, pkB, batchIDStr, strlen((char*)batchIDStr));
   ASSERT_TRUE(cfg != nullptr);
 
   PrioPRGSeed serverSecret;
   prioRv = PrioPRGSeed_randomize(&serverSecret);