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_ECDH_PREGENERATED_TEST_KEYS_H_ 18 #define FCP_SECAGG_TESTING_ECDH_PREGENERATED_TEST_KEYS_H_ 19 20 #include <string> 21 #include <vector> 22 23 #include "fcp/secagg/shared/ecdh_keys.h" 24 25 namespace fcp { 26 namespace secagg { 27 28 // This class contains some pregenerated ECDH public/private keypairs. In no 29 // actual implementation should pregenerated keys such as these be used. 30 class EcdhPregeneratedTestKeys { 31 public: 32 // Valid inputs for all functions are integers from 0 to kNumTestEcdhKeys. 33 static constexpr int kNumTestEcdhKeys = 8; 34 35 EcdhPregeneratedTestKeys(); 36 37 // Returns a public or private key. 38 EcdhPrivateKey GetPrivateKey(size_t index); 39 EcdhPublicKey GetPublicKey(size_t index); 40 41 // Returns a public or private key in the form of a string. 42 std::string GetPrivateKeyString(size_t index); 43 std::string GetPublicKeyString(size_t index); 44 45 // Returns an uncompressed public key. 46 EcdhPublicKey GetUncompressedPublicKey(size_t index); 47 // Returns an uncompressed public key in the form of a string, with X.509 48 // header. 49 std::string GetUncompressedPublicKeyString(size_t index); 50 51 private: 52 std::vector<const char*> private_key_strings_; 53 std::vector<const char*> public_key_strings_; 54 std::vector<EcdhPrivateKey> private_keys_; 55 std::vector<EcdhPublicKey> public_keys_; 56 std::vector<EcdhPublicKey> uncompressed_public_keys_; 57 std::vector<const char*> uncompressed_public_key_strings_; 58 }; 59 } // namespace secagg 60 } // namespace fcp 61 62 #endif // FCP_SECAGG_TESTING_ECDH_PREGENERATED_TEST_KEYS_H_ 63