henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #ifndef RTC_BASE_SSLFINGERPRINT_H_ |
| 12 | #define RTC_BASE_SSLFINGERPRINT_H_ |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 13 | |
Henrik Kjellander | ec78f1c | 2017-06-29 05:52:50 | [diff] [blame] | 14 | #include <string> |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 16 | #include "rtc_base/basictypes.h" |
| 17 | #include "rtc_base/copyonwritebuffer.h" |
| 18 | #include "rtc_base/rtccertificate.h" |
| 19 | #include "rtc_base/sslidentity.h" |
Henrik Kjellander | ec78f1c | 2017-06-29 05:52:50 | [diff] [blame] | 20 | |
| 21 | namespace rtc { |
| 22 | |
| 23 | class SSLCertificate; |
| 24 | |
| 25 | struct SSLFingerprint { |
| 26 | static SSLFingerprint* Create(const std::string& algorithm, |
| 27 | const rtc::SSLIdentity* identity); |
| 28 | |
| 29 | static SSLFingerprint* Create(const std::string& algorithm, |
| 30 | const rtc::SSLCertificate* cert); |
| 31 | |
| 32 | static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm, |
| 33 | const std::string& fingerprint); |
| 34 | |
| 35 | // Creates a fingerprint from a certificate, using the same digest algorithm |
| 36 | // as the certificate's signature. |
| 37 | static SSLFingerprint* CreateFromCertificate(const RTCCertificate* cert); |
| 38 | |
| 39 | SSLFingerprint(const std::string& algorithm, |
| 40 | const uint8_t* digest_in, |
| 41 | size_t digest_len); |
| 42 | |
| 43 | SSLFingerprint(const SSLFingerprint& from); |
| 44 | |
| 45 | bool operator==(const SSLFingerprint& other) const; |
| 46 | |
| 47 | std::string GetRfc4572Fingerprint() const; |
| 48 | |
| 49 | std::string ToString() const; |
| 50 | |
| 51 | std::string algorithm; |
| 52 | rtc::CopyOnWriteBuffer digest; |
| 53 | }; |
| 54 | |
| 55 | } // namespace rtc |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 | [diff] [blame] | 56 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 57 | #endif // RTC_BASE_SSLFINGERPRINT_H_ |