| OLD | NEW |
| 1 """Class for storing shared keys.""" | 1 """Class for storing shared keys.""" |
| 2 | 2 |
| 3 from utils.cryptomath import * | 3 from utils.cryptomath import * |
| 4 from utils.compat import * | 4 from utils.compat import * |
| 5 from mathtls import * | 5 from mathtls import * |
| 6 from Session import Session | 6 from session import Session |
| 7 from BaseDB import BaseDB | 7 from basedb import BaseDB |
| 8 | 8 |
| 9 class SharedKeyDB(BaseDB): | 9 class SharedKeyDB(BaseDB): |
| 10 """This class represent an in-memory or on-disk database of shared | 10 """This class represent an in-memory or on-disk database of shared |
| 11 keys. | 11 keys. |
| 12 | 12 |
| 13 A SharedKeyDB can be passed to a server handshake function to | 13 A SharedKeyDB can be passed to a server handshake function to |
| 14 authenticate a client based on one of the shared keys. | 14 authenticate a client based on one of the shared keys. |
| 15 | 15 |
| 16 This class is thread-safe. | 16 This class is thread-safe. |
| 17 """ | 17 """ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 def _setItem(self, username, value): | 49 def _setItem(self, username, value): |
| 50 if len(username)>16: | 50 if len(username)>16: |
| 51 raise ValueError("username too long") | 51 raise ValueError("username too long") |
| 52 if len(value)>=48: | 52 if len(value)>=48: |
| 53 raise ValueError("shared key too long") | 53 raise ValueError("shared key too long") |
| 54 return value | 54 return value |
| 55 | 55 |
| 56 def _checkItem(self, value, username, param): | 56 def _checkItem(self, value, username, param): |
| 57 newSession = self._getItem(username, param) | 57 newSession = self._getItem(username, param) |
| 58 return value.masterSecret == newSession.masterSecret | 58 return value.masterSecret == newSession.masterSecret |
| OLD | NEW |