Skip to content

Commit

Permalink
feat(commands): use camelCase instead of kebab-case in command argume…
Browse files Browse the repository at this point in the history
…nt names and responses

WE2-585

Signed-off-by: Mart Somermaa <[email protected]>
  • Loading branch information
mrts committed Dec 13, 2021
1 parent bfe0567 commit c883b6c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 42 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ either contains the requested Base64-encoded certificate and supported
signature algorithms, or an error object with a symbolic error code. Successful
output example:

{"certificate":"MIID7DCCA02gAwIBAgIQOZYpcFbeurZbzz9ngqCZsTAKBggqhkjOPQQDBDBgMQswCQYDVQQGEwJFRTEbMBkGA1UECgwSU0sgSUQgU29sdXRpb25zIEFTMRcwFQYDVQRhDA5OVFJFRS0xMDc0NzAxMzEbMBkGA1UEAwwSVEVTVCBvZiBFU1RFSUQyMDE4MB4XDTE4MTAyMzE1MzM1OVoXDTIzMTAyMjIxNTk1OVowfzELMAkGA1UEBhMCRUUxKjAoBgNVBAMMIUrDlUVPUkcsSkFBSy1LUklTVEpBTiwzODAwMTA4NTcxODEQMA4GA1UEBAwHSsOVRU9SRzEWMBQGA1UEKgwNSkFBSy1LUklTVEpBTjEaMBgGA1UEBRMRUE5PRUUtMzgwMDEwODU3MTgwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASKvaAJSGYBrLcvq0KjgM1sOAS9vbtqeSS2OkqyY4i5AazaetYmCtXKOqUUeljOJUGBUzljDFlAEPHs5Fn+vFT7+cGkOVCA93PBYKVsA9avcWyMwgQQJoW6kA4ZN9yD/mijggGrMIIBpzAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIGQDBIBgNVHSAEQTA/MDIGCysGAQQBg5EhAQIBMCMwIQYIKwYBBQUHAgEWFWh0dHBzOi8vd3d3LnNrLmVlL0NQUzAJBgcEAIvsQAECMB0GA1UdDgQWBBRYwsjA5GJ7HWPvD8ByThPTZ6j3PDCBigYIKwYBBQUHAQMEfjB8MAgGBgQAjkYBATAIBgYEAI5GAQQwEwYGBACORgEGMAkGBwQAjkYBBgEwUQYGBACORgEFMEcwRRY/aHR0cHM6Ly9zay5lZS9lbi9yZXBvc2l0b3J5L2NvbmRpdGlvbnMtZm9yLXVzZS1vZi1jZXJ0aWZpY2F0ZXMvEwJFTjAfBgNVHSMEGDAWgBTAhJkpxE6fOwI09pnhClYACCk+ezBzBggrBgEFBQcBAQRnMGUwLAYIKwYBBQUHMAGGIGh0dHA6Ly9haWEuZGVtby5zay5lZS9lc3RlaWQyMDE4MDUGCCsGAQUFBzAChilodHRwOi8vYy5zay5lZS9UZXN0X29mX0VTVEVJRDIwMTguZGVyLmNydDAKBggqhkjOPQQDBAOBjAAwgYgCQgDBTN1LM08SeH18xKQplqAmV8AQhVvrOxRELCmYp54Qr0XTi2i7kMw0k8gVOV84RlPQP6/ayjs4+ytRbIdkBZK1vQJCARF17/gWYUu7bmy/AXT6fWgyuDV5j2UC2cWDFhPUYyS99rdLGSfP10rP9mPK87Y+4HkfJB/qDyENnJYPa5mUsuFK","supported-signature-algos":[{"crypto-algo":"ECC","hash-algo":"SHA-224","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA-256","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA-384","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA-512","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA3-224","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA3-256","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA3-384","padding-algo":"NONE"},{"crypto-algo":"ECC","hash-algo":"SHA3-512","padding-algo":"NONE"}]}
{"certificate":"MIID7DCCA02gAwIBAgIQOZYpcFbeurZbzz9ngqCZsTAKBggqhkjOPQQDBDBgMQswCQYDVQQGEwJFRTEbMBkGA1UECgwSU0sgSUQgU29sdXRpb25zIEFTMRcwFQYDVQRhDA5OVFJFRS0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ELCmYp54Qr0XTi2i7kMw0k8gVOV84RlPQP6/ayjs4+ytRbIdkBZK1vQJCARF17/gWYUu7bmy/AXT6fWgyuDV5j2UC2cWDFhPUYyS99rdLGSfP10rP9mPK87Y+4HkfJB/qDyENnJYPa5mUsuFK","supportedSignatureAlgorithms":[{"cryptoAlgorithm":"ECC","hashFunction":"SHA-224","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA-256","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA-384","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA-512","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA3-224","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA3-256","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA3-384","paddingScheme":"NONE"},{"cryptoAlgorithm":"ECC","hashFunction":"SHA3-512","paddingScheme":"NONE"}]}

