netwerk/protocol/http/nsHttpDigestAuth.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsDigestAuth_h__
michael@0 8 #define nsDigestAuth_h__
michael@0 9
michael@0 10 #include "nsIHttpAuthenticator.h"
michael@0 11 #include "nsStringFwd.h"
michael@0 12 #include "nsCOMPtr.h"
michael@0 13 #include "mozilla/Attributes.h"
michael@0 14
michael@0 15 class nsICryptoHash;
michael@0 16
michael@0 17 namespace mozilla { namespace net {
michael@0 18
michael@0 19 #define ALGO_SPECIFIED 0x01
michael@0 20 #define ALGO_MD5 0x02
michael@0 21 #define ALGO_MD5_SESS 0x04
michael@0 22 #define QOP_AUTH 0x01
michael@0 23 #define QOP_AUTH_INT 0x02
michael@0 24
michael@0 25 #define DIGEST_LENGTH 16
michael@0 26 #define EXPANDED_DIGEST_LENGTH 32
michael@0 27 #define NONCE_COUNT_LENGTH 8
michael@0 28
michael@0 29 //-----------------------------------------------------------------------------
michael@0 30 // nsHttpDigestAuth
michael@0 31 //-----------------------------------------------------------------------------
michael@0 32
michael@0 33 class nsHttpDigestAuth MOZ_FINAL : public nsIHttpAuthenticator
michael@0 34 {
michael@0 35 public:
michael@0 36 NS_DECL_ISUPPORTS
michael@0 37 NS_DECL_NSIHTTPAUTHENTICATOR
michael@0 38
michael@0 39 nsHttpDigestAuth();
michael@0 40 ~nsHttpDigestAuth();
michael@0 41
michael@0 42 protected:
michael@0 43 nsresult ExpandToHex(const char * digest, char * result);
michael@0 44
michael@0 45 nsresult CalculateResponse(const char * ha1_digest,
michael@0 46 const char * ha2_digest,
michael@0 47 const nsAFlatCString & nonce,
michael@0 48 uint16_t qop,
michael@0 49 const char * nonce_count,
michael@0 50 const nsAFlatCString & cnonce,
michael@0 51 char * result);
michael@0 52
michael@0 53 nsresult CalculateHA1(const nsAFlatCString & username,
michael@0 54 const nsAFlatCString & password,
michael@0 55 const nsAFlatCString & realm,
michael@0 56 uint16_t algorithm,
michael@0 57 const nsAFlatCString & nonce,
michael@0 58 const nsAFlatCString & cnonce,
michael@0 59 char * result);
michael@0 60
michael@0 61 nsresult CalculateHA2(const nsAFlatCString & http_method,
michael@0 62 const nsAFlatCString & http_uri_path,
michael@0 63 uint16_t qop,
michael@0 64 const char * body_digest,
michael@0 65 char * result);
michael@0 66
michael@0 67 nsresult ParseChallenge(const char * challenge,
michael@0 68 nsACString & realm,
michael@0 69 nsACString & domain,
michael@0 70 nsACString & nonce,
michael@0 71 nsACString & opaque,
michael@0 72 bool * stale,
michael@0 73 uint16_t * algorithm,
michael@0 74 uint16_t * qop);
michael@0 75
michael@0 76 // result is in mHashBuf
michael@0 77 nsresult MD5Hash(const char *buf, uint32_t len);
michael@0 78
michael@0 79 nsresult GetMethodAndPath(nsIHttpAuthenticableChannel *,
michael@0 80 bool, nsCString &, nsCString &);
michael@0 81
michael@0 82 // append the quoted version of value to aHeaderLine
michael@0 83 nsresult AppendQuotedString(const nsACString & value,
michael@0 84 nsACString & aHeaderLine);
michael@0 85
michael@0 86 protected:
michael@0 87 nsCOMPtr<nsICryptoHash> mVerifier;
michael@0 88 char mHashBuf[DIGEST_LENGTH];
michael@0 89 };
michael@0 90
michael@0 91 }} // namespace mozilla::net
michael@0 92
michael@0 93 #endif // nsHttpDigestAuth_h__

mercurial