📘
Deuterium Wiki
  • Hello
  • Linux
    • cmd
      • du: 显式文件大小
      • seq: 生成序列
      • cat: 连接
      • cp: 复制
      • cd: 切换目录
      • mv: 移动
    • awk
      • 执行awk脚本
      • 删除空行
      • 个数统计
      • 文件的交集
      • 文件的差集
    • mysql
      • 删除重复数据
      • 导出数据不带标题
  • Reading
    • Novel
      • 《基督山伯爵》人物关系
    • Awesome CS Books
      • csapp-3e-homework-solution
        • 1. A Tour of Computer Systems
        • 2. Representing and Manipulating Information
          • 2.55 Compile and Run
          • 2.56 Another Try
          • 2.57 More show Procedures
          • 2.58 Check Little-Endian
          • 2.59 Bit Expressions
          • 2.60 Replace Byte
          • 2.61 More Bit Expressions
          • 2.62 Check Arithmetic Right Shift
          • 2.63 Logic & Arithmetic Right Shift
          • 2.64 Any Odd One
          • 2.65 Odd Ones
          • 2.66 Leftmost One
          • 2.67 Int Size is 32
          • 2.68 Lower One Mask
          • 2.69 Rotate Left
          • 2.70 Fits Bits
          • 2.71 Xbyte
          • 2.72 Copy Int
          • 2.73 Saturating Add
          • 2.74 Sub OK
          • 2.75 Unsigned High Prod
          • 2.76 calloc
          • 2.77 Multiple By Shifts
          • 2.78 Divide Power 2
          • 2.79 Mul3div4
          • 2.80 Three Fourths
          • 2.81 Generate Bits
          • 2.82 Signed and Unsigned
          • 2.83 Binary Floating Value
          • 2.84 Float Le
          • 2.85 Floating Point I
          • 2.86 Extend Precision
          • 2.87 Floating-Point II
          • 2.88 Floating-Point III
          • 2.89 Floating-Point IV
          • 2.90 fpwr2
          • 2.91 π
          • 2.92 Float Negate
          • 2.93 Float Absval
          • 2.94 Float Twice
          • 2.95 Float Half
          • 2.96 Float f2i
          • 2.97 Float i2f
        • 3. Machine-Level Representation of Programs
          • 3.58 Decode
          • 3.59 128-bit Multiply
          • 3.60 For Loop
          • 3.61 Conditional Data Transfer
          • 3.62 Switch I
          • 3.63 Switch II
          • 3.64 Multiple Dimension Array I
          • 3.65 Multiple Dimension Array II
          • 3.66 Multiple Dimension Array III
          • 3.67 Caller and Callee
          • 3.68 Alignment
          • 3.69 Struct
          • 3.70 Union
          • 3.71 fgets
          • 3.72 Variable-Size Stack
          • 3.73 Find Range I
          • 3.74 Find Range II
          • 3.75 Complex
      • tcpv1
        • ch01: Introduction
        • ch02: Link Layer
        • ch03: Internet Protocol
        • ch04: Address Resolutin Protocol
        • ch05: Reverse Address Resolution Protocol
        • ch06: Internet Control Message Protocol
        • ch07: Ping Program
        • ch08: Traceroute Program
        • ch09: IP Routing
        • ch10: Dynamic Routing Protocols
        • ch11: User Datagram Protocol
        • ch12: Broadcasting and Multicasting
        • ch13: Internet Group Management Protocol
        • ch14: The Domain Name System
        • ch15: Trivial File Transfer Protocol
        • ch16: Boostrap Protocol
        • ch17: Transmission Control Protocol
        • ch18: TCP Connection Establishment and Termination
        • ch 19: TCP Interactive Data Flow
        • ch20: TCP Bulk Data Flow
      • http
        • ch01: Overview of HTTP
        • ch02: URLs and Resources
        • ch03: HTTP Messages
        • ch04: Connection Management
        • ch05: Web Servers
        • ch06: Proxies
        • ch07: Caching
        • ch08: Integration Points
        • ch09: Web Robots
        • ch10: HTTP-NG
        • ch11: Client Identification and Cookies
        • ch12: Basic Authentication
        • ch13: Digest Authentication
        • ch14: Secure HTTP
        • ch15: Entities and Encodings
        • ch16: Internationalizated
        • ch17: Content Negotiation and Transcoding
        • ch18: Web Hosting
        • ch19: Publishing Systems
        • ch20: Redirections and Load Balancing
        • ch21: Logging and Usage Tracking
    • 提升认知
      • 《为什么需要生物学思维》
      • 《大话西方艺术史》
  • Mathematics
