diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-05-06 01:26:53 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-05-06 01:26:53 +0000 |
commit | 9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b (patch) | |
tree | 768763aa48be1a5a2c8dae7cba81859510f1146e /src/lib/tlslite/SharedKeyDB.py | |
parent | 13f6d1554dd24d08d44662906fa9f3f008a23058 (diff) | |
download | bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.tar.gz bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.tar.bz2 bcfg2-9590d0bb421cb7fdf7dd04d4b1d0d77e3f06f13b.zip |
more to python 2.6 ssl
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5187 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/tlslite/SharedKeyDB.py')
-rwxr-xr-x | src/lib/tlslite/SharedKeyDB.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/lib/tlslite/SharedKeyDB.py b/src/lib/tlslite/SharedKeyDB.py deleted file mode 100755 index 3246ec7f1..000000000 --- a/src/lib/tlslite/SharedKeyDB.py +++ /dev/null @@ -1,58 +0,0 @@ -"""Class for storing shared keys.""" - -from utils.cryptomath import * -from utils.compat import * -from mathtls import * -from Session import Session -from BaseDB import BaseDB - -class SharedKeyDB(BaseDB): - """This class represent an in-memory or on-disk database of shared - keys. - - A SharedKeyDB can be passed to a server handshake function to - authenticate a client based on one of the shared keys. - - This class is thread-safe. - """ - - def __init__(self, filename=None): - """Create a new SharedKeyDB. - - @type filename: str - @param filename: Filename for an on-disk database, or None for - an in-memory database. If the filename already exists, follow - this with a call to open(). To create a new on-disk database, - follow this with a call to create(). - """ - BaseDB.__init__(self, filename, "shared key") - - def _getItem(self, username, valueStr): - session = Session() - session._createSharedKey(username, valueStr) - return session - - def __setitem__(self, username, sharedKey): - """Add a shared key to the database. - - @type username: str - @param username: The username to associate the shared key with. - Must be less than or equal to 16 characters in length, and must - not already be in the database. - - @type sharedKey: str - @param sharedKey: The shared key to add. Must be less than 48 - characters in length. - """ - BaseDB.__setitem__(self, username, sharedKey) - - def _setItem(self, username, value): - if len(username)>16: - raise ValueError("username too long") - if len(value)>=48: - raise ValueError("shared key too long") - return value - - def _checkItem(self, value, username, param): - newSession = self._getItem(username, param) - return value.masterSecret == newSession.masterSecret
\ No newline at end of file |