henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2012, Google Inc. |
| 4 | * Copyright 2012, RTFM Inc. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are met: |
| 8 | * |
| 9 | * 1. Redistributions of source code must retain the above copyright notice, |
| 10 | * this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation |
| 13 | * and/or other materials provided with the distribution. |
| 14 | * 3. The name of the author may not be used to endorse or promote products |
| 15 | * derived from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 20 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #ifndef TALK_BASE_SSLFINGERPRINT_H_ |
| 30 | #define TALK_BASE_SSLFINGERPRINT_H_ |
| 31 | |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | #include <string> |
| 33 | |
| 34 | #include "talk/base/buffer.h" |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 35 | #include "talk/base/sslidentity.h" |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 36 | |
| 37 | namespace talk_base { |
| 38 | |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 39 | class SSLCertificate; |
| 40 | |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 41 | struct SSLFingerprint { |
| 42 | static SSLFingerprint* Create(const std::string& algorithm, |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 43 | const talk_base::SSLIdentity* identity); |
wu@webrtc.org | 62fe97f | 2013-10-09 15:37:36 +0000 | [diff] [blame] | 44 | |
| 45 | static SSLFingerprint* Create(const std::string& algorithm, |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 46 | const talk_base::SSLCertificate* cert); |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | |
| 48 | static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm, |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 49 | const std::string& fingerprint); |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 50 | |
| 51 | SSLFingerprint(const std::string& algorithm, const uint8* digest_in, |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 52 | size_t digest_len); |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 53 | |
sergeyu@chromium.org | f32dd31 | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 54 | SSLFingerprint(const SSLFingerprint& from); |
| 55 | |
| 56 | bool operator==(const SSLFingerprint& other) const; |
| 57 | |
| 58 | std::string GetRfc4572Fingerprint() const; |
| 59 | |
| 60 | std::string ToString(); |
henrike@webrtc.org | 0e118e7 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 61 | |
| 62 | std::string algorithm; |
| 63 | talk_base::Buffer digest; |
| 64 | }; |
| 65 | |
| 66 | } // namespace talk_base |
| 67 | |
| 68 | #endif // TALK_BASE_SSLFINGERPRINT_H_ |