AusweisApp
Lade ...
Suche ...
Keine Treffer
EcdsaPublicKey.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
7#include "ASN1TemplateUtil.h"
8#include "SecurityProtocol.h"
9
10#include <QByteArray>
11#include <QSharedPointer>
12
13#include <openssl/asn1t.h>
14#include <openssl/evp.h>
15
16#if OPENSSL_VERSION_NUMBER < 0x30000000L
17 #include <openssl/ec.h>
18#endif
19
20
21namespace governikus
22{
23
45{
47 ASN1_OCTET_STRING* mPrimeModulus;
48 ASN1_OCTET_STRING* mFirstCoefficient;
49 ASN1_OCTET_STRING* mSecondCoefficient;
50 ASN1_OCTET_STRING* mBasePoint;
51 ASN1_OCTET_STRING* mOrderOfTheBasePoint;
52 ASN1_OCTET_STRING* mPublicPoint;
53 ASN1_OCTET_STRING* mCofactor;
54
57 QByteArray encode();
58
59 [[nodiscard]] bool isComplete() const;
61
65 [[nodiscard]] Oid getOid() const;
67
75
76#ifndef QT_NO_DEBUG
77
83 [[nodiscard]] QSharedPointer<EVP_PKEY> createKey() const;
84#endif
85
86 private:
87 struct CurveData
88 {
89 QSharedPointer<BIGNUM> p;
90 QSharedPointer<BIGNUM> a;
91 QSharedPointer<BIGNUM> b;
92 QSharedPointer<BIGNUM> order;
93 QSharedPointer<BIGNUM> cofactor;
94
95 [[nodiscard]] bool isValid() const
96 {
97 return !p.isNull() && !a.isNull() && !b.isNull() && !order.isNull();
98 }
99
100
101 };
102
103 [[nodiscard]] static bool isAllValid(const ecdsapublickey_st* pKey);
104 [[nodiscard]] static bool isAllInvalid(const ecdsapublickey_st* pKey);
105
108#if OPENSSL_VERSION_NUMBER < 0x30000000L
110#endif
111
112 public:
113 static int decodeCallback(int pOperation, ASN1_VALUE** pVal, const ASN1_ITEM* pIt, void* pExarg);
114};
115
116
119
120} // namespace governikus
#define DECLARE_ASN1_OBJECT(name)
Definition ASN1TemplateUtil.h:178
QByteArray fromHex(const std::string &pString)
Definition SmartManager.cpp:41
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:16
struct ecdsapublickey_st { ASN1_OBJECT *mObjectIdentifier; ASN1_OCTET_STRING *mPrimeModulus; ASN1_OCTET_STRING *mFirstCoefficient; ASN1_OCTET_STRING *mSecondCoefficient; ASN1_OCTET_STRING *mBasePoint; ASN1_OCTET_STRING *mOrderOfTheBasePoint; ASN1_OCTET_STRING *mPublicPoint; ASN1_OCTET_STRING *mCofactor; static QSharedPointer< ecdsapublickey_st > fromHex(const QByteArray &pHexValue); static QSharedPointer< ecdsapublickey_st > decode(const QByteArray &pBytes); QByteArray encode();[[nodiscard]] bool isComplete() const ;[[nodiscard]] SecurityProtocol getSecurityProtocol() const ;[[nodiscard]] Oid getOid() const ;[[nodiscard]] QByteArray getUncompressedPublicPoint() const ;[[nodiscard]] QSharedPointer< EVP_PKEY > createKey(const QByteArray &pPublicPoint) const ;[[nodiscard]] QSharedPointer< EVP_PKEY > createKey() const ; private: struct CurveData { QSharedPointer< BIGNUM > p; QSharedPointer< BIGNUM > a; QSharedPointer< BIGNUM > b; QSharedPointer< BIGNUM > order; QSharedPointer< BIGNUM > cofactor;[[nodiscard]] bool isValid() const { return !p.isNull() &&!a.isNull() &&!b.isNull() &&!order.isNull(); } };[[nodiscard]] static bool isAllValid(const ecdsapublickey_st *pKey);[[nodiscard]] static bool isAllInvalid(const ecdsapublickey_st *pKey);[[nodiscard]] CurveData createCurveData() const ;[[nodiscard]] QSharedPointer< EVP_PKEY > createKey(const uchar *pPublicPoint, int pPublicPointLength) const ;[[nodiscard]] QSharedPointer< EC_GROUP > createGroup(const CurveData &pData) const ; public: static int decodeCallback(int pOperation, ASN1_VALUE **pVal, const ASN1_ITEM *pIt, void *pExarg);} EcdsaPublicKey
According to TR-03110-3 chapter D elliptic curve public keys are defined as follows:
Definition EcdsaPublicKey.h:44
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition ASN1TemplateUtil.h:114