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)); }
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(); } }
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); }
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); }
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 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); }
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; }