AusweisApp
Lade ...
Suche ...
Keine Treffer
EcUtil.h
gehe zur Dokumentation dieser Datei
1
9
#pragma once
10
11
#include <QByteArray>
12
#include <QSharedPointer>
13
14
#include <openssl/bn.h>
15
#include <openssl/ec.h>
16
#include <openssl/ecdsa.h>
17
#include <openssl/evp.h>
18
19
#include <functional>
20
21
namespace
governikus
22
{
23
24
class
EcUtil
25
{
26
public
:
27
static
QByteArray
point2oct
(
const
QSharedPointer<const EC_GROUP>
&
pCurve
,
const
EC_POINT
*
pPoint
,
bool
pCompressed
=
false
);
28
29
static
QSharedPointer<EC_POINT>
oct2point
(
const
QSharedPointer<const EC_GROUP>
&
pCurve
,
const
QByteArray
&
pCompressedData
);
30
31
static
QSharedPointer<EC_GROUP>
create
(
EC_GROUP
*
pEcGroup
);
32
33
static
QSharedPointer<EC_KEY>
create
(
EC_KEY
*
pEcKey
);
34
35
static
QSharedPointer<EC_POINT>
create
(
EC_POINT
*
pEcPoint
);
36
37
static
QSharedPointer<BIGNUM>
create
(
BIGNUM
*
pBigNum
);
38
39
static
QSharedPointer<EVP_PKEY>
create
(
EVP_PKEY
*
pEcGroup
);
40
41
static
QSharedPointer<EVP_PKEY_CTX>
create
(
EVP_PKEY_CTX
*
pEcGroup
);
42
43
static
QSharedPointer<EC_KEY>
generateKey
(
const
QSharedPointer<const EC_GROUP>
&
pCurve
);
44
45
static
QSharedPointer<EC_GROUP>
createCurve
(
int
pNid
);
46
};
47
48
49
inline
QSharedPointer<EC_GROUP>
EcUtil::create
(
EC_GROUP
*
pEcGroup
)
50
{
51
static
auto
deleter
= [](
EC_GROUP
*
ecCurve
)
52
{
53
EC_GROUP_free
(
ecCurve
);
54
};
55
56
return
QSharedPointer<EC_GROUP>
(
pEcGroup
,
deleter
);
57
}
58
59
60
inline
QSharedPointer<EC_KEY>
EcUtil::create
(
EC_KEY
*
pEcKey
)
61
{
62
static
auto
deleter
= [](
EC_KEY
*
ecKey
)
63
{
64
EC_KEY_free
(
ecKey
);
65
};
66
67
return
QSharedPointer<EC_KEY>
(
pEcKey
,
deleter
);
68
}
69
70
71
inline
QSharedPointer<EC_POINT>
EcUtil::create
(
EC_POINT
*
pEcPoint
)
72
{
73
static
auto
deleter
= [](
EC_POINT
*
ecPoint
)
74
{
75
EC_POINT_clear_free
(
ecPoint
);
76
};
77
78
return
QSharedPointer<EC_POINT>
(
pEcPoint
,
deleter
);
79
}
80
81
82
inline
QSharedPointer<BIGNUM>
EcUtil::create
(
BIGNUM
*
pBigNum
)
83
{
84
static
auto
deleter
= [](
BIGNUM
*
bigNum
)
85
{
86
BN_clear_free
(
bigNum
);
87
};
88
89
return
QSharedPointer<BIGNUM>
(
pBigNum
,
deleter
);
90
}
91
92
93
inline
QSharedPointer<EVP_PKEY>
EcUtil::create
(
EVP_PKEY
*
pKey
)
94
{
95
static
auto
deleter
= [](
EVP_PKEY
*
key
)
96
{
97
EVP_PKEY_free
(
key
);
98
};
99
100
return
QSharedPointer<EVP_PKEY>
(
pKey
,
deleter
);
101
}
102
103
104
inline
QSharedPointer<EVP_PKEY_CTX>
EcUtil::create
(
EVP_PKEY_CTX
*
pCtx
)
105
{
106
static
auto
deleter
= [](
EVP_PKEY_CTX
*
ctx
)
107
{
108
EVP_PKEY_CTX_free
(
ctx
);
109
};
110
111
return
QSharedPointer<EVP_PKEY_CTX>
(
pCtx
,
deleter
);
112
}
113
114
115
}
// namespace governikus
governikus::EcUtil
Definition
EcUtil.h:25
governikus::EcUtil::point2oct
static QByteArray point2oct(const QSharedPointer< const EC_GROUP > &pCurve, const EC_POINT *pPoint, bool pCompressed=false)
Definition
EcUtil.cpp:31
governikus::EcUtil::createCurve
static QSharedPointer< EC_GROUP > createCurve(int pNid)
Definition
EcUtil.cpp:19
governikus::EcUtil::generateKey
static QSharedPointer< EC_KEY > generateKey(const QSharedPointer< const EC_GROUP > &pCurve)
Definition
EcUtil.cpp:91
governikus::EcUtil::oct2point
static QSharedPointer< EC_POINT > oct2point(const QSharedPointer< const EC_GROUP > &pCurve, const QByteArray &pCompressedData)
Definition
EcUtil.cpp:67
governikus::EcUtil::create
static QSharedPointer< EC_GROUP > create(EC_GROUP *pEcGroup)
Definition
EcUtil.h:49
governikus
Implementation of GeneralAuthenticate response APDUs.
Definition
CommandApdu.h:16
governikus::decodeObject
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition
ASN1TemplateUtil.h:114
src
card
base
pace
ec
EcUtil.h
Erzeugt von
1.10.0