1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ 6 #define QUICHE_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "absl/strings/string_view.h" 12 #include "quiche/quic/core/quic_types.h" 13 #include "quiche/quic/platform/api/quic_export.h" 14 15 namespace quic { 16 17 // ChannelIDVerifier verifies ChannelID signatures. 18 class QUICHE_EXPORT ChannelIDVerifier { 19 public: 20 ChannelIDVerifier() = delete; 21 22 // kContextStr is prepended to the data to be signed in order to ensure that 23 // a ChannelID signature cannot be used in a different context. (The 24 // terminating NUL byte is inclued.) 25 static const char kContextStr[]; 26 // kClientToServerStr follows kContextStr to specify that the ChannelID is 27 // being used in the client to server direction. (The terminating NUL byte is 28 // included.) 29 static const char kClientToServerStr[]; 30 31 // Verify returns true iff |signature| is a valid signature of |signed_data| 32 // by |key|. 33 static bool Verify(absl::string_view key, absl::string_view signed_data, 34 absl::string_view signature); 35 36 // FOR TESTING ONLY: VerifyRaw returns true iff |signature| is a valid 37 // signature of |signed_data| by |key|. |is_channel_id_signature| indicates 38 // whether |signature| is a ChannelID signature (with kContextStr prepended 39 // to the data to be signed). 40 static bool VerifyRaw(absl::string_view key, absl::string_view signed_data, 41 absl::string_view signature, 42 bool is_channel_id_signature); 43 }; 44 45 } // namespace quic 46 47 #endif // QUICHE_QUIC_CORE_CRYPTO_CHANNEL_ID_H_ 48