Error example:

{"error": {"code": "ERR_WEBEID_NATIVE_FATAL", "message": "Invalid origin"}}

The `supported-signature-algos` field contains an array of objects that
The `supportedSignatureAlgorithms` field contains an array of objects that
specify the signature algorithms that the card supports. Each object has three
members:

- `crypto-algo`, the cryptographic algorithm, `ECC` for elliptic curve
- `cryptoAlgorithm`, the cryptographic algorithm, `ECC` for elliptic curve
cryptography or `RSA` for the Rivest-Shamir-Adleman algorithm;

- `hash-algo`, the cryptographic hash algorithm, any of the SHA-2 or SHA-3
standard algorithms, see _Allowed hash algorithms_ below in section _Sign_;
- `hashFunction`, the cryptographic hash function, any of the SHA-2 or SHA-3
standard algorithms, see _Allowed hash functions_ below in section _Sign_;

- `padding-algo`, the padding scheme used, for example `PKCS1.5` for PKCS#1
- `paddingScheme`, the padding scheme used, for example `PKCS1.5` for PKCS#1
v1.5 padding.

### Authenticate
Expand All @@ -79,7 +79,7 @@ and signs it with the authentication key.
Authentication command requires the challenge nonce and origin URL as
JSON-encoded command-line arguments:

web-eid -c authenticate '{"challenge-nonce": "12345678901234567890123456789012345678901234", "origin": "https://ria.ee"}'
web-eid -c authenticate '{"challengeNonce": "12345678901234567890123456789012345678901234", "origin": "https://ria.ee"}'

