1 /* 2 * Copyright 2019 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_SHARED_AES_CTR_PRNG_FACTORY_H_ 18 #define FCP_SECAGG_SHARED_AES_CTR_PRNG_FACTORY_H_ 19 20 #include <memory> 21 22 #include "fcp/secagg/shared/aes_key.h" 23 #include "fcp/secagg/shared/aes_prng_factory.h" 24 #include "fcp/secagg/shared/prng.h" 25 26 namespace fcp { 27 namespace secagg { 28 29 // Factory for the OpenSSL-based AesCtrPrng. 30 class AesCtrPrngFactory : public AesPrngFactory { 31 public: 32 AesCtrPrngFactory() = default; 33 34 // Creates and returns an instance of AesCtrPrng, given an AES key. 35 // For security reasons, the key MUST be suitable for immediate use in AES, 36 // i.e. it must not be a shared ECDH secret that has not yet been hashed. 37 std::unique_ptr<SecurePrng> MakePrng(const AesKey& key) const override; 38 39 // TODO(team): Remove this when transition to the batch mode of 40 // SecurePrng is fully done. SupportsBatchMode()41 bool SupportsBatchMode() const override { return true; } 42 }; 43 44 } // namespace secagg 45 } // namespace fcp 46 47 #endif // FCP_SECAGG_SHARED_AES_CTR_PRNG_FACTORY_H_ 48