1 // Copyright 2023 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 // https://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 #ifndef ANONYMOUS_TOKENS_CPP_CRYPTO_ANONYMOUS_TOKENS_PB_OPENSSL_CONVERTERS_H_ 16 #define ANONYMOUS_TOKENS_CPP_CRYPTO_ANONYMOUS_TOKENS_PB_OPENSSL_CONVERTERS_H_ 17 18 #include <string> 19 20 #include "absl/status/statusor.h" 21 #include "anonymous_tokens/proto/anonymous_tokens.pb.h" 22 #include <openssl/base.h> 23 24 25 namespace anonymous_tokens { 26 27 // Generate a message mask. For more details, see 28 // https://datatracker.ietf.org/doc/draft-irtf-cfrg-rsa-blind-signatures/ 29 absl::StatusOr<std::string> GenerateMask( 30 const RSABlindSignaturePublicKey& public_key); 31 32 // Converts the AnonymousTokens proto hash type to the equivalent EVP digest. 33 absl::StatusOr<const EVP_MD*> 34 ProtoHashTypeToEVPDigest(HashType hash_type); 35 36 // Converts the AnonymousTokens proto hash type for mask generation function to 37 // the equivalent EVP digest. 38 absl::StatusOr<const EVP_MD*> 39 ProtoMaskGenFunctionToEVPDigest(MaskGenFunction mgf); 40 41 // Converts AnonymousTokens::RSAPrivateKey to bssl::UniquePtr<RSA> without 42 // public metadata augmentation. 43 absl::StatusOr<bssl::UniquePtr<RSA>> 44 AnonymousTokensRSAPrivateKeyToRSA(const RSAPrivateKey& private_key); 45 46 // Converts AnonymousTokens::RSAPublicKey to bssl::UniquePtr<RSA> without 47 // public metadata augmentation. 48 absl::StatusOr<bssl::UniquePtr<RSA>> 49 AnonymousTokensRSAPublicKeyToRSA(const RSAPublicKey& public_key); 50 51 } // namespace anonymous_tokens 52 53 54 #endif // ANONYMOUS_TOKENS_CPP_CRYPTO_ANONYMOUS_TOKENS_PB_OPENSSL_CONVERTERS_H_ 55