@@ -38,31 +38,30 @@ using namespace electronic_id;
38
38
namespace
39
39
{
40
40
41
- // Use common base64-encoding defaults.
42
- constexpr auto BASE64_OPTIONS = QByteArray::Base64Encoding | QByteArray::KeepTrailingEquals;
43
-
44
41
QVariantMap createAuthenticationToken (const QString& signatureAlgorithm,
45
42
const QByteArray& certificateDer, const QByteArray& signature)
46
43
{
47
44
return QVariantMap {
48
- {" unverifiedCertificate" , QString (certificateDer.toBase64 (BASE64_OPTIONS ))},
45
+ {" unverifiedCertificate" , QString (certificateDer.toBase64 ())},
49
46
{" algorithm" , signatureAlgorithm},
50
47
{" signature" , QString (signature)},
51
48
{" format" , QStringLiteral (" web-eid:1.0" )},
52
49
{" appVersion" ,
53
50
QStringLiteral (" https://web-eid.eu/web-eid-app/releases/%1" )
54
- .arg (qApp-> applicationVersion ())},
51
+ .arg (QApplication:: applicationVersion ())},
55
52
};
56
53
}
57
54
58
55
QByteArray createSignature (const QString& origin, const QString& challengeNonce,
59
56
const ElectronicID& eid, const pcsc_cpp::byte_vector& pin)
60
57
{
61
- static const auto SIGNATURE_ALGO_TO_HASH =
62
- std::map<JsonWebSignatureAlgorithm, QCryptographicHash::Algorithm> {
58
+ static const std::map<JsonWebSignatureAlgorithm, QCryptographicHash::Algorithm>
59
+ SIGNATURE_ALGO_TO_HASH {
63
60
{JsonWebSignatureAlgorithm::RS256, QCryptographicHash::Sha256},
64
61
{JsonWebSignatureAlgorithm::PS256, QCryptographicHash::Sha256},
62
+ {JsonWebSignatureAlgorithm::ES256, QCryptographicHash::Sha256},
65
63
{JsonWebSignatureAlgorithm::ES384, QCryptographicHash::Sha384},
64
+ {JsonWebSignatureAlgorithm::ES512, QCryptographicHash::Sha512},
66
65
};
67
66
68
67
if (!SIGNATURE_ALGO_TO_HASH.count (eid.authSignatureAlgorithm ())) {
@@ -80,26 +79,27 @@ QByteArray createSignature(const QString& origin, const QString& challengeNonce,
80
79
// The value that is signed is hash(origin)+hash(challenge).
81
80
const auto hashToBeSignedQBytearray =
82
81
QCryptographicHash::hash (originHash + challengeNonceHash, hashAlgo);
83
- const auto hashToBeSigned =
84
- pcsc_cpp::byte_vector {hashToBeSignedQBytearray. cbegin (), hashToBeSignedQBytearray.cend ()};
82
+ const pcsc_cpp::byte_vector hashToBeSigned {hashToBeSignedQBytearray. cbegin (),
83
+ hashToBeSignedQBytearray.cend ()};
85
84
86
85
const auto signature = eid.signWithAuthKey (pin, hashToBeSigned);
87
86
88
87
return QByteArray::fromRawData (reinterpret_cast <const char *>(signature.data ()),
89
88
int (signature.size ()))
90
- .toBase64 (BASE64_OPTIONS );
89
+ .toBase64 ();
91
90
}
92
91
93
92
} // namespace
94
93
95
94
Authenticate::Authenticate (const CommandWithArguments& cmd) : CertificateReader(cmd)
96
95
{
97
96
const auto arguments = cmd.second ;
98
- requireArgumentsAndOptionalLang ({ " challengeNonce " , " origin " }, arguments,
99
- " \" challengeNonce\" : \" <challenge nonce> \" , "
100
- " \" origin\ " : \ " <origin URL>\" " );
97
+ requireArgumentsAndOptionalLang (
98
+ { " challengeNonce" , " origin " }, arguments,
99
+ R"( "challengeNonce": "<challenge nonce>", " origin": "<origin URL>" ) " );
101
100
102
- challengeNonce = validateAndGetArgument<QString>(QStringLiteral (" challengeNonce" ), arguments);
101
+ challengeNonce = validateAndGetArgument<decltype (challengeNonce)>(
102
+ QStringLiteral (" challengeNonce" ), arguments);
103
103
// nonce must contain at least 256 bits of entropy and is usually Base64-encoded, so the
104
104
// required byte length is 44, the length of 32 Base64-encoded bytes.
105
105
if (challengeNonce.length () < 44 ) {
@@ -135,10 +135,10 @@ QVariantMap Authenticate::onConfirm(WebEidUI* window,
135
135
136
136
} catch (const VerifyPinFailed& failure) {
137
137
switch (failure.status ()) {
138
- case electronic_id:: VerifyPinFailed::Status::PIN_ENTRY_CANCEL:
139
- case electronic_id:: VerifyPinFailed::Status::PIN_ENTRY_TIMEOUT:
138
+ case VerifyPinFailed::Status::PIN_ENTRY_CANCEL:
139
+ case VerifyPinFailed::Status::PIN_ENTRY_TIMEOUT:
140
140
break ;
141
- case electronic_id:: VerifyPinFailed::Status::PIN_ENTRY_DISABLED:
141
+ case VerifyPinFailed::Status::PIN_ENTRY_DISABLED:
142
142
emit retry (RetriableError::PIN_VERIFY_DISABLED);
143
143
break ;
144
144
default :
0 commit comments