KIO
ksslx509v3.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 2001 George Staikos <staikos@kde.org> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public License 00016 * along with this library; see the file COPYING.LIB. If not, write to 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 * Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include "ksslx509v3.h" 00022 00023 #include <config.h> 00024 #include <ksslconfig.h> 00025 00026 #include <kopenssl.h> 00027 #include <kdebug.h> 00028 00029 00030 KSSLX509V3::KSSLX509V3() { 00031 flags = 0; 00032 } 00033 00034 00035 KSSLX509V3::~KSSLX509V3() { 00036 } 00037 00038 00039 /* When reading this, please remember that 00040 * !A || B is logically equivalent to A => B 00041 */ 00042 00043 bool KSSLX509V3::certTypeCA() const { 00044 #ifdef KSSL_HAVE_SSL 00045 // First try CA without X509_PURPOSE_ANY CA, then just try SSLCA 00046 return (flags & (65471L << 16)) ? true : certTypeSSLCA(); 00047 #endif 00048 return false; 00049 } 00050 00051 00052 bool KSSLX509V3::certTypeSSLCA() const { 00053 #ifdef KSSL_HAVE_SSL 00054 return (flags & ((1 << (16+X509_PURPOSE_NS_SSL_SERVER-1))| 00055 (1 << (16+X509_PURPOSE_SSL_SERVER-1))| 00056 (1 << (16+X509_PURPOSE_SSL_CLIENT-1)))) ? true : 00057 ( certTypeSSLServer() || 00058 certTypeSSLClient() || 00059 certTypeNSSSLServer()); 00060 #endif 00061 return false; 00062 } 00063 00064 00065 bool KSSLX509V3::certTypeEmailCA() const { 00066 #ifdef KSSL_HAVE_SSL 00067 return (flags & ((1 << (16+X509_PURPOSE_SMIME_ENCRYPT-1))| 00068 (1 << (16+X509_PURPOSE_SMIME_SIGN-1)))) ? true : 00069 certTypeSMIME(); 00070 #endif 00071 return false; 00072 } 00073 00074 00075 bool KSSLX509V3::certTypeCodeCA() const { 00076 #ifdef KSSL_HAVE_SSL 00077 return (flags & (1 << (16+X509_PURPOSE_ANY-1))) ? true : false; 00078 #endif 00079 return false; 00080 } 00081 00082 00083 bool KSSLX509V3::certTypeSSLClient() const { 00084 #ifdef KSSL_HAVE_SSL 00085 return (flags & (1 << (X509_PURPOSE_SSL_CLIENT-1))) ? true : false; 00086 #endif 00087 return false; 00088 } 00089 00090 00091 bool KSSLX509V3::certTypeSSLServer() const { 00092 #ifdef KSSL_HAVE_SSL 00093 return (flags & (1 << (X509_PURPOSE_SSL_SERVER-1))) ? true : false; 00094 #endif 00095 return false; 00096 } 00097 00098 00099 bool KSSLX509V3::certTypeNSSSLServer() const { 00100 #ifdef KSSL_HAVE_SSL 00101 return (flags & (1 << (X509_PURPOSE_NS_SSL_SERVER-1))) ? true : false; 00102 #endif 00103 return false; 00104 } 00105 00106 00107 bool KSSLX509V3::certTypeSMIME() const { 00108 #ifdef KSSL_HAVE_SSL 00109 return certTypeSMIMEEncrypt()||certTypeSMIMESign(); 00110 #endif 00111 return false; 00112 } 00113 00114 00115 bool KSSLX509V3::certTypeSMIMEEncrypt() const { 00116 #ifdef KSSL_HAVE_SSL 00117 return (flags & (1 << (X509_PURPOSE_SMIME_ENCRYPT-1))) ? true : false; 00118 #endif 00119 return false; 00120 } 00121 00122 00123 bool KSSLX509V3::certTypeSMIMESign() const { 00124 #ifdef KSSL_HAVE_SSL 00125 return (flags & (1 << (X509_PURPOSE_SMIME_SIGN-1))) ? true : false; 00126 #endif 00127 return false; 00128 } 00129 00130 00131 bool KSSLX509V3::certTypeCRLSign() const { 00132 #ifdef KSSL_HAVE_SSL 00133 return (flags & (1 << (X509_PURPOSE_CRL_SIGN-1))) ? true : false; 00134 #endif 00135 return false; 00136 } 00137 00138 00139 00140 00141