-
Notifications
You must be signed in to change notification settings - Fork 6
CryptoHelper implementation #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature_unification
Are you sure you want to change the base?
CryptoHelper implementation #354
Conversation
e683971
to
ad69154
Compare
ad69154
to
e7961c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Mykhailo Lohvynenko <[email protected]>
Move all crypto interfaces into itf folder and crypto.md with class diagram and basic module description. I've added separate task to add full crypto design document. |
* @param[out] urls result URLs. | ||
* @return Error. | ||
*/ | ||
Error GetServiceDiscoveryURLs(Array<StaticString<cURLLen>>& urls); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this function should be moved to communication module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
under discussion
/** | ||
* Stub implementation of CertProviderItf. | ||
*/ | ||
class CertProviderStub : public iam::certhandler::CertProviderItf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be usefull to put it into separate file under common/tests/stubs/certproviderstub.hpp
src/core/common/config.hpp
Outdated
/** | ||
* Maximum number of private keys in crypto provider. | ||
*/ | ||
#ifndef AOS_CONFIG_CRYPTO_MAX_PRIV_KEY_COUNT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have AOS_CONFIG_CRYPTO_KEYS_COUNT I guess it can be used here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
* Private | ||
**********************************************************************************************************************/ | ||
|
||
Time MbedTLSCryptoProvider::mCurrentTime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to static section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed in the latest commit
c85584b
to
d7a1e9f
Compare
const Array<uint8_t>& cipher, const crypto::DecryptionOptions& options, Array<uint8_t>& result) const | ||
{ | ||
CK_MECHANISM mechanism = {CKM_RSA_PKCS, nullptr, 0}; | ||
struct PCKS11MechConverter : public StaticVisitor<RetWithError<CK_MECHANISM>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it could be used by some other methods in future
/** | ||
* Max number of certificates. | ||
*/ | ||
constexpr auto cMaxNumCertificates = AOS_CONFIG_CRYPTO_MAX_NUM_CERTIFICATES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move it to types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically, it mostly used in crypto module. all others still have to include crypto to have certificate type. so I'd keep it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then other consts related to crypto should be moved there, for example:
/**
- SHA256 size.
*/
constexpr auto cSHA256Size = 32;
/**
- SHA3-224 size.
*/
constexpr auto cSHA3_224Size = 28;
auto worker = [&]() { | ||
LockGuard lock {sem}; | ||
|
||
int cur = ++currentRunning; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is potential race condition between inc currentRunning and store load max running. Butter to do not use atomic here but just use mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed with mutex
|
||
static constexpr size_t cReadChunkSize = 1024; | ||
|
||
static constexpr auto cMaxSimultaneousThreads = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add AOS_CONFIG_TYPES_MUX_CONCURRENT_ITEMS to types. It will be used for other modules as well.
std::vector<TestData> testData = { | ||
{{online, intermediateCA, secondaryCA}, CreateCertChain("online", {"online", "intermediateCA", "secondaryCA"}), | ||
CreateSigns("online", "RSA/SHA256/PKCS1v1_5")}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Verify target certificate. | ||
uint32_t flags = 0; | ||
int ret = mbedtls_x509_crt_verify(&interm, &root, nullptr, nullptr, &flags, nullptr, nullptr); | ||
int ret = mbedtls_x509_crt_verify( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (!err.IsNone()) { | ||
*flags |= MBEDTLS_X509_BADCERT_OTHER; | ||
|
||
return 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return MBEDTLS_ERR_X509_CERT_VERIFY_FAILED; ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems MBEDTLS_ERR_X509_CERT_VERIFY_FAILED is an error code, not flag
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Add AES encoder/decoder interfaces Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
Signed-off-by: Mykola Kobets <[email protected]>
b4c7253
to
ab4e128
Compare
Signed-off-by: Mykola Kobets <[email protected]>
683b94c
to
32efc60
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature_unification #354 +/- ##
=======================================================
- Coverage 81.44% 80.28% -1.17%
=======================================================
Files 179 183 +4
Lines 17231 19487 +2256
Branches 2320 2730 +410
=======================================================
+ Hits 14034 15645 +1611
- Misses 3197 3842 +645 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Mykola Solianko <[email protected]>
* @param[out] buffer destination buffer. | ||
* @return Error. | ||
*/ | ||
Error WriteBlock(Array<uint8_t>& buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider accepting a const ref and returning RetWithError<size_t> bytes written
@@ -0,0 +1,406 @@ | |||
# | |||
# Copyright (C) 2024 Renesas Electronics Corporation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright (C) 2024 Renesas Electronics Corporation. |
@@ -0,0 +1,406 @@ | |||
# | |||
# Copyright (C) 2024 Renesas Electronics Corporation. | |||
# Copyright (C) 2024 EPAM Systems, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Copyright (C) 2024 EPAM Systems, Inc. | |
# Copyright (C) 2025 EPAM Systems, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Mykhailo Lohvynenko <[email protected]>
No description provided.