File indexing completed on 2024-04-21 14:56:09
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 2001 George Staikos <staikos@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "ksslx509v3.h" 0022 0023 #include <ksslconfig.h> 0024 0025 #include <kopenssl.h> 0026 0027 KSSLX509V3::KSSLX509V3() 0028 { 0029 flags = 0; 0030 } 0031 0032 KSSLX509V3::~KSSLX509V3() 0033 { 0034 } 0035 0036 /* When reading this, please remember that 0037 * !A || B is logically equivalent to A => B 0038 */ 0039 0040 bool KSSLX509V3::certTypeCA() const 0041 { 0042 #if KSSL_HAVE_SSL 0043 // First try CA without X509_PURPOSE_ANY CA, then just try SSLCA 0044 return (flags & (65471L << 16)) ? true : certTypeSSLCA(); 0045 #endif 0046 return false; 0047 } 0048 0049 bool KSSLX509V3::certTypeSSLCA() const 0050 { 0051 #if KSSL_HAVE_SSL 0052 return (flags & ((1 << (16 + X509_PURPOSE_NS_SSL_SERVER - 1)) | 0053 (1 << (16 + X509_PURPOSE_SSL_SERVER - 1)) | 0054 (1 << (16 + X509_PURPOSE_SSL_CLIENT - 1)))) ? true : 0055 (certTypeSSLServer() || 0056 certTypeSSLClient() || 0057 certTypeNSSSLServer()); 0058 #endif 0059 return false; 0060 } 0061 0062 bool KSSLX509V3::certTypeEmailCA() const 0063 { 0064 #if KSSL_HAVE_SSL 0065 return (flags & ((1 << (16 + X509_PURPOSE_SMIME_ENCRYPT - 1)) | 0066 (1 << (16 + X509_PURPOSE_SMIME_SIGN - 1)))) ? true : 0067 certTypeSMIME(); 0068 #endif 0069 return false; 0070 } 0071 0072 bool KSSLX509V3::certTypeCodeCA() const 0073 { 0074 #if KSSL_HAVE_SSL 0075 return (flags & (1 << (16 + X509_PURPOSE_ANY - 1))) ? true : false; 0076 #endif 0077 return false; 0078 } 0079 0080 bool KSSLX509V3::certTypeSSLClient() const 0081 { 0082 #if KSSL_HAVE_SSL 0083 return (flags & (1 << (X509_PURPOSE_SSL_CLIENT - 1))) ? true : false; 0084 #endif 0085 return false; 0086 } 0087 0088 bool KSSLX509V3::certTypeSSLServer() const 0089 { 0090 #if KSSL_HAVE_SSL 0091 return (flags & (1 << (X509_PURPOSE_SSL_SERVER - 1))) ? true : false; 0092 #endif 0093 return false; 0094 } 0095 0096 bool KSSLX509V3::certTypeNSSSLServer() const 0097 { 0098 #if KSSL_HAVE_SSL 0099 return (flags & (1 << (X509_PURPOSE_NS_SSL_SERVER - 1))) ? true : false; 0100 #endif 0101 return false; 0102 } 0103 0104 bool KSSLX509V3::certTypeSMIME() const 0105 { 0106 #if KSSL_HAVE_SSL 0107 return certTypeSMIMEEncrypt() || certTypeSMIMESign(); 0108 #endif 0109 return false; 0110 } 0111 0112 bool KSSLX509V3::certTypeSMIMEEncrypt() const 0113 { 0114 #if KSSL_HAVE_SSL 0115 return (flags & (1 << (X509_PURPOSE_SMIME_ENCRYPT - 1))) ? true : false; 0116 #endif 0117 return false; 0118 } 0119 0120 bool KSSLX509V3::certTypeSMIMESign() const 0121 { 0122 #if KSSL_HAVE_SSL 0123 return (flags & (1 << (X509_PURPOSE_SMIME_SIGN - 1))) ? true : false; 0124 #endif 0125 return false; 0126 } 0127 0128 bool KSSLX509V3::certTypeCRLSign() const 0129 { 0130 #if KSSL_HAVE_SSL 0131 return (flags & (1 << (X509_PURPOSE_CRL_SIGN - 1))) ? true : false; 0132 #endif 0133 return false; 0134 } 0135