OpenCoverage

qsslellipticcurve_openssl.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/ssl/qsslellipticcurve_openssl.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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#include "qsslsocket_p.h"-
42#include "qsslsocket_openssl_symbols_p.h"-
43-
44#include <openssl/ssl.h>-
45#include <openssl/obj_mac.h>-
46-
47#include <algorithm>-
48-
49QT_BEGIN_NAMESPACE-
50-
51QString QSslEllipticCurve::shortName() const-
52{-
53 QString result;-
54#ifndef OPENSSL_NO_EC-
55 if (id != 0)
id != 0Description
TRUEevaluated 268 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
10-268
56 result = QString::fromLatin1(q_OBJ_nid2sn(id));
executed 268 times by 1 test: result = QString::fromLatin1(q_OBJ_nid2sn(id));
Executed by:
  • tst_qsslellipticcurve - unknown status
268
57#endif-
58 return result;
executed 278 times by 1 test: return result;
Executed by:
  • tst_qsslellipticcurve - unknown status
278
59}-
60-
61QString QSslEllipticCurve::longName() const-
62{-
63 QString result;-
64#ifndef OPENSSL_NO_EC-
65 if (id != 0)
id != 0Description
TRUEevaluated 268 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
10-268
66 result = QString::fromLatin1(q_OBJ_nid2ln(id));
executed 268 times by 1 test: result = QString::fromLatin1(q_OBJ_nid2ln(id));
Executed by:
  • tst_qsslellipticcurve - unknown status
268
67#endif-
68 return result;
executed 278 times by 1 test: return result;
Executed by:
  • tst_qsslellipticcurve - unknown status
278
69}-
70-
71QSslEllipticCurve QSslEllipticCurve::fromShortName(const QString &name)-
72{-
73 if (name.isEmpty())
name.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
2-68
74 return QSslEllipticCurve();
executed 2 times by 1 test: return QSslEllipticCurve();
Executed by:
  • tst_qsslellipticcurve - unknown status
2
75-
76 QSslSocketPrivate::ensureInitialized();-
77-
78 QSslEllipticCurve result;-
79-
80#ifndef OPENSSL_NO_EC-
81 const QByteArray curveNameLatin1 = name.toLatin1();-
82-
83 int nid = q_OBJ_sn2nid(curveNameLatin1.data());-
84-
85#if OPENSSL_VERSION_NUMBER >= 0x10002000L-
86 if (nid == 0 && q_SSLeay() >= 0x10002000L)-
87 nid = q_EC_curve_nist2nid(curveNameLatin1.data());-
88#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L-
89-
90 result.id = nid;-
91#endif-
92-
93 return result;
executed 68 times by 1 test: return result;
Executed by:
  • tst_qsslellipticcurve - unknown status
68
94}-
95-
96QSslEllipticCurve QSslEllipticCurve::fromLongName(const QString &name)-
97{-
98 if (name.isEmpty())
name.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
FALSEevaluated 68 times by 1 test
Evaluated by:
  • tst_qsslellipticcurve - unknown status
2-68
99 return QSslEllipticCurve();
executed 2 times by 1 test: return QSslEllipticCurve();
Executed by:
  • tst_qsslellipticcurve - unknown status
2
100-
101 QSslSocketPrivate::ensureInitialized();-
102-
103 QSslEllipticCurve result;-
104-
105#ifndef OPENSSL_NO_EC-
106 const QByteArray curveNameLatin1 = name.toLatin1();-
107-
108 int nid = q_OBJ_ln2nid(curveNameLatin1.data());-
109 result.id = nid;-
110#endif-
111-
112 return result;
executed 68 times by 1 test: return result;
Executed by:
  • tst_qsslellipticcurve - unknown status
68
113}-
114-
115-
116// The brainpool curve NIDs (RFC 7027) have been introduced in OpenSSL 1.0.2,-
117// redefine them here to make Qt compile with previous versions of OpenSSL-
118// (yet correctly recognize them as TLS named curves).-
119// See crypto/objects/obj_mac.h-
120#ifndef NID_brainpoolP256r1-
121#define NID_brainpoolP256r1 927-
122#endif-
123-
124#ifndef NID_brainpoolP384r1-
125#define NID_brainpoolP384r1 931-
126#endif-
127-
128#ifndef NID_brainpoolP512r1-
129#define NID_brainpoolP512r1 933-
130#endif-
131-
132// NIDs of named curves allowed in TLS as per RFCs 4492 and 7027,-
133// see also https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-8-
134static const int tlsNamedCurveNIDs[] = {-
135 // RFC 4492-
136 NID_sect163k1,-
137 NID_sect163r1,-
138 NID_sect163r2,-
139 NID_sect193r1,-
140 NID_sect193r2,-
141 NID_sect233k1,-
142 NID_sect233r1,-
143 NID_sect239k1,-
144 NID_sect283k1,-
145 NID_sect283r1,-
146 NID_sect409k1,-
147 NID_sect409r1,-
148 NID_sect571k1,-
149 NID_sect571r1,-
150-
151 NID_secp160k1,-
152 NID_secp160r1,-
153 NID_secp160r2,-
154 NID_secp192k1,-
155 NID_X9_62_prime192v1, // secp192r1-
156 NID_secp224k1,-
157 NID_secp224r1,-
158 NID_secp256k1,-
159 NID_X9_62_prime256v1, // secp256r1-
160 NID_secp384r1,-
161 NID_secp521r1,-
162-
163 // RFC 7027-
164 NID_brainpoolP256r1,-
165 NID_brainpoolP384r1,-
166 NID_brainpoolP512r1-
167};-
168-
169static const size_t tlsNamedCurveNIDCount = sizeof(tlsNamedCurveNIDs) / sizeof(tlsNamedCurveNIDs[0]);-
170-
171bool QSslEllipticCurve::isTlsNamedCurve() const Q_DECL_NOTHROW-
172{-
173 const int * const tlsNamedCurveNIDsEnd = tlsNamedCurveNIDs + tlsNamedCurveNIDCount;-
174 return std::find(tlsNamedCurveNIDs, tlsNamedCurveNIDsEnd, id) != tlsNamedCurveNIDsEnd;
executed 1 time by 1 test: return std::find(tlsNamedCurveNIDs, tlsNamedCurveNIDsEnd, id) != tlsNamedCurveNIDsEnd;
Executed by:
  • tst_qsslellipticcurve - unknown status
1
175}-
176-
177QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9