Skip to content

Commit

Permalink
make_pretty changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnulf Rupp committed Aug 14, 2023
1 parent bf495e9 commit 5a8d154
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 167 deletions.
14 changes: 6 additions & 8 deletions include/openthread/ble_secure.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void otBleSecureSetPsk(otInstance *aInstance,
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aPeerCert A pointer to the base64 encoded certificate buffer.
* @param[in,out] aCertLength On input, the size the max size of @p aPeerCert.
* @param[in,out] aCertLength On input, the size the max size of @p aPeerCert.
* On output, the length of the base64 encoded peer certificate.
*
* @retval OT_ERROR_NONE Successfully get the peer certificate.
Expand All @@ -168,9 +168,7 @@ void otBleSecureSetPsk(otInstance *aInstance,
* @retval OT_ERROR_NO_BUFS Can't allocate memory for certificate.
*
*/
otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength);
otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength);

/**
* Returns an attribute value identified by its OID from the subject
Expand All @@ -186,7 +184,7 @@ otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance,
* @param[in] aOid A pointer to the OID to be found.
* @param[in] aOidLength The length of the OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
* @param[out] aAns1Type A pointer to the ANS1 type of the attribute written to the buffer.
*
Expand Down Expand Up @@ -215,7 +213,7 @@ otError otBleSecureGetPeerSubjectAttributeByOid(otInstance *aInstance,
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval OT_ERROR_NONE Successfully read attribute.
Expand All @@ -241,7 +239,7 @@ otError otBleSecureGetThreadAttributeFromPeerCertificate(otInstance *aInstance,
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval OT_ERROR_NONE Successfully read attribute.
Expand All @@ -267,7 +265,7 @@ otError otBleSecureGetThreadAttributeFromOwnCertificate(otInstance *aInstance,
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval OT_ERROR_NONE Successfully read attribute.
Expand Down
1 change: 0 additions & 1 deletion include/openthread/platform/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ extern "C" {

#define OT_BLE_ATT_MTU_MAX 67


/**
* Represents a BLE packet.
*
Expand Down
21 changes: 10 additions & 11 deletions include/openthread/tcat.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ extern "C" {
#define OT_TCAT_MAX_SERVICE_NAME_LENGTH \
15 ///< Maximum string length of a UDP or TCP service name (does not include null char).


/**
* Represents TCAT status code.
*
Expand All @@ -80,9 +79,9 @@ typedef enum otTcatStatusCode
OT_TCAT_STATUS_VALUE_ERROR = 3, ///< The value of the transmitted TLV has an error
OT_TCAT_STATUS_GENERAL_ERROR = 4, ///< An error not matching any other category occurred
OT_TCAT_STATUS_BUSY = 5, ///< Command cannot be executed because the resource is busy
OT_TCAT_STATUS_UNDEFINED = 6, ///< The requested value, data or service is not defined (currently) or not present
OT_TCAT_STATUS_HASH_ERROR = 7, ///< The hash value presented by the commissioner was incorrect
OT_TCAT_STATUS_UNAUTHORIZED = 8, ///< Sender does not have sufficient authorization for the given command
OT_TCAT_STATUS_UNDEFINED = 6, ///< The requested value, data or service is not defined (currently) or not present
OT_TCAT_STATUS_HASH_ERROR = 7, ///< The hash value presented by the commissioner was incorrect
OT_TCAT_STATUS_UNAUTHORIZED = 8, ///< Sender does not have sufficient authorization for the given command

} otTcatStatusCode;

Expand All @@ -103,20 +102,20 @@ typedef enum otTcatMessageType

/**
* Represents TCAT a command class.
*
*
*/
typedef enum otTcatCommandClass
{
OT_TCAT_COMMAND_CLASS_COMMISSIONING = 1, ///< TCAT commands related to commissioning
OT_TCAT_COMMAND_CLASS_EXTRACTION = 2, ///< TCAT commands related to key extraction
OT_TCAT_COMMAND_CLASS_DECOMMISSIONING = 3, ///< TCAT commands related to de-commissioning
OT_TCAT_COMMAND_CLASS_APPLICATION = 4, ///< TCAT commands related to application layer
OT_TCAT_COMMAND_CLASS_COMMISSIONING = 1, ///< TCAT commands related to commissioning
OT_TCAT_COMMAND_CLASS_EXTRACTION = 2, ///< TCAT commands related to key extraction
OT_TCAT_COMMAND_CLASS_DECOMMISSIONING = 3, ///< TCAT commands related to de-commissioning
OT_TCAT_COMMAND_CLASS_APPLICATION = 4, ///< TCAT commands related to application layer

} otTcatCommandClass;

