Exemplo n.º 1
0
 public void SetDefaultValue(int index)
 {
     this.AuthScheme    = AuthSchemes.None;
     this.AuthAlgorithm = AuthAlgorithms.None;
     this.Qop.SetDefaultValue(index);
     this.Nonce.SetDefaultValue(index);
     this.Realm.SetDefaultValue(index);
     this.Opaque.SetDefaultValue(index);
     this.Stale = false;
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
public void SetDefaultValue()
{
AuthScheme = AuthSchemes.None;
AuthAlgorithm = AuthAlgorithms.None;
NonceCountBytes.SetDefaultValue();
MessageQop.SetDefaultValue();
DigestUri.SetDefaultValue();
Nonce.SetDefaultValue();
Realm.SetDefaultValue();
Cnonce.SetDefaultValue();
Opaque.SetDefaultValue();
Response.SetDefaultValue();
Username.SetDefaultValue();
NonceCount = int.MinValue;
HasResponse = false;
OnSetDefaultValue();
}
Exemplo n.º 4
0
        public static ByteArrayPart ToByteArrayPart(this AuthAlgorithms algorithm)
        {
            switch (algorithm)
            {
            case AuthAlgorithms.None:
            case AuthAlgorithms.Other:
                throw new ArgumentException();

            case AuthAlgorithms.Md5:
                return(SipMessageWriter.C.MD5);

            case AuthAlgorithms.Md5Sess:
                return(SipMessageWriter.C.MD5_sess);

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 5
0
 public void SetDefaultValue(int index)
 {
     this.AuthScheme    = AuthSchemes.None;
     this.AuthAlgorithm = AuthAlgorithms.None;
     this.NonceCountBytes.SetDefaultValue(index);
     this.MessageQop.SetDefaultValue(index);
     this.DigestUri.SetDefaultValue(index);
     this.Realm.SetDefaultValue(index);
     this.Opaque.SetDefaultValue(index);
     this.Nonce.SetDefaultValue(index);
     this.Cnonce.SetDefaultValue(index);
     this.Response.SetDefaultValue(index);
     this.Username.SetDefaultValue(index);
     this.Targetname.SetDefaultValue(index);
     this.GssapiData.SetDefaultValue(index);
     this.NonceCount    = -2147483648;
     this.Cnum          = -2147483648;
     this.Crand         = -2147483648;
     this.Version       = -2147483648;
     this.HasResponse   = false;
     this.HasGssapiData = false;
 }
        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));
        }
Exemplo n.º 7
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);
 }
Exemplo n.º 8
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);
		}
Exemplo n.º 9
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;
		}