| 1 |
/**************************************************************************** |
| 2 |
** |
| 3 |
** Copyright (C) 2014 Governikus GmbH & Co. KG. |
| 4 |
** Contact: https://www.qt.io/licensing/ |
| 5 |
** |
| 6 |
** This file is part of the QtNetwork module of the Qt Toolkit. |
| 7 |
** |
| 8 |
** $QT_BEGIN_LICENSE:LGPL$ |
| 9 |
** Commercial License Usage |
| 10 |
** Licensees holding valid commercial Qt licenses may use this file in |
| 11 |
** accordance with the commercial license agreement provided with the |
| 12 |
** Software or, alternatively, in accordance with the terms contained in |
| 13 |
** a written agreement between you and The Qt Company. For licensing terms |
| 14 |
** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 |
** information use the contact form at https://www.qt.io/contact-us. |
| 16 |
** |
| 17 |
** GNU Lesser General Public License Usage |
| 18 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 |
** General Public License version 3 as published by the Free Software |
| 20 |
** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 |
** packaging of this file. Please review the following information to |
| 22 |
** ensure the GNU Lesser General Public License version 3 requirements |
| 23 |
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 |
** |
| 25 |
** GNU General Public License Usage |
| 26 |
** Alternatively, this file may be used under the terms of the GNU |
| 27 |
** General Public License version 2.0 or (at your option) the GNU General |
| 28 |
** Public license version 3 or any later version approved by the KDE Free |
| 29 |
** Qt Foundation. The licenses are as published by the Free Software |
| 30 |
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 |
** included in the packaging of this file. Please review the following |
| 32 |
** information to ensure the GNU General Public License requirements will |
| 33 |
** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 |
** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 |
** |
| 36 |
** $QT_END_LICENSE$ |
| 37 |
** |
| 38 |
****************************************************************************/ |
| 39 |
|
| 40 |
#include "qsslellipticcurve.h" |
| 41 |
|
| 42 |
#ifndef QT_NO_DEBUG_STREAM |
| 43 |
#include <QDebug> |
| 44 |
#endif |
| 45 |
|
| 46 |
QT_BEGIN_NAMESPACE |
| 47 |
|
| 48 |
/*! |
| 49 |
\class QSslEllipticCurve |
| 50 |
\since 5.5 |
| 51 |
|
| 52 |
\brief Represents an elliptic curve for use by elliptic-curve cipher algorithms. |
| 53 |
|
| 54 |
\reentrant |
| 55 |
\ingroup network |
| 56 |
\ingroup ssl |
| 57 |
\inmodule QtNetwork |
| 58 |
|
| 59 |
The class QSslEllipticCurve represents an elliptic curve for use by |
| 60 |
elliptic-curve cipher algorithms. |
| 61 |
|
| 62 |
Elliptic curves can be constructed from a "short name" (SN) (fromShortName()), |
| 63 |
and by a call to QSslConfiguration::supportedEllipticCurves(). |
| 64 |
|
| 65 |
QSslEllipticCurve instances can be compared for equality and can be used as keys |
| 66 |
in QHash and QSet. They cannot be used as key in a QMap. |
| 67 |
|
| 68 |
\note This class is currently only supported in OpenSSL. |
| 69 |
*/ |
| 70 |
|
| 71 |
/*! |
| 72 |
\fn QSslEllipticCurve::QSslEllipticCurve() |
| 73 |
|
| 74 |
Constructs an invalid elliptic curve. |
| 75 |
|
| 76 |
\sa isValid(), QSslConfiguration::supportedEllipticCurves() |
| 77 |
*/ |
| 78 |
|
| 79 |
/*! |
| 80 |
\fn QSslEllipticCurve QSslEllipticCurve::fromShortName(const QString &name) |
| 81 |
|
| 82 |
Returns an QSslEllipticCurve instance representing the |
| 83 |
named curve \a name. The \a name is the conventional short |
| 84 |
name for the curve, as represented by RFC 4492 (for instance \c{secp521r1}), |
| 85 |
or as NIST short names (for instance \c{P-256}). The actual set of |
| 86 |
recognized names depends on the SSL implementation. |
| 87 |
|
| 88 |
If the given \a name is not supported, returns an invalid QSslEllipticCurve instance. |
| 89 |
|
| 90 |
\note The OpenSSL implementation of this function treats the name case-sensitively. |
| 91 |
|
| 92 |
\sa shortName() |
| 93 |
*/ |
| 94 |
|
| 95 |
/*! |
| 96 |
\fn QSslEllipticCurve QSslEllipticCurve::fromLongName(const QString &name) |
| 97 |
|
| 98 |
Returns an QSslEllipticCurve instance representing the named curve \a name. |
| 99 |
The \a name is a long name for the curve, whose exact spelling depends on the |
| 100 |
SSL implementation. |
| 101 |
|
| 102 |
If the given \a name is not supported, returns an invalid QSslEllipticCurve instance. |
| 103 |
|
| 104 |
\note The OpenSSL implementation of this function treats the name case-sensitively. |
| 105 |
|
| 106 |
\sa longName() |
| 107 |
*/ |
| 108 |
|
| 109 |
/*! |
| 110 |
\fn QString QSslEllipticCurve::shortName() const |
| 111 |
|
| 112 |
Returns the conventional short name for this curve. If this |
| 113 |
curve is invalid, returns an empty string. |
| 114 |
|
| 115 |
\sa longName() |
| 116 |
*/ |
| 117 |
|
| 118 |
/*! |
| 119 |
\fn QString QSslEllipticCurve::longName() const |
| 120 |
|
| 121 |
Returns the conventional long name for this curve. If this |
| 122 |
curve is invalid, returns an empty string. |
| 123 |
|
| 124 |
\sa shortName() |
| 125 |
*/ |
| 126 |
|
| 127 |
/*! |
| 128 |
\fn bool QSslEllipticCurve::isValid() const |
| 129 |
|
| 130 |
Returns true if this elliptic curve is a valid curve, false otherwise. |
| 131 |
*/ |
| 132 |
|
| 133 |
/*! |
| 134 |
\fn bool QSslEllipticCurve::isTlsNamedCurve() const |
| 135 |
|
| 136 |
Returns true if this elliptic curve is one of the named curves that can be |
| 137 |
used in the key exchange when using an elliptic curve cipher with TLS; |
| 138 |
false otherwise. |
| 139 |
*/ |
| 140 |
|
| 141 |
/*! |
| 142 |
\fn bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) |
| 143 |
\since 5.5 |
| 144 |
\relates QSslEllipticCurve |
| 145 |
|
| 146 |
Returns true if the curve \a lhs represents the same curve of \a rhs; |
| 147 |
*/ |
| 148 |
|
| 149 |
/*! |
| 150 |
\fn bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) |
| 151 |
\since 5.5 |
| 152 |
\relates QSslEllipticCurve |
| 153 |
|
| 154 |
Returns true if the curve \a lhs represents a different curve than \a rhs; |
| 155 |
false otherwise. |
| 156 |
*/ |
| 157 |
|
| 158 |
/*! |
| 159 |
\fn uint qHash(QSslEllipticCurve curve, uint seed) |
| 160 |
\since 5.5 |
| 161 |
\relates QHash |
| 162 |
|
| 163 |
Returns an hash value for the curve \a curve, using \a seed to seed |
| 164 |
the calculation. |
| 165 |
*/ |
| 166 |
|
| 167 |
#ifndef QT_NO_DEBUG_STREAM |
| 168 |
/*! |
| 169 |
\relates QSslEllipticCurve |
| 170 |
\since 5.5 |
| 171 |
|
| 172 |
Writes the elliptic curve \a curve into the debug object \a debug for |
| 173 |
debugging purposes. |
| 174 |
|
| 175 |
\sa {Debugging Techniques} |
| 176 |
*/ |
| 177 |
QDebug operator<<(QDebug debug, QSslEllipticCurve curve) |
| 178 |
{ |
| 179 |
QDebugStateSaver saver(debug); |
| 180 |
debug.resetFormat().nospace(); |
| 181 |
debug << "QSslEllipticCurve(" << curve.shortName() << ')'; |
| 182 |
return debug; |
| 183 |
} |
| 184 |
#endif |
| 185 |
|
| 186 |
QT_END_NAMESPACE |