The result will be written to standard output as a JSON-encoded message that
either contains the authentication token or an error code. Successful output
Expand All @@ -100,31 +100,31 @@ architecture document](https://github.com/web-eid/web-eid-system-architecture-do

Signing command signs the provided document hash with the signing key.

Signing command requires the Base64-encoded document hash, hash algorithm,
Signing command requires the Base64-encoded document hash, hash function,
origin URL and previously retrieved Base64-encoded user signing certificate as
JSON-encoded command-line arguments:

web-eid -c sign '{"doc-hash": "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4", "hash-algo": "SHA-384", "origin": "https://ria.ee", "user-eid-cert": "MIID7DCCA02gAwIBAgIQGWaqJX+JmHFbyFd4ba1pajAKBggqhkjOPQQDBDBgMQswCQYDVQQGEwJFRTEbMBkGA1UECgwSU0sgSUQgU29sdXRpb25zIEFTMRcwFQYDVQRhDA5OVFJFRS0xMDc0NzAxMzEbMBkGA1UEAwwSVEVTVCBvZiBFU1RFSUQyMDE4MB4XDTE4MTAxODA5NTA0N1oXDTIzMTAxNzIxNTk1OVowfzELMAkGA1UEBhMCRUUxKjAoBgNVBAMMIUrDlUVPUkcsSkFBSy1LUklTVEpBTiwzODAwMTA4NTcxODEQMA4GA1UEBAwHSsOVRU9SRzEWMBQGA1UEKgwNSkFBSy1LUklTVEpBTjEaMBgGA1UEBRMRUE5PRUUtMzgwMDEwODU3MTgwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATF0tc74ZjE9UNp4iWwMFQ/zolrDB9XH//FJdwT6ynQBT8v6HNdxRF+z+8P81eRMHNb+VehUNUob/s5et7iW0bK28yQrlTcyHfQNxHMfBJFzDl+6QImU2fXKKK4oopV28ujggGrMIIBpzAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIGQDBIBgNVHSAE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5e6maOrxP2mcz9yvnfg0jS52gQ0r905Af0bwp6vVxObxVU"}'

Allowed hash algorithm values are SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224,
SHA3-256, SHA3-384, SHA3-512, and the hash algorithm has to be supported by the
card (see the `hash-algo` member of `supported-signature-algos` array elements
Allowed hash function values are SHA-224, SHA-256, SHA-384, SHA-512, SHA3-224,
SHA3-256, SHA3-384, SHA3-512, and the hash function has to be supported by the
card (see the `hashFunction` member of `supportedSignatureAlgorithms` array elements
in the `get-signing-certificate` command output). The document hash length has to match
the hash algorithm output length and the hash algorithm has to be supported by
the hash function output length and the hash function has to be supported by
the electronic ID signing implementation.

The user signing certificate for the `user-eid-cert` field can be retrieved
The user signing certificate for the `certificate` field can be retrieved
with the `get-signing-certificate` command as described above:

web-eid -c get-signing-certificate '{...other arguments as above...}'

The result will be written to standard output as a JSON-encoded message that
either contains the Base64-encoded signature and the signature algorithm used
(see the description of the `supported-signature-algos` field above in section
(see the description of the `supportedSignatureAlgorithms` field above in section
_Get certificate_), or an error code. Successful output example:

{
"signature-algo": {"hash-algo": "SHA-384", "padding-algo": "NONE", "crypto-algo": "ECC"},
"signatureAlgorithm": {"hashFunction": "SHA-384", "paddingScheme": "NONE", "cryptoAlgorithm": "ECC"},
"signature": "oIw20YRlryXgAhGbHEKBCzQetVAE/S2VjqEQ1h+Kc9Scujcl37oOCmAgoHmEkG4Fpmp/z2waGw8ciJ1yXNpgzIaLhtyytFnFmcwR3zp6OKZTqHuEvTEAxZkxC6gLCxJh"
}

Expand Down
10 changes: 5 additions & 5 deletions src/controller/command-handlers/authenticate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ QByteArray createSignature(const QString& origin, const QString& challengeNonce,
Authenticate::Authenticate(const CommandWithArguments& cmd) : CertificateReader(cmd)
{
const auto arguments = cmd.second;
requireArgumentsAndOptionalLang({"challenge-nonce", "origin"}, arguments,
"\"challenge-nonce\": \"<challenge nonce>\", "
requireArgumentsAndOptionalLang({"challengeNonce", "origin"}, arguments,
"\"challengeNonce\": \"<challenge nonce>\", "
"\"origin\": \"<origin URL>\"");

challengeNonce = validateAndGetArgument<QString>(QStringLiteral("challenge-nonce"), arguments);
challengeNonce = validateAndGetArgument<QString>(QStringLiteral("challengeNonce"), arguments);
// nonce must contain at least 256 bits of entropy and is usually Base64-encoded, so the
// required byte length is 44, the length of 32 Base64-encoded bytes.
if (challengeNonce.length() < 44) {
THROW(CommandHandlerInputDataError,
"Challenge nonce argument 'challenge-nonce' must be at least 44 characters long");
"Challenge nonce argument 'challengeNonce' must be at least 44 characters long");
}
if (challengeNonce.length() > 128) {
THROW(CommandHandlerInputDataError,
"Challenge nonce argument 'challenge-nonce' cannot be longer than 128 characters");
"Challenge nonce argument 'challengeNonce' cannot be longer than 128 characters");
}
validateAndStoreOrigin(arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/command-handlers/getcertificate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ QVariantMap GetCertificate::onConfirm(WebEidUI* /* window */,
// Base64url-encoded) DER [ITU.X690.2008] PKIX certificate value.
auto certPem = cardCertAndPin.certificateBytesInDer.toBase64();
auto algos = supportedSigningAlgos(cardCertAndPin.cardInfo->eid());
return {{"certificate", QString(certPem)}, {"supported-signature-algos", algos}};
return {{"certificate", QString(certPem)}, {"supportedSignatureAlgorithms", algos}};
}
20 changes: 10 additions & 10 deletions src/controller/command-handlers/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ Sign::Sign(const CommandWithArguments& cmd) : CertificateReader(cmd)
const auto arguments = cmd.second;

requireArgumentsAndOptionalLang(
{"doc-hash", "hash-algo", "user-eid-cert", "origin"}, arguments,
"\"doc-hash\": \"<Base64-encoded document hash>\", "
"\"hash-algo\": \"<the hash algorithm that was used for computing 'doc-hash', any of "
{"hash", "hashFunction", "certificate", "origin"}, arguments,
"\"hash\": \"<Base64-encoded document hash>\", "
"\"hashFunction\": \"<the hash algorithm that was used for computing 'hash', any of "
+ HashAlgorithm::allSupportedAlgorithmNames()
+ ">\", \"user-eid-cert\": \"<Base64-encoded user eID certificate previously "
+ ">\", \"certificate\": \"<Base64-encoded user eID certificate previously "
"retrieved with get-cert>\", "
"\"origin\": \"<origin URL>\"");

validateAndStoreDocHashAndHashAlgo(arguments);

userEidCertificateFromArgs =
parseAndValidateCertificate(QStringLiteral("user-eid-cert"), arguments);
parseAndValidateCertificate(QStringLiteral("certificate"), arguments);
validateAndStoreOrigin(arguments);
}

Expand Down Expand Up @@ -108,7 +108,7 @@ QVariantMap Sign::onConfirm(WebEidUI* window, const CardCertificateAndPinInfo& c
std::fill(pin.begin(), pin.end(), '\0');

return {{QStringLiteral("signature"), signature.first},
{QStringLiteral("signature-algo"), signature.second}};
{QStringLiteral("signatureAlgorithm"), signature.second}};

} catch (const VerifyPinFailed& failure) {
switch (failure.status()) {
Expand All @@ -135,12 +135,12 @@ void Sign::connectSignals(const WebEidUI* window)

void Sign::validateAndStoreDocHashAndHashAlgo(const QVariantMap& args)
{
docHash = QByteArray::fromBase64(
validateAndGetArgument<QByteArray>(QStringLiteral("doc-hash"), args));
docHash =
QByteArray::fromBase64(validateAndGetArgument<QByteArray>(QStringLiteral("hash"), args));

QString hashAlgoInput = validateAndGetArgument<QString>(QStringLiteral("hash-algo"), args);
QString hashAlgoInput = validateAndGetArgument<QString>(QStringLiteral("hashFunction"), args);
if (hashAlgoInput.size() > 8) {
THROW(CommandHandlerInputDataError, "hash-algo value is invalid");
THROW(CommandHandlerInputDataError, "hashFunction value is invalid");
}
hashAlgo = HashAlgorithm(hashAlgoInput.toStdString());

Expand Down
7 changes: 4 additions & 3 deletions src/controller/command-handlers/signauthutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ QVariantMap signatureAlgoToVariantMap(const SignatureAlgorithm signatureAlgo)
}

if (signatureAlgo & SignatureAlgorithm::ES)
return {{"crypto-algo", "ECC"}, {"hash-algo", hashAlgo}, {"padding-algo", "NONE"}};
return {{"cryptoAlgorithm", "ECC"}, {"hashFunction", hashAlgo}, {"paddingScheme", "NONE"}};
if (signatureAlgo & SignatureAlgorithm::RS)
return {{"crypto-algo", "RSA"}, {"hash-algo", hashAlgo}, {"padding-algo", "PKCS1.5"}};
return {
{"cryptoAlgorithm", "RSA"}, {"hashFunction", hashAlgo}, {"paddingScheme", "PKCS1.5"}};
if (signatureAlgo & SignatureAlgorithm::PS)
return {{"crypto-algo", "RSA"}, {"hash-algo", hashAlgo}, {"padding-algo", "PSS"}};
return {{"cryptoAlgorithm", "RSA"}, {"hashFunction", hashAlgo}, {"paddingScheme", "PSS"}};
THROW(ProgrammingError, "Unknown signature algorithm " + std::string(signatureAlgo));
}
8 changes: 4 additions & 4 deletions tests/input-output-mode/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_2_authenticate(self):
message = {
'command': 'authenticate',
'arguments': {
'challenge-nonce': '12345678123456781234567812345678912356789123',
'challengeNonce': '12345678123456781234567812345678912356789123',
'origin': 'https://ria.ee'
}
}
Expand All @@ -63,10 +63,10 @@ def test_3_sign(self):
message = {
'command': 'sign',
'arguments': {
'doc-hash': b64encode(b'x' * 48).decode('ascii'),
'hash-algo': 'SHA-384',
'hash': b64encode(b'x' * 48).decode('ascii'),
'hashFunction': 'SHA-384',
'origin': 'https://ria.ee',
'user-eid-cert': self.__class__.signingCertificate,
'certificate': self.__class__.signingCertificate,
}
}
response = self.exchange_message_with_app(message)
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/getcommandhandler-mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
using namespace std::string_literals;

const QVariantMap AUTHENTICATE_COMMAND_ARGUMENT = {
{"challenge-nonce", "12345678912345678912345678912345678912345678"},
{"challengeNonce", "12345678912345678912345678912345678912345678"},
{"origin", "https://ria.ee"},
};

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ void WebEidTests::getCertificate_outputsSupportedAlgos()
QSignalSpy certificateReadySpy(g_cached_GetCertificate.get(),
&GetCertificate::singleCertificateReady);
QVariantMap ES224_ALGO {
{"crypto-algo", "ECC"}, {"hash-algo", "SHA-224"}, {"padding-algo", "NONE"}};
{"cryptoAlgorithm", "ECC"}, {"hashFunction", "SHA-224"}, {"paddingScheme", "NONE"}};

// act
runEventLoopVerifySignalsEmitted(certificateReadySpy);

// assert
QCOMPARE(controller->result()["supported-signature-algos"].toList()[0].toMap(), ES224_ALGO);
QCOMPARE(controller->result()["supportedSignatureAlgorithms"].toList()[0].toMap(), ES224_ALGO);
}

void WebEidTests::authenticate_validArgumentsResultInValidToken()
Expand Down

0 comments on commit c883b6c

Please sign in to comment.