Home | History | Annotate | Download | only in base
      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 
     32 #include <string>
     33 
     34 #include "talk/base/buffer.h"
     35 #include "talk/base/sslidentity.h"
     36 
     37 namespace talk_base {
     38 
     39 class SSLCertificate;
     40 
     41 struct SSLFingerprint {
     42   static SSLFingerprint* Create(const std::string& algorithm,
     43                                 const talk_base::SSLIdentity* identity);
     44 
     45   static SSLFingerprint* Create(const std::string& algorithm,
     46                                 const talk_base::SSLCertificate* cert);
     47 
     48   static SSLFingerprint* CreateFromRfc4572(const std::string& algorithm,
     49                                            const std::string& fingerprint);
     50 
     51   SSLFingerprint(const std::string& algorithm, const uint8* digest_in,
     52                  size_t digest_len);
     53 
     54   SSLFingerprint(const SSLFingerprint& from);
     55 
     56   bool operator==(const SSLFingerprint& other) const;
     57 
     58   std::string GetRfc4572Fingerprint() const;
     59 
     60   std::string ToString();
     61 
     62   std::string algorithm;
     63   talk_base::Buffer digest;
     64 };
     65 
     66 }  // namespace talk_base
     67 
     68 #endif  // TALK_BASE_SSLFINGERPRINT_H_
     69