IETF RFC 2617 - "HTTP Basic Access Authentication" data: ' . '
';
echo 'expected: ' . 'dXNlcmFyb246cGFzc2Fyb24=' . '
';
echo 'computed: ' . $basic_data . '
';
echo '
IETF RFC 2617 - "HTTP Digest Access Authentication" data: ' . '
';
echo 'expected: ' . 'b91e35f58b79f6662669aa59c0c3016f' . '
';
echo 'computed: ' . $digest_data . '
';
//citations from IETF RFC 2617
/*
standard:
http://www.ietf.org/rfc/rfc2617.txt
Basic Access Authentication Scheme
basic-credentials = base64-user-pass
base64-user-pass =
user-pass = userid ":" password
userid = *
password = *TEXT
Digest Access Authentication Scheme
challenge = "Digest" digest-challenge
digest-challenge = 1#( realm | [ domain ] | nonce |
[ opaque ] |[ stale ] | [ algorithm ] |
[ qop-options ] | [auth-param] )
domain = "domain" "=" <"> URI ( 1*SP URI ) <">
URI = absoluteURI | abs_path
nonce = "nonce" "=" nonce-value
nonce-value = quoted-string
opaque = "opaque" "=" quoted-string
stale = "stale" "=" ( "true" | "false" )
algorithm = "algorithm" "=" ( "MD5" | "MD5-sess" | token )
qop-options = "qop" "=" <"> 1#qop-value <">
qop-value = "auth" | "auth-int" | token
credentials = "Digest" digest-response
digest-response = 1#( username | realm | nonce | digest-uri
| response | [ algorithm ] | [cnonce] |
[opaque] | [message-qop] |
[nonce-count] | [auth-param] )
username = "username" "=" username-value
username-value = quoted-string
digest-uri = "uri" "=" digest-uri-value
digest-uri-value = request-uri ; As specified by HTTP/1.1
message-qop = "qop" "=" qop-value
cnonce = "cnonce" "=" cnonce-value
cnonce-value = nonce-value
nonce-count = "nc" "=" nc-value
nc-value = 8LHEX
response = "response" "=" request-digest
request-digest = <"> 32LHEX <">
LHEX = "0" | "1" | "2" | "3" |
"4" | "5" | "6" | "7" |
"8" | "9" | "a" | "b" |
"c" | "d" | "e" | "f"
test vector data:
Basic Access Authentication Scheme
GET /private-basic/ HTTP/1.1
HTTP/1.1 401 Authorization Required
WWW-Authenticate: Basic realm="private-basic"
GET /private-basic/ HTTP/1.1
Authorization: Basic dXNlcmFyb246cGFzc2Fyb24=
HTTP/1.1 200 OK
Digest Access Authentication Scheme
GET /private-digest/ HTTP/1.1
HTTP/1.1 401 Authorization Required
WWW-Authenticate: Digest realm="private-digest",
nonce="LhSMkgDTBAA=301b3524217a449e1e13ac45b7bda948f3ec2ee8",
algorithm=MD5,
qop="auth"
GET /private-digest/ HTTP/1.1
Authorization: Digest username="useraron",
realm="private-digest",
nonce="LhSMkgDTBAA=301b3524217a449e1e13ac45b7bda948f3ec2ee8",
uri="/private-digest/",
cnonce="10efaf6b429ac8902d29fc0dade2f0e3",
nc=00000001,
algorithm=MD5,
response="b91e35f58b79f6662669aa59c0c3016f",
qop="auth"
HTTP/1.1 200 OK
*/
?>