1 // Copyright 2021 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 /////////////////////////////////////////////////////////////////////////////// 16 17 #ifndef TINK_EXPERIMENTAL_PQCRYPTO_KEM_SUBTLE_CECPQ2_SUBTLE_BORINGSSL_UTIL_H_ 18 #define TINK_EXPERIMENTAL_PQCRYPTO_KEM_SUBTLE_CECPQ2_SUBTLE_BORINGSSL_UTIL_H_ 19 20 #include <string> 21 22 #include "openssl/hrss.h" 23 #include "tink/subtle/common_enums.h" 24 #include "tink/util/secret_data.h" 25 #include "tink/util/statusor.h" 26 27 namespace crypto { 28 namespace tink { 29 namespace pqc { 30 31 struct HrssKeyPair { 32 crypto::tink::util::SecretData hrss_private_key_seed; 33 std::string hrss_public_key_marshaled; 34 }; 35 36 struct EccKeyPair { 37 std::string pub_x; 38 std::string pub_y; 39 util::SecretData priv; 40 }; 41 42 struct Cecpq2KeyPair { 43 struct HrssKeyPair hrss_key_pair; 44 struct EccKeyPair x25519_key_pair; 45 }; 46 47 // This is an utility function that generates a new HRSS key pair from a high 48 // entropy seed (hrss_key_entropy). This function is expected to be called from 49 // a key manager class, which will take care of generating a high entropy seed. 50 crypto::tink::util::StatusOr<HrssKeyPair> GenerateHrssKeyPair( 51 util::SecretData hrss_key_entropy); 52 53 // This method performs CECPQ2 (HRSS and X25519) key generation, 54 // and HRSS public key marshaling. 55 crypto::tink::util::StatusOr<crypto::tink::pqc::Cecpq2KeyPair> 56 GenerateCecpq2Keypair(subtle::EllipticCurveType curve_type); 57 58 } // namespace pqc 59 } // namespace tink 60 } // namespace crypto 61 62 #endif // TINK_EXPERIMENTAL_PQCRYPTO_KEM_SUBTLE_CECPQ2_SUBTLE_BORINGSSL_UTIL_H_ 63