Powered by GitBook
On this page
  • 1. The Improvements of Digest Authentication
  • 1.1 Using Digests to Keep Passords Secret
  • 1.2 One-Way Digests
  • 1.3 Using Nonces to Prevent Replays
  • 1.4 The Digest Authentication Handshake
  • 2. Digest Calculations
  • 2.1 Digest Algorithm Input Data
  • 2.2 The Algorithms H(d) and KD(s, d)
  • 2.3 The Security-Related Data (A1)
  • 2.4 The Message-Related Data (A2)
  • 2.5 Overall Digest Algorithm
  • 2.6 Preemptive Authorization
  • 2.7 Nonce Selection
  • 2.8 Symmetric Authentication
  • 3. Quality of Protection Enhancements
  • 4. Practical Considerations
  • 4.1 Multiple Challenges
  • 4.2 Error Handling
  • 4.3 Rewriting URIs
  • 4.4 Caches

Was this helpful?

  1. Reading
  2. Awesome CS Books
  3. http

ch13: Digest Authentication

Previousch12: Basic AuthenticationNextch14: Secure HTTP

Last updated 4 years ago

Was this helpful?

13.摘要认证

1. The Improvements of Digest Authentication

Digest authentication has not been widely deployed.

Use HTTPS instead.

1.1 Using Digests to Keep Passords Secret

"Never send the password across the network", use digest of the password instead.

1.2 One-Way Digests

A digest is a "condensation of a body of information".

Digests act as one-way function.

1.3 Using Nonces to Prevent Replays

To prevent replay attacks, the server can pass along to the client a special token called a nonce.

The client appends this nonce token to the password before computing the digest.

This prevent the replay attack.

1.4 The Digest Authentication Handshake

A simplified three-phase handshake of digest authentication:

2. Digest Calculations

2.1 Digest Algorithm Input Data

  • A pair of functions consisting of a one-way hash function H(d) and digest KD(s, d), where s stands for secret and d stands for data.

  • A chunk of data containing security information, including the secret password, called A1.

  • A chunk of data containing nonsecret attributes of the request message, called A2.

The two pieces of data, A1 and A2, are processed by H and KD to yield a digest.

2.2 The Algorithms H(d) and KD(s, d)

Digest algorithms: MD5 (default) and MD5-sess.

H(<data>) = MD5(<data>)
KD(<secret>, <data>) = H(concatenate(<secret>:<data>))

2.3 The Security-Related Data (A1)

The chunk of data called A1 is a product of secret and protection information, such as the username, password, protection realm, and nonces.

Algorithms:

Algorithm

A1

MD5

A1 = <user>:<realm>:<password>

MD5-sess

A1 = MD5(<user>:<realm>:<password>):<nonce>:<cnonce>

2.4 The Message-Related Data (A2)

The chunk of data called A2 represents information about the message itself, such as the URL, request method, and message entity body.

A2 is used to help protect against method, resource, or message tampering.

Quality of protection (qop):

qop

A2

undefined

<request-method>:<uri-directive-value>

auth

<request-method>:<uri-directive-value>

auth-int

<request-method>:<uri-directive-value>:H(<request-entity-body>)

2.5 Overall Digest Algorithm

qop=auth or auth-int:

KD(H(A1), <nonce>:<nc>:<cnonce>:<qop>:H(A2))

2.6 Preemptive Authorization

In normal authentication, each request requires a request/challenge cycle before the transaction can be completed, this is depicted in Figure 13-4a.

This request/challenge cycle can be eliminated if the client knows in advance what the next nonce will be, so it can generate the correct Authorization header before the server asks for it. This is depicted in Figure 13-4b.

2.6.1 Next nonce pregeneration

The next nonce value can be provided in advance to the client:

Authentication-Info: nextnonce="<nonce-value>"

2.6.2 Limited nonce reuse

Instead of pregenerating a sequence of nonces, another approach is to allow limited reuse of nonces.

For example, a server may allow a nonce to be reused 5 times, or for 10 seconds.

If a nonce finally expires, the server returns 401:

WWW-Authenticate: Digest
    realm="<realm-value>"
    nonce="<nonce-value>"
    stale=true

with stale=true.

2.7 Nonce Selection

Suggested:

BASE64(time-stamp H(time-stamp ":" ETag ":" private-key))

2.8 Symmetric Authentication

The client can also authenticate the server.

3. Quality of Protection Enhancements

The qop field may be present in all three digest headers: WWW-Authenticate, Authorization, and Authentication-Info.

4. Practical Considerations

4.1 Multiple Challenges

If a server does not know the capabilities of a client, it may provide both basic and digest authentication callenges.

When faced with multiple challenges, the client must choose to answer with the strongest authentication mechanism that it supports.

4.2 Error Handling

In digest authentication, if a directive or its value is improper, or if a required directive is missing, the proper response is 400 Bad Request.

4.3 Rewriting URIs

Proxies may rewrite URIs in ways that change the URI syntax but not the aatcual resource being described.

Digest authentication sanity checks the integrity of the URI value, the digest authentication will break if any of these changes are made.

4.4 Caches

When a shared cache receives a request containing an Authorization header and a response from relaying that request, it must not return that response as a reply to any other request, unless one of two Cache-Control directives was present in the response:

  • must-revalidate

  • public