1 // Copyright 2018 Google Inc. 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 #include "tink/daead/deterministic_aead_key_templates.h" 18 19 #include "proto/aes_siv.pb.h" 20 #include "proto/common.pb.h" 21 #include "proto/tink.pb.h" 22 23 using google::crypto::tink::AesSivKeyFormat; 24 using google::crypto::tink::KeyTemplate; 25 using google::crypto::tink::OutputPrefixType; 26 27 namespace crypto { 28 namespace tink { 29 30 namespace { 31 NewAesSivKeyTemplate(int key_size_in_bytes)32KeyTemplate* NewAesSivKeyTemplate(int key_size_in_bytes) { 33 KeyTemplate* key_template = new KeyTemplate; 34 key_template->set_type_url( 35 "type.googleapis.com/google.crypto.tink.AesSivKey"); 36 key_template->set_output_prefix_type(OutputPrefixType::TINK); 37 AesSivKeyFormat key_format; 38 key_format.set_key_size(key_size_in_bytes); 39 key_format.SerializeToString(key_template->mutable_value()); 40 return key_template; 41 } 42 43 } // anonymous namespace 44 45 // static Aes256Siv()46const KeyTemplate& DeterministicAeadKeyTemplates::Aes256Siv() { 47 static const KeyTemplate* key_template = 48 NewAesSivKeyTemplate(/* key_size_in_bytes= */ 64); 49 return *key_template; 50 } 51 52 } // namespace tink 53 } // namespace crypto 54