summaryrefslogtreecommitdiffstats
path: root/src/network/ssl/qasn1element_p.h
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2014-09-03 10:44:02 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2014-09-03 17:28:02 +0200
commitbdb30abcd274d4fb1958e17ba8790e415a2ffe85 (patch)
tree144fa81547f64be204436ba5f19fe7e3405fe235 /src/network/ssl/qasn1element_p.h
parentc68ef6d2c010da545c839ba669da011162828f76 (diff)
ssl: add support for ASN.1 boolean values
This adds support for reading and writing ASN.1 boolean values. It also adds an operator to test two ASN.1 elements for equality. Change-Id: I4a22cbf9808533d593fc59d27b63caaf650b1f57 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/ssl/qasn1element_p.h')
-rw-r--r--src/network/ssl/qasn1element_p.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/ssl/qasn1element_p.h b/src/network/ssl/qasn1element_p.h
index 949fd69875..b4445dacfd 100644
--- a/src/network/ssl/qasn1element_p.h
+++ b/src/network/ssl/qasn1element_p.h
@@ -64,6 +64,7 @@ class Q_AUTOTEST_EXPORT QAsn1Element
public:
enum ElementType {
// universal
+ BooleanType = 0x01,
IntegerType = 0x02,
BitStringType = 0x03,
OctetStringType = 0x04,
@@ -91,10 +92,12 @@ public:
bool read(const QByteArray &data);
void write(QDataStream &data) const;
+ static QAsn1Element fromBool(bool val);
static QAsn1Element fromInteger(unsigned int val);
static QAsn1Element fromVector(const QVector<QAsn1Element> &items);
static QAsn1Element fromObjectId(const QByteArray &id);
+ bool toBool(bool *ok = 0) const;
QDateTime toDateTime() const;
QMultiMap<QByteArray, QString> toInfo() const;
qint64 toInteger(bool *ok = 0) const;
@@ -106,12 +109,21 @@ public:
quint8 type() const { return mType; }
QByteArray value() const { return mValue; }
+ friend inline bool operator==(const QAsn1Element &, const QAsn1Element &);
+ friend inline bool operator!=(const QAsn1Element &, const QAsn1Element &);
+
private:
quint8 mType;
QByteArray mValue;
};
Q_DECLARE_TYPEINFO(QAsn1Element, Q_MOVABLE_TYPE);
+inline bool operator==(const QAsn1Element &e1, const QAsn1Element &e2)
+{ return e1.mType == e2.mType && e1.mValue == e2.mValue; }
+
+inline bool operator!=(const QAsn1Element &e1, const QAsn1Element &e2)
+{ return e1.mType != e2.mType || e1.mValue != e2.mValue; }
+
QT_END_NAMESPACE
#endif