| 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 |
| 11 | #ifndef RTC_BASE_SSL_FINGERPRINT_H_ |
| 12 | #define RTC_BASE_SSL_FINGERPRINT_H_ |
| 13 |
| 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
| 16 | #include <string> |
| 17 |
| 18 | #include "rtc_base/copy_on_write_buffer.h" |
| 19 | #include "rtc_base/system/rtc_export.h" |
| 20 |
| 21 | namespace rtc { |
| 22 |
| 23 | class RTCCertificate; |
| 24 | class SSLCertificate; |
| 25 | class SSLIdentity; |
| 26 |
| 27 | struct RTC_EXPORT SSLFingerprint { |
| 28 | // TODO(steveanton): Remove once downstream projects have moved off of this. |
| 29 | static SSLFingerprint* Create(const std::string& algorithm, |
| 30 | const rtc::SSLIdentity* identity); |
| 31 | // TODO(steveanton): Rename to Create once projects have migrated. |
| 32 | static std::unique_ptr<SSLFingerprint> CreateUnique( |
| 33 | const std::string& algorithm, |
| 34 | const rtc::SSLIdentity& identity); |
| 35 |
| 36 | static std::unique_ptr<SSLFingerprint> Create( |
| 37 | const std::string& algorithm, |
| 38 | const rtc::SSLCertificate& cert); |
| 39 |
| 40 | // TODO(steveanton): Remove once downstream projects have moved off of this. |
| 41 | static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm, |
| 42 | const std::string& fingerprint); |
| 43 | // TODO(steveanton): Rename to CreateFromRfc4572 once projects have migrated. |
| 44 | static std::unique_ptr<SSLFingerprint> CreateUniqueFromRfc4572( |
| 45 | const std::string& algorithm, |
| 46 | const std::string& fingerprint); |
| 47 |
| 48 | // Creates a fingerprint from a certificate, using the same digest algorithm |
| 49 | // as the certificate's signature. |
| 50 | static std::unique_ptr<SSLFingerprint> CreateFromCertificate( |
| 51 | const RTCCertificate& cert); |
| 52 |
| 53 | SSLFingerprint(const std::string& algorithm, |
| 54 | ArrayView<const uint8_t> digest_view); |
| 55 | // TODO(steveanton): Remove once downstream projects have moved off of this. |
| 56 | SSLFingerprint(const std::string& algorithm, |
| 57 | const uint8_t* digest_in, |
| 58 | size_t digest_len); |
| 59 |
| 60 | SSLFingerprint(const SSLFingerprint& from) = default; |
| 61 | SSLFingerprint& operator=(const SSLFingerprint& from) = default; |
| 62 |
| 63 | bool operator==(const SSLFingerprint& other) const; |
| 64 |
| 65 | std::string GetRfc4572Fingerprint() const; |
| 66 |
| 67 | std::string ToString() const; |
| 68 |
| 69 | std::string algorithm; |
| 70 | rtc::CopyOnWriteBuffer digest; |
| 71 | }; |
| 72 |
| 73 | } // namespace rtc |
| 74 |
| 75 | #endif // RTC_BASE_SSL_FINGERPRINT_H_ |
| 76 |