blob: a803d2129a7ad55a6c5bfb8cffb7cd1862f7253a [file] [log] [blame]
henrike@webrtc.org0e118e72013-07-10 00:45:36 +00001/*
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.org0e118e72013-07-10 00:45:36 +000032#include <string>
33
34#include "talk/base/buffer.h"
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000035#include "talk/base/sslidentity.h"
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000036
37namespace talk_base {
38
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000039class SSLCertificate;
40
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000041struct SSLFingerprint {
42 static SSLFingerprint* Create(const std::string& algorithm,
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000043 const talk_base::SSLIdentity* identity);
wu@webrtc.org62fe97f2013-10-09 15:37:36 +000044
45 static SSLFingerprint* Create(const std::string& algorithm,
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000046 const talk_base::SSLCertificate* cert);
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000047
48 static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm,
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000049 const std::string& fingerprint);
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000050
51 SSLFingerprint(const std::string& algorithm, const uint8* digest_in,
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000052 size_t digest_len);
henrike@webrtc.org0e118e72013-07-10 00:45:36 +000053
sergeyu@chromium.orgf32dd312014-01-15 23:15:54 +000054 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.org0e118e72013-07-10 00:45:36 +000061
62 std::string algorithm;
63 talk_base::Buffer digest;
64};
65
66} // namespace talk_base
67
68#endif // TALK_BASE_SSLFINGERPRINT_H_