|
11 | 11 | from openid import oidutil |
12 | 12 | from openid.message import OPENID_NS |
13 | 13 |
|
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 | + |
15 | 20 | if hasattr(cryptutil, 'hmacSha256'): |
16 | 21 | supported_association_types = list(all_association_types) |
17 | 22 |
|
18 | 23 | default_association_order = [ |
19 | 24 | ('HMAC-SHA1', 'DH-SHA1'), |
| 25 | + ('HMAC-SHA1-SIGNALL', 'DH-SHA1'), |
20 | 26 | ('HMAC-SHA256-SIGNALL', 'DH-SHA256'), |
21 | 27 | ('HMAC-SHA1', 'no-encryption'), |
| 28 | + ('HMAC-SHA1-SIGNALL', 'no-encryption'), |
22 | 29 | ('HMAC-SHA256-SIGNALL', 'no-encryption'), |
23 | 30 | ] |
24 | 31 |
|
25 | 32 | only_encrypted_association_order = [ |
26 | 33 | ('HMAC-SHA1', 'DH-SHA1'), |
| 34 | + ('HMAC-SHA1-SIGNALL', 'DH-SHA1'), |
27 | 35 | ('HMAC-SHA256-SIGNALL', 'DH-SHA256'), |
28 | 36 | ] |
29 | 37 | else: |
30 | 38 | supported_association_types = ['HMAC-SHA1'] |
31 | 39 |
|
32 | 40 | default_association_order = [ |
33 | 41 | ('HMAC-SHA1', 'DH-SHA1'), |
| 42 | + ('HMAC-SHA1-SIGNALL', 'DH-SHA1'), |
34 | 43 | ('HMAC-SHA1', 'no-encryption'), |
| 44 | + ('HMAC-SHA1-SIGNALL', 'no-encryption'), |
35 | 45 | ] |
36 | 46 |
|
37 | 47 | only_encrypted_association_order = [ |
38 | 48 | ('HMAC-SHA1', 'DH-SHA1'), |
| 49 | + ('HMAC-SHA1-SIGNALL', 'DH-SHA1'), |
39 | 50 | ] |
40 | 51 |
|
41 | 52 | def getSessionTypes(assoc_type): |
42 | 53 | """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, []) |
49 | 60 |
|
50 | 61 | def checkSessionType(assoc_type, session_type): |
51 | 62 | """Check to make sure that this pair of assoc type and session |
@@ -105,7 +116,7 @@ def getAllowedType(self): |
105 | 116 | encrypted_negotiator = SessionNegotiator(only_encrypted_association_order) |
106 | 117 |
|
107 | 118 | def getSecretSize(assoc_type): |
108 | | - if assoc_type == 'HMAC-SHA1': |
| 119 | + if assoc_type in ('HMAC-SHA1', 'HMAC-SHA1-SIGNALL'): |
109 | 120 | return 20 |
110 | 121 | elif assoc_type == 'HMAC-SHA256-SIGNALL': |
111 | 122 | return 32 |
|
0 commit comments