/**
* This structure represents a TCAT vendor information.
*
*
* The content of this structure MUST persist and remain unchanged while a TCAT session is running.
*
*/
Expand All @@ -129,7 +128,7 @@ typedef struct otTcatVendorInfo
const char *mVendorData; ///< Vendor specific data string
const char *mPskdString; ///< Vendor managed pre-shared key for device
const char *mInstallCode; ///< Vendor managed install code string
const char *mDeviceId; ///< Vendor managed device ID string (if NULL: device ID is set to EUI-64 in binary format)
const char *mDeviceId; ///< Vendor managed device ID string (if NULL: device ID is set to EUI-64 in binary format)

} otTcatVendorInfo;

Expand Down
26 changes: 13 additions & 13 deletions src/cli/cli_tcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

#if OPENTHREAD_CONFIG_BLE_TCAT_ENABLE && OPENTHREAD_CONFIG_BLE_SECURE_CLI_ENABLE

#define OT_CLI_BBTC_X509_CERT \
"-----BEGIN CERTIFICATE-----\r\n" \
#define OT_CLI_BBTC_X509_CERT \
"-----BEGIN CERTIFICATE-----\r\n" \
"MIIBezCCASKgAwIBAgIEAQIDBDAKBggqhkjOPQQDAjBaMQswCQYDVQQGEwJERTER\r\n" \
"MA8GA1UEBxMIR2FyY2hpbmcxDDAKBgNVBAsTA1NUQTERMA8GA1UEChMITXlWZW5k\r\n" \
"b3IxFzAVBgNVBAMTDm9wdG90cm9uaWMuY29tMB4XDTIzMDgwODEwNDI0OVoXDTI0\r\n" \
Expand All @@ -52,15 +52,15 @@
"bRcWg8L4mHdYS5+lRwIgRM4b1eItMNpFTSLq174ZIjtq96QSEHA/8yS1UPyo9MM=\r\n" \
"-----END CERTIFICATE-----\r\n"

#define OT_CLI_BBTC_PRIV_KEY \
"-----BEGIN EC PRIVATE KEY-----\r\n" \
#define OT_CLI_BBTC_PRIV_KEY \
"-----BEGIN EC PRIVATE KEY-----\r\n" \
"MHcCAQEEIHqCO3YjGKu1469GTKwS+w+1MHCMwKPtN+yreiXbn0b5oAoGCCqGSM49\r\n" \
"AwEHoUQDQgAED3i3op7pdhAk8QvpytITPSrnhsFVg6SZhbFbAmw9fCTGOomXDYAR\r\n" \
"z2h3lSHxVdZUKjsn2bDX3s0PJ4urbpZhLg==\r\n" \
"z2h3lSHxVdZUKjsn2bDX3s0PJ4urbpZhLg==\r\n" \
"-----END EC PRIVATE KEY-----\r\n"

#define OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE \
"-----BEGIN CERTIFICATE-----\r\n" \
#define OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE \
"-----BEGIN CERTIFICATE-----\r\n" \
"MIIB3TCCAYOgAwIBAgIJAIEkU9Kpk7sQMAoGCCqGSM49BAMCMFoxCzAJBgNVBAYT\r\n" \
"AkRFMREwDwYDVQQHEwhHYXJjaGluZzEMMAoGA1UECxMDU1RBMREwDwYDVQQKEwhN\r\n" \
"eVZlbmRvcjEXMBUGA1UEAxMOb3B0b3Ryb25pYy5jb20wHhcNMjMwMzI0MjMwODI2\r\n" \
Expand All @@ -71,10 +71,9 @@
"F2AwIs/TLaMyMDAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUDf0KHNxzEy7q\r\n" \
"znA405Fx1lQsRLowCgYIKoZIzj0EAwIDSAAwRQIhAPDKNTxO8sLkns1y7ec2w2oR\r\n" \
"CYoQyDj2d498XeWYkSVuAiBz+GSRnTmdCFzQKfL8/ma7QaNdXihKYrWUdqvlynVV\r\n" \
"MQ==\r\n" \
"MQ==\r\n" \
"-----END CERTIFICATE-----\r\n"


namespace ot {

namespace Cli {
Expand All @@ -92,10 +91,10 @@ static void HandleBleSecureReceive(otInstance *aInstance,
OT_UNUSED_VARIABLE(aContext);
OT_UNUSED_VARIABLE(aTcatMessageType);
OT_UNUSED_VARIABLE(aServiceName);
static constexpr int kTextMaxLen = 100;
static constexpr int kTextMaxLen = 100;
static constexpr uint8_t kBufPrefixLen = 5;
uint16_t nLen;
uint8_t buf[kTextMaxLen];
uint16_t nLen;
uint8_t buf[kTextMaxLen];

nLen = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf + kBufPrefixLen, sizeof(buf) - kBufPrefixLen - 1);

Expand All @@ -120,7 +119,8 @@ template <> otError Tcat::Process<Cmd("start")>(Arg aArgs[])
sizeof(OT_CLI_BBTC_X509_CERT), reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_PRIV_KEY),
sizeof(OT_CLI_BBTC_PRIV_KEY));

otBleSecureSetCaCertificateChain(GetInstancePtr(), reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE),
otBleSecureSetCaCertificateChain(GetInstancePtr(),
reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE),
sizeof(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE));

