/* * KmsConnectorInterface.h * * This source file is part of the FoundationDB open source project * * Copyright 2013-2022 Apple Inc. and the FoundationDB project authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef FDBSERVER_KMSCONNECTORINTERFACE_H #define FDBSERVER_KMSCONNECTORINTERFACE_H #pragma once #include "fdbrpc/fdbrpc.h" #include "flow/EncryptUtils.h" #include "flow/FileIdentifier.h" #include "flow/Trace.h" #include "flow/flow.h" #include "flow/network.h" struct KmsConnectorInterface { constexpr static FileIdentifier file_identifier = 2416711; RequestStream> waitFailure; RequestStream ekLookupByIds; RequestStream ekLookupByDomainIds; KmsConnectorInterface() {} UID id() const { return ekLookupByIds.getEndpoint().token; } template void serialize(Archive& ar) { if constexpr (!is_fb_function) { ASSERT(ar.protocolVersion().isValid()); } serializer(ar, waitFailure); if (Archive::isDeserializing) { ekLookupByIds = RequestStream(waitFailure.getEndpoint().getAdjustedEndpoint(1)); ekLookupByDomainIds = RequestStream(waitFailure.getEndpoint().getAdjustedEndpoint(2)); } } void initEndpoints() { std::vector> streams; streams.push_back(waitFailure.getReceiver()); streams.push_back(ekLookupByIds.getReceiver(TaskPriority::Worker)); streams.push_back(ekLookupByDomainIds.getReceiver(TaskPriority::Worker)); FlowTransport::transport().addEndpoints(streams); } }; struct EncryptCipherKeyDetails { constexpr static FileIdentifier file_identifier = 1227025; EncryptCipherDomainId encryptDomainId; EncryptCipherBaseKeyId encryptKeyId; StringRef encryptKey; EncryptCipherKeyDetails() {} explicit EncryptCipherKeyDetails(EncryptCipherDomainId dId, EncryptCipherBaseKeyId keyId, StringRef key, Arena& arena) : encryptDomainId(dId), encryptKeyId(keyId), encryptKey(StringRef(arena, key)) {} bool operator==(const EncryptCipherKeyDetails& toCompare) { return encryptDomainId == toCompare.encryptDomainId && encryptKeyId == toCompare.encryptKeyId && encryptKey.compare(toCompare.encryptKey) == 0; } template void serialize(Ar& ar) { serializer(ar, encryptDomainId, encryptKeyId, encryptKey); } }; struct KmsConnLookupEKsByKeyIdsRep { constexpr static FileIdentifier file_identifier = 2313778; Arena arena; std::vector cipherKeyDetails; KmsConnLookupEKsByKeyIdsRep() {} template void serialize(Ar& ar) { serializer(ar, arena, cipherKeyDetails); } }; struct KmsConnLookupEKsByKeyIdsReq { constexpr static FileIdentifier file_identifier = 6913396; std::vector> encryptKeyIds; ReplyPromise reply; KmsConnLookupEKsByKeyIdsReq() {} explicit KmsConnLookupEKsByKeyIdsReq( const std::vector>& keyIds) : encryptKeyIds(keyIds) {} template void serialize(Ar& ar) { serializer(ar, encryptKeyIds, reply); } }; struct KmsConnLookupEKsByDomainIdsRep { constexpr static FileIdentifier file_identifier = 3009025; Arena arena; std::vector cipherKeyDetails; KmsConnLookupEKsByDomainIdsRep() {} template void serialize(Ar& ar) { serializer(ar, arena, cipherKeyDetails); } }; struct KmsConnLookupEKsByDomainIdsReq { constexpr static FileIdentifier file_identifier = 9918682; std::vector encryptDomainIds; ReplyPromise reply; KmsConnLookupEKsByDomainIdsReq() {} explicit KmsConnLookupEKsByDomainIdsReq(const std::vector& ids) : encryptDomainIds(ids) {} template void serialize(Ar& ar) { serializer(ar, encryptDomainIds, reply); } }; #endif