Use std::string_view for label strings

No need to deal with converting between string literals and Span<const
char> is kind of annoying, and now we just have std::string_view.

Bug: 42290600
Change-Id: Ic6a4de786f77c512a19fcf10ed7a5f8ec7cfbcdb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75207
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin
2025-01-11 00:07:57 -05:00
committed by Boringssl LUCI CQ
parent e4b6d4f754
commit 574fd72ebc
4 changed files with 53 additions and 73 deletions

View File

@@ -10,6 +10,8 @@
#include <openssl/ssl.h>
#include <string_view>
#include <openssl/buf.h>
#include <openssl/digest.h>
#include <openssl/err.h>
@@ -197,18 +199,13 @@ bool SSLTranscript::GetHash(uint8_t *out, size_t *out_len) const {
bool SSLTranscript::GetFinishedMAC(uint8_t *out, size_t *out_len,
const SSL_SESSION *session,
bool from_server) const {
static const char kClientLabel[] = "client finished";
static const char kServerLabel[] = "server finished";
auto label = from_server
? MakeConstSpan(kServerLabel, sizeof(kServerLabel) - 1)
: MakeConstSpan(kClientLabel, sizeof(kClientLabel) - 1);
uint8_t digest[EVP_MAX_MD_SIZE];
size_t digest_len;
if (!GetHash(digest, &digest_len)) {
return false;
}
std::string_view label = from_server ? "server finished" : "client finished";
static const size_t kFinishedLen = 12;
if (!tls1_prf(Digest(), MakeSpan(out, kFinishedLen), session->secret, label,
MakeConstSpan(digest, digest_len), {})) {