[crypto] update method documentation and style (#5015)

This commit is contained in:
Abtin Keshavarzian
2020-05-28 22:02:22 -07:00
committed by Jonathan Hui
parent f640774684
commit 615bf36d88
9 changed files with 24 additions and 18 deletions
+2 -2
View File
@@ -36,7 +36,7 @@
namespace ot {
namespace Crypto {
AesEcb::AesEcb()
AesEcb::AesEcb(void)
{
mbedtls_aes_init(&mContext);
}
@@ -51,7 +51,7 @@ void AesEcb::Encrypt(const uint8_t aInput[kBlockSize], uint8_t aOutput[kBlockSiz
mbedtls_aes_crypt_ecb(&mContext, MBEDTLS_AES_ENCRYPT, aInput, aOutput);
}
AesEcb::~AesEcb()
AesEcb::~AesEcb(void)
{
mbedtls_aes_free(&mContext);
}
+3 -3
View File
@@ -64,19 +64,19 @@ public:
* Constructor to initialize the mbedtls_aes_context.
*
*/
AesEcb();
AesEcb(void);
/**
* Destructor to free the mbedtls_aes_context.
*
*/
~AesEcb();
~AesEcb(void);
/**
* This method sets the key.
*
* @param[in] aKey A pointer to the key.
* @param[in] aKeyLength The key length in bytes.
* @param[in] aKeyLength The key length in bits.
*
*/
void SetKey(const uint8_t *aKey, uint16_t aKeyLength);
+1
View File
@@ -72,6 +72,7 @@ public:
* @retval OT_ERROR_NO_BUFS Output buffer is too small.
* @retval OT_ERROR_INVALID_ARGS Private key is not valid EC Private Key.
* @retval OT_ERROR_FAILED Error during signing.
*
*/
static otError Sign(uint8_t * aOutput,
uint16_t * aOutputLength,
+2 -2
View File
@@ -36,7 +36,7 @@
namespace ot {
namespace Crypto {
HmacSha256::HmacSha256()
HmacSha256::HmacSha256(void)
{
const mbedtls_md_info_t *mdInfo = NULL;
mbedtls_md_init(&mContext);
@@ -44,7 +44,7 @@ HmacSha256::HmacSha256()
mbedtls_md_setup(&mContext, mdInfo, 1);
}
HmacSha256::~HmacSha256()
HmacSha256::~HmacSha256(void)
{
mbedtls_md_free(&mContext);
}
+2 -2
View File
@@ -66,13 +66,13 @@ public:
* Constructor for initialization of mbedtls_md_context_t.
*
*/
HmacSha256();
HmacSha256(void);
/**
* Destructor for freeing of mbedtls_md_context_t.
*
*/
~HmacSha256();
~HmacSha256(void);
/**
* This method sets the key.
+3 -3
View File
@@ -74,11 +74,11 @@ MbedTls::MbedTls(void)
#endif // !OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE && OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT
}
otError MbedTls::MapError(int rval)
otError MbedTls::MapError(int aMbedTlsError)
{
otError error = OT_ERROR_NONE;
switch (rval)
switch (aMbedTlsError)
{
#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
case MBEDTLS_ERR_PK_TYPE_MISMATCH:
@@ -154,7 +154,7 @@ otError MbedTls::MapError(int rval)
break;
default:
OT_ASSERT(rval >= 0);
OT_ASSERT(aMbedTlsError >= 0);
break;
}
+7 -2
View File
@@ -64,9 +64,14 @@ public:
MbedTls(void);
/**
* This method converts from MbedTls error to OpenThread error.
* This method converts an mbed TLS error to OpenThread error.
*
* @param[in] aMbedTlsError The mbed TLS error.
*
* @returns The mapped otError.
*
*/
static otError MapError(int rval);
static otError MapError(int aMbedTlsError);
};
/**
+2 -2
View File
@@ -36,12 +36,12 @@
namespace ot {
namespace Crypto {
Sha256::Sha256()
Sha256::Sha256(void)
{
mbedtls_sha256_init(&mContext);
}
Sha256::~Sha256()
Sha256::~Sha256(void)
{
mbedtls_sha256_free(&mContext);
}
+2 -2
View File
@@ -66,13 +66,13 @@ public:
* Constructor for initializing mbedtls_sha256_context.
*
*/
Sha256();
Sha256(void);
/**
* Destructor for freeing mbedtls_sha256_context.
*
*/
~Sha256();
~Sha256(void);
/**
* This method starts the SHA-256 computation.