"Fossies" - the Fresh Open Source Software Archive

Member "LinOTP-release-2.10.5.2/linotpd/src/linotp/lib/security/__init__.py" (13 May 2019, 3474 Bytes) of package /linux/misc/LinOTP-release-2.10.5.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "__init__.py" see the Fossies "Dox" file reference documentation.

    1 # -*- coding: utf-8 -*-
    2 #
    3 #    LinOTP - the open source solution for two factor authentication
    4 #    Copyright (C) 2010 - 2019 KeyIdentity GmbH
    5 #
    6 #    This file is part of LinOTP server.
    7 #
    8 #    This program is free software: you can redistribute it and/or
    9 #    modify it under the terms of the GNU Affero General Public
   10 #    License, version 3, as published by the Free Software Foundation.
   11 #
   12 #    This program is distributed in the hope that it will be useful,
   13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 #    GNU Affero General Public License for more details.
   16 #
   17 #    You should have received a copy of the
   18 #               GNU Affero General Public License
   19 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
   20 #
   21 #
   22 #    E-mail: linotp@keyidentity.com
   23 #    Contact: www.linotp.org
   24 #    Support: www.keyidentity.com
   25 #
   26 """module for SecurityModules / devices like hsms"""
   27 import logging
   28 log = logging.getLogger(__name__)
   29 
   30 
   31 class FatalHSMException(Exception):
   32     pass
   33 
   34 
   35 class SecurityModule(object):
   36 
   37     @classmethod
   38     def getAdditionalClassConfig(cls):
   39         return []
   40 
   41     def __init__(self, config=None, add_conf=None):
   42         self.name = "SecurityModule"
   43 
   44     def isReady(self):
   45         fname = 'isReady'
   46         raise NotImplementedError("Should have been implemented %s"
   47                                    % fname)
   48 
   49     def setup_module(self, params):
   50         fname = 'setup_module'
   51         raise NotImplementedError("Should have been implemented %s"
   52                                    % fname)
   53 
   54     ''' base methods '''
   55     def random(self, len):
   56         fname = 'random'
   57         raise NotImplementedError("Should have been implemented %s"
   58                                    % fname)
   59 
   60     def encrypt(self, value, iv=None, id=0):
   61         fname = 'encrypt'
   62         raise NotImplementedError("Should have been implemented %s"
   63                                    % fname)
   64 
   65     def decrypt(self, value, iv=None, id=0):
   66         fname = 'decrypt'
   67         raise NotImplementedError("Should have been implemented %s"
   68                                    % fname)
   69 
   70 
   71     ''' higer level methods '''
   72     def encryptPassword(self, cryptPass):
   73         fname = 'decrypt'
   74         raise NotImplementedError("Should have been implemented %s"
   75                                    % fname)
   76 
   77     def encryptPin(self, cryptPin, iv=None):
   78         fname = 'decrypt'
   79         raise NotImplementedError("Should have been implemented %s"
   80                                    % fname)
   81 
   82     def decryptPassword(self, cryptPass):
   83         fname = 'decrypt'
   84         raise NotImplementedError("Should have been implemented %s"
   85                                   % fname)
   86 
   87     def decryptPin(self, cryptPin):
   88         fname = 'decrypt'
   89         raise NotImplementedError("Should have been implemented %s"
   90                                   % fname)
   91 
   92     def signMessage(self, message, method=None, slot_id=3):
   93         fname = 'signMessage'
   94         raise NotImplementedError("Should have been implemented %s"
   95                                   % fname)
   96 
   97     def verfiyMessageSignature(self, message, hex_mac, method=None,
   98                                slot_id=3):
   99 
  100         fname = 'verfiyMessageSignature'
  101         raise NotImplementedError("Should have been implemented %s"
  102                                   % fname)
  103 
  104 # eof ########################################################################