2014-05-13 18:00:26 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef RTC_BASE_SSLFINGERPRINT_H_
|
|
|
|
|
#define RTC_BASE_SSLFINGERPRINT_H_
|
2014-05-13 18:00:26 +00:00
|
|
|
|
2017-06-29 07:52:50 +02:00
|
|
|
#include <string>
|
2014-05-13 18:00:26 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/copyonwritebuffer.h"
|
|
|
|
|
#include "rtc_base/rtccertificate.h"
|
|
|
|
|
#include "rtc_base/sslidentity.h"
|
2017-06-29 07:52:50 +02:00
|
|
|
|
|
|
|
|
namespace rtc {
|
|
|
|
|
|
|
|
|
|
class SSLCertificate;
|
|
|
|
|
|
|
|
|
|
struct SSLFingerprint {
|
2018-10-15 19:27:44 -07:00
|
|
|
// TODO(steveanton): Remove once downstream projects have moved off of this.
|
2018-10-11 11:15:48 +00:00
|
|
|
static SSLFingerprint* Create(const std::string& algorithm,
|
2018-10-15 14:18:03 +00:00
|
|
|
const rtc::SSLIdentity* identity);
|
2018-10-15 19:27:44 -07:00
|
|
|
// TODO(steveanton): Rename to Create once projects have migrated.
|
|
|
|
|
static std::unique_ptr<SSLFingerprint> CreateUnique(
|
|
|
|
|
const std::string& algorithm,
|
|
|
|
|
const rtc::SSLIdentity& identity);
|
2017-06-29 07:52:50 +02:00
|
|
|
|
2018-10-15 19:27:44 -07:00
|
|
|
static std::unique_ptr<SSLFingerprint> Create(
|
|
|
|
|
const std::string& algorithm,
|
|
|
|
|
const rtc::SSLCertificate& cert);
|
2017-06-29 07:52:50 +02:00
|
|
|
|
2018-10-15 19:27:44 -07:00
|
|
|
// TODO(steveanton): Remove once downstream projects have moved off of this.
|
2017-06-29 07:52:50 +02:00
|
|
|
static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm,
|
|
|
|
|
const std::string& fingerprint);
|
2018-10-15 19:27:44 -07:00
|
|
|
// TODO(steveanton): Rename to CreateFromRfc4572 once projects have migrated.
|
|
|
|
|
static std::unique_ptr<SSLFingerprint> CreateUniqueFromRfc4572(
|
|
|
|
|
const std::string& algorithm,
|
|
|
|
|
const std::string& fingerprint);
|
2017-06-29 07:52:50 +02:00
|
|
|
|
|
|
|
|
// Creates a fingerprint from a certificate, using the same digest algorithm
|
|
|
|
|
// as the certificate's signature.
|
2018-10-15 19:27:44 -07:00
|
|
|
static std::unique_ptr<SSLFingerprint> CreateFromCertificate(
|
|
|
|
|
const RTCCertificate& cert);
|
2017-06-29 07:52:50 +02:00
|
|
|
|
2018-10-15 19:27:44 -07:00
|
|
|
SSLFingerprint(const std::string& algorithm,
|
|
|
|
|
ArrayView<const uint8_t> digest_view);
|
|
|
|
|
// TODO(steveanton): Remove once downstream projects have moved off of this.
|
2017-06-29 07:52:50 +02:00
|
|
|
SSLFingerprint(const std::string& algorithm,
|
|
|
|
|
const uint8_t* digest_in,
|
|
|
|
|
size_t digest_len);
|
|
|
|
|
|
|
|
|
|
SSLFingerprint(const SSLFingerprint& from);
|
|
|
|
|
|
|
|
|
|
bool operator==(const SSLFingerprint& other) const;
|
|
|
|
|
|
|
|
|
|
std::string GetRfc4572Fingerprint() const;
|
|
|
|
|
|
|
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
std::string algorithm;
|
|
|
|
|
rtc::CopyOnWriteBuffer digest;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace rtc
|
2014-05-13 18:00:26 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // RTC_BASE_SSLFINGERPRINT_H_
|