tdecryptographiccarddevice.h
00001 /* This file is part of the TDE libraries 00002 Copyright (C) 2015 Timothy Pearson <kb9vqf@pearsoncomputing.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef _TDECRYPTOGRAPHICCARDDEVICE_H 00020 #define _TDECRYPTOGRAPHICCARDDEVICE_H 00021 00022 #include "ksslconfig.h" 00023 #include "tdegenericdevice.h" 00024 00025 #ifndef _TDECRYPTOGRAPHICCARDDEVICE_INTERNAL 00026 #ifdef KSSL_HAVE_SSL 00027 typedef struct x509_st X509; 00028 #else 00029 struct X509; 00030 #endif 00031 #endif 00032 00033 class TQEventLoopThread; 00034 class CryptoCardDeviceWatcher; 00035 00036 typedef TQValueList<X509*> X509CertificatePtrList; 00037 typedef TQValueListIterator<X509*> X509CertificatePtrListIterator; 00038 00039 class TDECORE_EXPORT TDECryptographicCardDevice : public TDEGenericDevice 00040 { 00041 Q_OBJECT 00042 00043 public: 00048 TDECryptographicCardDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn=TQString::null); 00049 00053 ~TDECryptographicCardDevice(); 00054 00059 void enableCardMonitoring(bool enable); 00060 00073 void enablePINEntryCallbacks(bool enable); 00074 00081 int cardPresent(); 00082 00088 TQString cardATR(); 00089 00098 X509CertificatePtrList cardX509Certificates(); 00099 00107 void setProvidedPin(TQString pin); 00108 00117 TQString autoPIN(); 00118 00130 int decryptDataEncryptedWithCertPublicKey(TQByteArray &ciphertext, TQByteArray &plaintext, TQString *errstr=NULL); 00131 00144 int decryptDataEncryptedWithCertPublicKey(TQValueList<TQByteArray> &cipherTextList, TQValueList<TQByteArray> &plainTextList, TQValueList<int> &retcodes, TQString *errstr); 00145 00154 static int createNewSecretRSAKeyFromCertificate(TQByteArray &plaintext, TQByteArray &ciphertext, X509* certificate); 00155 00159 static TQString pkcsProviderLibrary(); 00160 00161 public slots: 00162 void cardStatusChanged(TQString status, TQString atr); 00163 void workerRequestedPin(TQString prompt); 00164 00165 signals: 00166 void cardInserted(TDECryptographicCardDevice*); 00167 void cardRemoved(TDECryptographicCardDevice*); 00168 void certificateListAvailable(TDECryptographicCardDevice*); 00169 void pinRequested(TQString prompt, TDECryptographicCardDevice* cdevice); 00170 00171 private: 00172 TQEventLoopThread *m_watcherThread; 00173 CryptoCardDeviceWatcher *m_watcherObject; 00174 00175 bool m_cardPresent; 00176 TQString m_cardATR; 00177 X509CertificatePtrList m_cardCertificates; 00178 00179 friend class TDEHardwareDevices; 00180 friend class CryptoCardDeviceWatcher; 00181 }; 00182 00183 #endif // _TDECRYPTOGRAPHICCARDDEVICE_H
Trinity API Reference