File indexing completed on 2024-05-05 16:10:20

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 #ifndef _KSSLKEYGEN_H
0022 #define _KSSLKEYGEN_H
0023 
0024 #include <khtml_export.h>
0025 
0026 #include <QStringList>
0027 #include <QWizard>
0028 
0029 class KSSLKeyGenPrivate;
0030 
0031 /**
0032  * KDE Key Generation dialog
0033  *
0034  * This is used to display a key generation dialog for cases such as the
0035  * html \<keygen\> tag.  It also does the certificate signing request generation.
0036  *
0037  * @author George Staikos <staikos@kde.org>
0038  * @see KSSL, KSSLCertificate, KSSLPKCS12
0039  * @short KDE Key Generation Dialog
0040  */
0041 class KHTML_EXPORT KSSLKeyGen : public QWizard
0042 {
0043     Q_OBJECT
0044 public:
0045     /**
0046      *  Construct a keygen dialog.
0047      *  @param parent the parent widget
0048      */
0049     explicit KSSLKeyGen(QWidget *parent = nullptr);
0050 
0051     /**
0052      *  Destroy this dialog.
0053      */
0054     virtual ~KSSLKeyGen();
0055 
0056     /**
0057      *  List the supported key sizes.
0058      *  @return the supported key sizes
0059      */
0060     static QStringList supportedKeySizes();
0061 
0062     /**
0063      *  Generate the certificate signing request.
0064      *  @param name the name for the certificate
0065      *  @param pass the password for the request
0066      *  @param bits the bitsize for the key
0067      *  @param e the value of the "e" parameter in RSA
0068      *  @return 0 on success, non-zero on error
0069      */
0070     int generateCSR(const QString &name, const QString &pass, int bits, int e = 0x10001);
0071 
0072     /**
0073      *  Set the key size.
0074      *  @param idx an index into supportedKeySizes()
0075      */
0076     void setKeySize(int idx);
0077 
0078 private:
0079     bool validateCurrentPage() override;
0080 
0081 private:
0082     KSSLKeyGenPrivate *const d;
0083 };
0084 
0085 #endif
0086