Пример #1
0
        public bool UpdateChallenge(ByteArrayPart nonce, ByteArrayPart opaque, ByteArrayPart qop)
        {
            lock (sync)
            {
                this.nonce  = nonce.DeepCopy();
                this.opaque = opaque.DeepCopy();
                this.qop    = qop.IsValid ? AuthQops.Auth : AuthQops.None;

                return(true);
            }
        }
        public static byte[] GetResponseHexChars(ByteArrayPart username, ByteArrayPart realm, AuthAlgorithms algorithm,
                                                 ByteArrayPart nonce, int cnonce, int nonceCount, ByteArrayPart password,
                                                 AuthQops qop, ByteArrayPart digestUri, ByteArrayPart method, ArraySegment <byte> body)
        {
            if (responseCalculator == null)
            {
                responseCalculator = new ResponseCalculator();
            }

            return(responseCalculator.GetResponseHexChars(username, realm, algorithm == AuthAlgorithms.Md5Sess, nonce,
                                                          cnonce, nonceCount, password, qop.ToByteArrayPart(), digestUri, method, body));
        }
Пример #3
0
        public static ByteArrayPart ToByteArrayPart(this AuthQops qop)
        {
            switch (qop)
            {
            case AuthQops.Auth:
                return(SipMessageWriter.C.auth);

            case AuthQops.AuthInt:
                return(SipMessageWriter.C.auth_int);

            default:
                throw new NotImplementedException();
            }
        }
Пример #4
0
 public byte[] GetDigestResponseHexChars(ByteArrayPart username, ByteArrayPart realm, AuthAlgorithms algorithm,
                                         ByteArrayPart nonce, int cnonce, int nonceCount, ByteArrayPart password,
                                         AuthQops qop, ByteArrayPart digestUri, Methods method, ArraySegment <byte> body)
 {
     return(response);
 }
Пример #5
0
        public void WriteDigestAuthorization(HeaderNames header, ByteArrayPart username, ByteArrayPart realm, AuthQops qop,
                                             AuthAlgorithms algorithm, ByteArrayPart uri, ByteArrayPart nonce, int nc, int cnonce, ByteArrayPart opaque, byte[] response)
        {
            if (header == HeaderNames.Authorization)
            {
                Write(C.Authorization);
            }
            else if (header == HeaderNames.ProxyAuthorization)
            {
                Write(C.Proxy_Authorization);
            }
            else
            {
                throw new ArgumentException(@"HeaderNames");
            }

            Write(C.__Digest_username__);
            Write(username);
            Write(C.___realm__);
            Write(realm);
            if (qop != AuthQops.None)
            {
                Write(C.___qop__);
                Write(qop.ToByteArrayPart());
            }
            else
            {
                Write(C.DQUOTE);
            }
            Write(C.__algorithm_);
            Write(algorithm.ToByteArrayPart());
            Write(C.__uri__);
            Write(uri);
            Write(C.___nonce__);
            Write(nonce);
            if (qop != AuthQops.None)
            {
                Write(C.__nc_);
                Write(nc);
                Write(C.__cnonce__);
                WriteAsHex8(cnonce);
            }
            Write(C.___opaque__);
            if (opaque.IsValid)
            {
                Write(opaque);
            }
            Write(C.___response__);
            Write(response);
            Write(C.DQUOTE);
            Write(C.CRLF);
        }
Пример #6
0
		public bool UpdateChallenge(ByteArrayPart nonce, ByteArrayPart opaque, ByteArrayPart qop)
		{
			lock (sync)
			{
				this.nonce = nonce.DeepCopy();
				this.opaque = opaque.DeepCopy();
				this.qop = qop.IsValid ? AuthQops.Auth : AuthQops.None;

				return true;
			}
		}
Пример #7
0
		public void WriteDigestAuthorization(HeaderNames header, ByteArrayPart username, ByteArrayPart realm, AuthQops qop,
			AuthAlgorithms algorithm, ByteArrayPart uri, ByteArrayPart nonce, int nc, int cnonce, ByteArrayPart opaque, byte[] response)
		{
			if (header == HeaderNames.Authorization)
				Write(C.Authorization);
			else if (header == HeaderNames.ProxyAuthorization)
				Write(C.Proxy_Authorization);
			else
				throw new ArgumentException(@"HeaderNames");

			Write(C.__Digest_username__);
			Write(username);
			Write(C.___realm__);
			Write(realm);
			if (qop != AuthQops.None)
			{
				Write(C.___qop__);
				Write(qop.ToByteArrayPart());
			}
			else
				Write(C.DQUOTE);
			Write(C.__algorithm_);
			Write(algorithm.ToByteArrayPart());
			Write(C.__uri__);
			Write(uri);
			Write(C.___nonce__);
			Write(nonce);
			if (qop != AuthQops.None)
			{
				Write(C.__nc_);
				Write(nc);
				Write(C.__cnonce__);
				WriteAsHex8(cnonce);
			}
			Write(C.___opaque__);
			if (opaque.IsValid)
				Write(opaque);
			Write(C.___response__);
			Write(response);
			Write(C.DQUOTE);
			Write(C.CRLF);
		}
Пример #8
0
		public byte[] GetDigestResponseHexChars(ByteArrayPart username, ByteArrayPart realm, AuthAlgorithms algorithm,
				ByteArrayPart nonce, int cnonce, int nonceCount, ByteArrayPart password,
				AuthQops qop, ByteArrayPart digestUri, Methods method, ArraySegment<byte> body)
		{
			return response;
		}