#include "timer.h"
#include <netdb.h>
+/* tinyDTLS library error code */
+#define TINY_DTLS_ERROR (-1)
+/* tinyDTLS library success code */
+#define TINY_DTLS_SUCCESS (0)
+
#ifdef __WITH_X509__
#include "pki.h"
#include "crl.h"
if (NULL == g_caDtlsContext)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "Context is NULL");
- return 0;
+ return TINY_DTLS_ERROR;
}
int type = 0;
}
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
- return 0;
+ return TINY_DTLS_SUCCESS;
}
static int32_t CASendSecureData(dtls_context_t *context,
}
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
- return 0;
+ return TINY_DTLS_SUCCESS;
}
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
- int32_t ret = -1;
+ int32_t ret = TINY_DTLS_ERROR;
if(NULL == ctx || NULL == session || NULL == result)
{
OIC_LOG(ERROR, NET_DTLS_TAG, "CAGetPskCredentials invalid parameters");
static int CAIsX509Active(struct dtls_context_t *ctx)
{
(void)ctx;
- return 0;
+ return TINY_DTLS_SUCCESS;
}
static int CAGetDeviceKey(struct dtls_context_t *ctx,
OIC_LOG(DEBUG, NET_DTLS_TAG, "CAGetDeviceKey");
static dtls_ecc_key_t ecdsa_key = {DTLS_ECDH_CURVE_SECP256R1, NULL, NULL, NULL};
- int ret = 1;
+ int ret = TINY_DTLS_ERROR;
VERIFY_SUCCESS(CAInitX509(), 0);
ecdsa_key.priv_key = g_X509Cred.devicePrivateKey;
*result = &ecdsa_key;
- ret = 0;
+ ret = TINY_DTLS_SUCCESS;
exit:
return ret;
}
size_t *cert_size)
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "CAGetDeviceCertificate");
- int ret = 1;
+ int ret = TINY_DTLS_ERROR;
VERIFY_SUCCESS(CAInitX509(), 0);
PRINT_BYTE_ARRAY("OWN CERT: \n", ownCert);
#endif
- ret = 0;
+ ret = TINY_DTLS_SUCCESS;
exit:
return ret;
}
uint8_t chainLength;
- int ret;
+ int ret = TINY_DTLS_ERROR;
const unsigned char *ca_pub_x;
const unsigned char *ca_pub_y;
ByteArray certDerCode = BYTE_ARRAY_INITIALIZER;
if ( !ctx || !session || !cert || !x || !y)
{
- return -PKI_NULL_PASSED;
+ return TINY_DTLS_ERROR;
}
CAGetRootKey (&ca_pub_x, &ca_pub_y);
exit:
if (ret != 0)
{
- OIC_LOG(DEBUG, NET_DTLS_TAG, "Certificate verification FAILED\n");
+ OIC_LOG(ERROR, NET_DTLS_TAG, "Certificate verification FAILED\n");
+ return TINY_DTLS_ERROR;
}
else
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "Certificate verification SUCCESS\n");
+ return TINY_DTLS_SUCCESS;
}
- return -ret;
}
#endif