otBleSecureSetSslAuthMode(GetInstancePtr(), true);
Expand Down
12 changes: 4 additions & 8 deletions src/core/api/ble_secure_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "meshcop/tcat_agent.hpp"
#include "radio/ble_secure.hpp"


using namespace ot;

otError otBleSecureStart(otInstance *aInstance,
Expand Down Expand Up @@ -78,9 +77,7 @@ void otBleSecureSetPsk(otInstance *aInstance,
#endif // MBEDTLS_KEY_EXCHANGE_PSK_ENABLED

#if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance,
unsigned char *aPeerCert,
size_t *aCertLength)
otError otBleSecureGetPeerCertificateBase64(otInstance *aInstance, unsigned char *aPeerCert, size_t *aCertLength)
{
return AsCoreType(aInstance).Get<Ble::BleSecure>().GetPeerCertificateBase64(aPeerCert, aCertLength);
}
Expand All @@ -94,8 +91,8 @@ otError otBleSecureGetPeerSubjectAttributeByOid(otInstance *aInstance,
size_t *aAttributeLength,
int *aAns1Type)
{
return AsCoreType(aInstance).Get<Ble::BleSecure>().GetPeerSubjectAttributeByOid(
aOid, aOidLength, aAttributeBuffer, aAttributeLength, aAns1Type);
return AsCoreType(aInstance).Get<Ble::BleSecure>().GetPeerSubjectAttributeByOid(aOid, aOidLength, aAttributeBuffer,
aAttributeLength, aAns1Type);
}

otError otBleSecureGetThreadAttributeFromPeerCertificate(otInstance *aInstance,
Expand Down Expand Up @@ -182,7 +179,7 @@ bool otBleSecureIsPskcVerified(otInstance *aInstance)
bool otBleSecureIsCommandClassAuthorized(otInstance *aInstance, otTcatCommandClass aCommandClass)
{
return AsCoreType(aInstance).Get<Ble::BleSecure>().IsCommandClassAuthorized(
static_cast<Ble::BleSecure::CommandClass>(aCommandClass));
static_cast<Ble::BleSecure::CommandClass>(aCommandClass));
}

otError otBleSecureSendMessage(otInstance *aInstance, otMessage *aMessage)
Expand All @@ -202,5 +199,4 @@ otError otBleSecureSendApplicationTlv(otInstance *aInstance, uint8_t *aBuf, uint

otError otBleSecureFlush(otInstance *aInstance) { return AsCoreType(aInstance).Get<Ble::BleSecure>().Flush(); }


#endif // OPENTHREAD_CONFIG_BLE_TCAT_ENABLE
6 changes: 3 additions & 3 deletions src/core/meshcop/dtls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ Error Dtls::GetPeerSubjectAttributeByOid(const char *aOid,

VerifyOrExit(aAttributeLength != nullptr, error = kErrorInvalidArgs);
attributeBufferSize = *aAttributeLength;
*aAttributeLength = 0;
*aAttributeLength = 0;

VerifyOrExit(aAttributeBuffer != nullptr, error = kErrorNoBufs);
VerifyOrExit(peerCert != nullptr, error = kErrorInvalidState);
data = mbedtls_asn1_find_named_data(&peerCert->subject, aOid, aOidLength);
Expand Down Expand Up @@ -670,7 +670,7 @@ Error Dtls::GetThreadAttributeFromCertificate(const mbedtls_x509_crt *aCert,

VerifyOrExit(aAttributeLength != nullptr, error = kErrorInvalidArgs);
attributeBufferSize = *aAttributeLength;
*aAttributeLength = 0;
*aAttributeLength = 0;

VerifyOrExit(aCert != nullptr, error = kErrorInvalidState);
v3_ext = aCert->v3_ext;
Expand Down
12 changes: 6 additions & 6 deletions src/core/meshcop/dtls.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class Dtls : public InstanceLocator
* @param[in] aOid A pointer to the OID to be found.
* @param[in] aOidLength The length of the OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
* @param[out] aAns1Type A pointer to the ANS1 type of the attribute written to the buffer.
*
Expand All @@ -325,8 +325,8 @@ class Dtls : public InstanceLocator
*
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval kErrorNone Successfully read attribute.
* @retval kErrorInvalidArgs Invalid attribute length.
Expand All @@ -350,7 +350,7 @@ class Dtls : public InstanceLocator
*
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval kErrorNone Successfully read attribute.
Expand All @@ -374,8 +374,8 @@ class Dtls : public InstanceLocator
*
* @param[in] aThreadOidDescriptor The last digit of the Thread attribute OID.
* @param[out] aAttributeBuffer A pointer to the attribute buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
* @param[in,out] aAttributeLength On input, the size the max size of @p aAttributeBuffer.
* On output, the length of the attribute written to the buffer.
*
* @retval kErrorNone Successfully read attribute.
* @retval kErrorInvalidArgs Invalid attribute length.
Expand Down
Loading

0 comments on commit 5a8d154

Please sign in to comment.