1 /* 2 * Copyright 2018 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef FCP_SECAGG_TESTING_FAKE_PRNG_H_ 18 #define FCP_SECAGG_TESTING_FAKE_PRNG_H_ 19 20 #include <cstdint> 21 22 #include "fcp/secagg/shared/prng.h" 23 24 namespace fcp { 25 namespace secagg { 26 27 // Fake Implementation of SecurePrng that just returns constantly incrementing 28 // values. 29 30 class FakePrng : public SecurePrng { 31 public: 32 // Returns 1, 2, 3, etc. 33 FakePrng() = default; 34 35 // Returns the selected value first, and increments by 1 each time from there. FakePrng(uint64_t value)36 explicit FakePrng(uint64_t value) : value_(value - 1) {} 37 Rand8()38 uint8_t Rand8() override { return static_cast<uint8_t>(++value_); } Rand64()39 uint64_t Rand64() override { return ++value_; } 40 41 private: 42 uint64_t value_ = 0; 43 }; 44 45 } // namespace secagg 46 } // namespace fcp 47 48 #endif // FCP_SECAGG_TESTING_FAKE_PRNG_H_ 49