Skip to content

Commit fe0a531

Browse files
author
Kevin Turner
committed
[project @ association: add HMAC-SHA1-SIGNALL to list of recognized association types]
1 parent 1782432 commit fe0a531

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

‎openid/association.py‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,52 @@
1111
from openid import oidutil
1212
from openid.message import OPENID_NS
1313

14-
all_association_types = ['HMAC-SHA1', 'HMAC-SHA256-SIGNALL']
14+
all_association_types = [
15+
'HMAC-SHA1',
16+
'HMAC-SHA1-SIGNALL',
17+
'HMAC-SHA256-SIGNALL',
18+
]
19+
1520
if hasattr(cryptutil, 'hmacSha256'):
1621
supported_association_types = list(all_association_types)
1722

1823
default_association_order = [
1924
('HMAC-SHA1', 'DH-SHA1'),
25+
('HMAC-SHA1-SIGNALL', 'DH-SHA1'),
2026
('HMAC-SHA256-SIGNALL', 'DH-SHA256'),
2127
('HMAC-SHA1', 'no-encryption'),
28+
('HMAC-SHA1-SIGNALL', 'no-encryption'),
2229
('HMAC-SHA256-SIGNALL', 'no-encryption'),
2330
]
2431

2532
only_encrypted_association_order = [
2633
('HMAC-SHA1', 'DH-SHA1'),
34+
('HMAC-SHA1-SIGNALL', 'DH-SHA1'),
2735
('HMAC-SHA256-SIGNALL', 'DH-SHA256'),
2836
]
2937
else:
3038
supported_association_types = ['HMAC-SHA1']
3139

3240
default_association_order = [
3341
('HMAC-SHA1', 'DH-SHA1'),
42+
('HMAC-SHA1-SIGNALL', 'DH-SHA1'),
3443
('HMAC-SHA1', 'no-encryption'),
44+
('HMAC-SHA1-SIGNALL', 'no-encryption'),
3545
]
3646

3747
only_encrypted_association_order = [
3848
('HMAC-SHA1', 'DH-SHA1'),
49+
('HMAC-SHA1-SIGNALL', 'DH-SHA1'),
3950
]
4051

4152
def getSessionTypes(assoc_type):
4253
"""Return the allowed session types for a given association type"""
43-
if assoc_type == 'HMAC-SHA1':
44-
return ['DH-SHA1', 'no-encryption']
45-
elif assoc_type == 'HMAC-SHA256-SIGNALL':
46-
return ['DH-SHA256', 'no-encryption']
47-
else:
48-
return []
54+
assoc_to_session = {
55+
'HMAC-SHA1': ['DH-SHA1', 'no-encryption'],
56+
'HMAC-SHA256-SIGNALL': ['DH-SHA256', 'no-encryption'],
57+
}
58+
assoc_to_session['HMAC-SHA1-SIGNALL'] = assoc_to_session['HMAC-SHA1']
59+
return assoc_to_session.get(assoc_type, [])
4960

5061
def checkSessionType(assoc_type, session_type):
5162
"""Check to make sure that this pair of assoc type and session
@@ -105,7 +116,7 @@ def getAllowedType(self):
105116
encrypted_negotiator = SessionNegotiator(only_encrypted_association_order)
106117

107118
def getSecretSize(assoc_type):
108-
if assoc_type == 'HMAC-SHA1':
119+
if assoc_type in ('HMAC-SHA1', 'HMAC-SHA1-SIGNALL'):
109120
return 20
110121
elif assoc_type == 'HMAC-SHA256-SIGNALL':
111122
return 32

0 commit comments

Comments
 (0)