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_CECPQ2_HYBRID_KEY_TEMPLATES_H_ 18 #define TINK_EXPERIMENTAL_PQCRYPTO_KEM_CECPQ2_HYBRID_KEY_TEMPLATES_H_ 19 20 #include "proto/tink.pb.h" 21 22 namespace crypto { 23 namespace tink { 24 25 /////////////////////////////////////////////////////////////////////////////// 26 // Pre-generated KeyTemplate for hybrid key types. One can use these templates 27 // to generate a new KeysetHandle object with fresh keys. 28 // To generate a new keyset that contains a single Cecpq2AeadHkdfPrivateKey, 29 // one can do: 30 // 31 // auto status = Cecpq2HybridConfig::Register(); 32 // if (!status.ok()) { /* fail with error */ } 33 // auto handle_result = KeysetHandle::GenerateNew( 34 // Cecpq2HybridKeyTemplates::Cecpq2P256HkdfHmacSha256Aes128Gcm()); 35 // if (!handle_result.ok()) { /* fail with error */ } 36 // auto keyset_handle = std::move(handle_result.value()); 37 38 // Returns a KeyTemplate that generates new instances of 39 // Cecpq2AeadHkdfPrivateKey with the following parameters: 40 // - KEM: CECPQ2 41 // - DEM: AES256-GCM 42 // - KDF: HKDF-HMAC-SHA256 with an empty salt 43 // - EC Point Format: Compressed 44 // - OutputPrefixType: TINK 45 const google::crypto::tink::KeyTemplate& 46 Cecpq2HybridKeyTemplateX25519HkdfHmacSha256Aes256Gcm(); 47 48 // Returns a KeyTemplate that generates new instances of 49 // Cecpq2AeadHkdfPrivateKey with the following parameters: 50 // - KEM: CECPQ2 51 // - DEM: XChaCha20-Poly1305 with the following parameters: 52 // * XChaCha20 key size: 32 bytes 53 // * IV size: 24 bytes 54 // - KDF: HKDF-HMAC-SHA256 with an empty salt 55 // - EC Point Format: Compressed 56 // - OutputPrefixType: TINK 57 const google::crypto::tink::KeyTemplate& 58 Cecpq2HybridKeyTemplateX25519HkdfHmacSha256XChaCha20Poly1305(); 59 60 // Returns a KeyTemplate that generates new instances of 61 // Cecpq2AeadHkdfPrivateKey with the following parameters: 62 // - KEM: CECPQ2 63 // - DEM: AES256-SIV (Deterministic Aead) 64 // - KDF: HKDF-HMAC-SHA256 with an empty salt 65 // - EC Point Format: Compressed 66 // - OutputPrefixType: TINK 67 const google::crypto::tink::KeyTemplate& 68 Cecpq2HybridKeyTemplateX25519HkdfHmacSha256DeterministicAesSiv(); 69 70 } // namespace tink 71 } // namespace crypto 72 73 #endif // TINK_EXPERIMENTAL_PQCRYPTO_KEM_CECPQ2_HYBRID_KEY_TEMPLATES_H_ 74