Source code for linotp.lib.security

# -*- coding: utf-8 -*-
#
#    LinOTP - the open source solution for two factor authentication
#    Copyright (C) 2010 - 2017 KeyIdentity GmbH
#
#    This file is part of LinOTP server.
#
#    This program is free software: you can redistribute it and/or
#    modify it under the terms of the GNU Affero General Public
#    License, version 3, as published by the Free Software Foundation.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the
#               GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#
#    E-mail: linotp@keyidentity.com
#    Contact: www.linotp.org
#    Support: www.keyidentity.com
#
"""module for SecurityModules / devices like hsms"""
import logging
log = logging.getLogger(__name__)


[docs]class FatalHSMException(Exception): pass
[docs]class SecurityModule(object): @classmethod
[docs] def getAdditionalClassConfig(cls): return []
def __init__(self, config=None, add_conf=None): self.name = "SecurityModule"
[docs] def isReady(self): fname = 'isReady' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def setup_module(self, params): fname = 'setup_module' raise NotImplementedError("Should have been implemented %s" % fname)
''' base methods '''
[docs] def random(self, len): fname = 'random' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def encrypt(self, value, iv=None, id=0): fname = 'encrypt' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def decrypt(self, value, iv=None, id=0): fname = 'decrypt' raise NotImplementedError("Should have been implemented %s" % fname)
''' higer level methods '''
[docs] def encryptPassword(self, cryptPass): fname = 'decrypt' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def encryptPin(self, cryptPin, iv=None): fname = 'decrypt' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def decryptPassword(self, cryptPass): fname = 'decrypt' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def decryptPin(self, cryptPin): fname = 'decrypt' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def signMessage(self, message, method=None, slot_id=3): fname = 'signMessage' raise NotImplementedError("Should have been implemented %s" % fname)
[docs] def verfiyMessageSignature(self, message, hex_mac, method=None, slot_id=3): fname = 'verfiyMessageSignature' raise NotImplementedError("Should have been implemented %s" % fname) # eof ########################################################################

Table Of Contents