00001 // This is part of tacppd (tacacs++) project 00002 // (c) Copyright in 2000-2004 by tacppd team and contributors 00003 // see http://tacppd.org for more information 00004 // 00005 // file: CryptoCard.h 00006 // description: CryptoCard support 00007 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 /* 00023 The CryptoCard code derived from code written by Alec Peterson <ahp@hilander.com> 00024 00025 The cryptocard code use libdes package with next copyright notice: 00026 00027 Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 00028 All rights reserved. 00029 00030 This package is an DES implementation written by Eric Young (eay@cryptsoft.com). 00031 The implementation was written so as to conform with MIT's libdes. 00032 00033 This library is free for commercial and non-commercial use as long as 00034 the following conditions are aheared to. The following conditions 00035 apply to all code found in this distribution. 00036 00037 Copyright remains Eric Young's, and as such any Copyright notices in 00038 the code are not to be removed. 00039 If this package is used in a product, Eric Young should be given attribution 00040 as the author of that the SSL library. This can be in the form of a textual 00041 message at program startup or in documentation (online or textual) provided 00042 with the package. 00043 00044 Redistribution and use in source and binary forms, with or without 00045 modification, are permitted provided that the following conditions 00046 are met: 00047 1. Redistributions of source code must retain the copyright 00048 notice, this list of conditions and the following disclaimer. 00049 2. Redistributions in binary form must reproduce the above copyright 00050 notice, this list of conditions and the following disclaimer in the 00051 documentation and/or other materials provided with the distribution. 00052 3. All advertising materials mentioning features or use of this software 00053 must display the following acknowledgement: 00054 This product includes software developed by Eric Young (eay@cryptsoft.com) 00055 00056 THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 00057 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00058 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00059 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00060 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00061 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00062 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00063 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00064 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00065 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00066 SUCH DAMAGE. 00067 00068 The license and distribution terms for any publically available version or 00069 derivative of this code cannot be changed. i.e. this code cannot simply be 00070 copied and put under another distrubution license 00071 [including the GNU Public License.] 00072 00073 The reason behind this being stated in this direct manner is past 00074 experience in code simply being copied and the attribution removed 00075 from it and then being distributed as part of other packages. This 00076 implementation was a non-trivial and unpaid effort. 00077 */ 00078 00079 // all comments which start from /** - this is comments for KDoc 00080 // for classes 00081 // @short [short description of the class] 00082 // @author [class author] 00083 // @version [class version] 00084 // @see [references to other classes or methods] 00085 // for methods 00086 // @see [references] 00087 // @return [sentence describing the return value] 00088 // @exception [list the exeptions that could be thrown] 00089 // @param [name id] [description] - can be multiple 00090 00091 #ifndef __CRYPTOCARD_H__ 00092 #define __CRYPTOCARD_H__ 00093 00094 #include "global.h" 00095 00096 namespace tacpp { 00097 00100 class CryptoCard { 00101 void swap(unsigned char*); 00102 int check_response(char*,char*,char*,int,char*); 00103 char *generate_response(char*,char*,char*); 00104 char *random_challenge(char*); 00105 public: 00106 int getchal(db_user,char*); // get challenge 00107 int checkresp(char*,char*,char*,char*); // check respond 00108 void store_nextchallenge(char*,char*); // store next challenge 00109 int crypt_key(char*,char*,int); 00110 // int cryptocard_fn(); 00111 }; 00112 00113 }; 00114 00115 #endif //__CRYPTOCARD_H__