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_SIGNATURE_UTIL_ENUMS_H_ 18 #define TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_UTIL_ENUMS_H_ 19 20 #include "absl/strings/string_view.h" 21 #include "tink/experimental/pqcrypto/signature/subtle/dilithium_key.h" 22 #include "tink/experimental/pqcrypto/signature/subtle/sphincs_subtle_utils.h" 23 #include "tink/util/statusor.h" 24 #include "proto/experimental/pqcrypto/dilithium.pb.h" 25 #include "proto/experimental/pqcrypto/sphincs.pb.h" 26 #include "proto/tink.pb.h" 27 28 namespace crypto { 29 namespace tink { 30 namespace util { 31 32 // Helpers for translation of pqcrypto enums between protocol buffer enums, 33 // their string representation, and pqcrypto enums used in subtle. 34 class EnumsPqcrypto { 35 public: 36 // DilithiumSeedExpansion. 37 static google::crypto::tink::DilithiumSeedExpansion SubtleToProto( 38 crypto::tink::subtle::DilithiumSeedExpansion expansion); 39 40 static crypto::tink::subtle::DilithiumSeedExpansion ProtoToSubtle( 41 google::crypto::tink::DilithiumSeedExpansion expansion); 42 43 // SphincsHashType. 44 static google::crypto::tink::SphincsHashType SubtleToProto( 45 crypto::tink::subtle::SphincsHashType type); 46 47 static crypto::tink::subtle::SphincsHashType ProtoToSubtle( 48 google::crypto::tink::SphincsHashType type); 49 50 // SphincsVariant. 51 static google::crypto::tink::SphincsVariant SubtleToProto( 52 crypto::tink::subtle::SphincsVariant variant); 53 54 static crypto::tink::subtle::SphincsVariant ProtoToSubtle( 55 google::crypto::tink::SphincsVariant variant); 56 57 // SphincsSignatureType. 58 static google::crypto::tink::SphincsSignatureType SubtleToProto( 59 crypto::tink::subtle::SphincsSignatureType type); 60 61 static crypto::tink::subtle::SphincsSignatureType ProtoToSubtle( 62 google::crypto::tink::SphincsSignatureType type); 63 }; 64 65 } // namespace util 66 } // namespace tink 67 } // namespace crypto 68 69 #endif // TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_UTIL_ENUMS_H_ 70