Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
2327c877
Commit
2327c877
authored
Mar 14, 2013
by
Albertas Agejevas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort out authentication hash str/bytes types.
parent
b863acd5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
src/ZEO/auth/auth_digest.py
src/ZEO/auth/auth_digest.py
+6
-5
src/ZEO/tests/auth_plaintext.py
src/ZEO/tests/auth_plaintext.py
+3
-2
src/ZEO/zrpc/smac.py
src/ZEO/zrpc/smac.py
+1
-1
No files found.
src/ZEO/auth/auth_digest.py
View file @
2327c877
...
...
@@ -48,12 +48,12 @@ from ZEO.hash import sha1
def
get_random_bytes
(
n
=
8
):
if
os
.
path
.
exists
(
"/dev/urandom"
):
f
=
open
(
"/dev/urandom"
,
'rb'
)
s
=
f
.
read
(
n
)
b
=
f
.
read
(
n
)
f
.
close
()
else
:
L
=
[
chr
(
random
.
randint
(
0
,
255
))
for
i
in
range
(
n
)]
s
=
""
.
join
(
L
)
return
s
b
=
b
""
.
join
(
L
)
return
b
def
hexdigest
(
s
):
return
sha1
(
s
.
encode
()).
hexdigest
()
...
...
@@ -76,7 +76,8 @@ def session_key(h_up, nonce):
# HMAC wants a 64-byte key. We don't want to use h_up
# directly because it would never change over time. Instead
# use the hash plus part of h_up.
return
sha1
(
"%s:%s"
%
(
h_up
,
nonce
)).
digest
()
+
h_up
[:
44
]
return
(
sha1
((
"%s:%s"
%
(
h_up
,
nonce
)).
encode
(
'latin-1'
)).
digest
()
+
h_up
.
encode
(
'utf-8'
)[:
44
])
class
StorageClass
(
ZEOStorage
):
def
set_database
(
self
,
database
):
...
...
@@ -93,7 +94,7 @@ class StorageClass(ZEOStorage):
# RFC 2069 recommends a nonce of the form
# H(client-IP ":" time-stamp ":" private-key)
dig
=
sha1
()
dig
.
update
(
str
(
self
.
connection
.
addr
))
dig
.
update
(
str
(
self
.
connection
.
addr
)
.
encode
(
'latin-1'
)
)
dig
.
update
(
self
.
_get_time
())
dig
.
update
(
self
.
noncekey
)
return
dig
.
hexdigest
()
...
...
src/ZEO/tests/auth_plaintext.py
View file @
2327c877
...
...
@@ -26,7 +26,8 @@ from ZEO.auth import register_module
from
ZEO.auth.base
import
Client
,
Database
def
session_key
(
username
,
realm
,
password
):
return
sha1
(
"%s:%s:%s"
%
(
username
,
realm
,
password
)).
hexdigest
()
key
=
"%s:%s:%s"
%
(
username
,
realm
,
password
)
return
sha1
(
key
.
encode
(
'utf-8'
)).
hexdigest
().
encode
(
'ascii'
)
class
StorageClass
(
ZEOStorage
):
...
...
@@ -36,7 +37,7 @@ class StorageClass(ZEOStorage):
except
LookupError
:
return
0
password_dig
=
sha1
(
password
).
hexdigest
()
password_dig
=
sha1
(
password
.
encode
(
'utf-8'
)
).
hexdigest
()
if
dbpw
==
password_dig
:
self
.
connection
.
setSessionKey
(
session_key
(
username
,
self
.
database
.
realm
,
...
...
src/ZEO/zrpc/smac.py
View file @
2327c877
...
...
@@ -147,7 +147,7 @@ class SizedMessageAsyncConnection(asyncore.dispatcher):
self
.
__hmac_send
=
hmac
.
HMAC
(
sesskey
,
digestmod
=
ZEO
.
hash
)
self
.
__hmac_recv
=
hmac
.
HMAC
(
sesskey
,
digestmod
=
ZEO
.
hash
)
if
False
:
yield
''
yield
b
''
self
.
message_output
(
hack
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment