Commit 8f37bf98 authored by Kishen Maloor's avatar Kishen Maloor

Rename constants OC_KEYPAIR_* to OC_ECDSA_*

Signed-off-by: Kishen Maloor's avatarKishen Maloor <kishen.maloor@intel.com>
Change-Id: I25dd3b9922c9c22c9ef2b97265915ad593e661b8
parent 98e2edf0
......@@ -791,7 +791,7 @@ oc_certs_validate_csr(const unsigned char *csr, size_t csr_len,
oc_new_string(subject_DN, DN, ret);
ret = mbedtls_pk_write_pubkey_der((mbedtls_pk_context *)&c.pk, public_key,
OC_KEYPAIR_PUBKEY_SIZE);
OC_ECDSA_PUBKEY_SIZE);
if (ret < 0) {
OC_ERR("unable to read public key from CSR %d", ret);
}
......@@ -838,7 +838,7 @@ oc_certs_generate_csr(size_t device, unsigned char *csr, size_t csr_len)
mbedtls_pk_init(&pk);
int ret =
mbedtls_pk_parse_public_key(&pk, kp->public_key, OC_KEYPAIR_PUBKEY_SIZE);
mbedtls_pk_parse_public_key(&pk, kp->public_key, OC_ECDSA_PUBKEY_SIZE);
if (ret != 0) {
OC_ERR("could not parse public key for device %zd", device);
goto generate_csr_error;
......
......@@ -77,14 +77,14 @@ oc_sec_decode_ecdsa_keypair(oc_rep_t *rep, size_t device)
if (rep->type == OC_REP_BYTE_STRING) {
if (oc_string_len(rep->name) == 10 &&
memcmp("public_key", oc_string(rep->name), 10) == 0) {
if (oc_string_len(rep->value.string) != OC_KEYPAIR_PUBKEY_SIZE) {
if (oc_string_len(rep->value.string) != OC_ECDSA_PUBKEY_SIZE) {
return false;
}
memcpy(kp->public_key, oc_cast(rep->value.string, uint8_t),
OC_KEYPAIR_PUBKEY_SIZE);
OC_ECDSA_PUBKEY_SIZE);
} else if (oc_string_len(rep->name) == 11 &&
memcmp("private_key", oc_string(rep->name), 11) == 0) {
if (oc_string_len(rep->value.string) > OC_KEYPAIR_PRIVKEY_SIZE) {
if (oc_string_len(rep->value.string) > OC_ECDSA_PRIVKEY_SIZE) {
return false;
}
memcpy(kp->private_key, oc_cast(rep->value.string, uint8_t),
......@@ -108,7 +108,7 @@ oc_sec_encode_ecdsa_keypair(size_t device)
oc_rep_start_root_object();
oc_rep_set_byte_string(root, public_key, kp->public_key,
OC_KEYPAIR_PUBKEY_SIZE);
OC_ECDSA_PUBKEY_SIZE);
oc_rep_set_byte_string(root, private_key, kp->private_key,
kp->private_key_size);
oc_rep_end_root_object();
......@@ -196,8 +196,8 @@ oc_generate_ecdsa_keypair_for_device(size_t device)
size_t public_key_size = 0;
if (oc_generate_ecdsa_keypair(
kp->public_key, OC_KEYPAIR_PUBKEY_SIZE, &public_key_size,
kp->private_key, OC_KEYPAIR_PRIVKEY_SIZE, &kp->private_key_size) < 0) {
kp->public_key, OC_ECDSA_PUBKEY_SIZE, &public_key_size, kp->private_key,
OC_ECDSA_PRIVKEY_SIZE, &kp->private_key_size) < 0) {
oc_memb_free(&oc_keypairs_s, kp);
return -1;
}
......
......@@ -26,15 +26,15 @@ extern "C"
{
#endif
#define OC_KEYPAIR_PUBKEY_SIZE (91)
#define OC_KEYPAIR_PRIVKEY_SIZE (200)
#define OC_ECDSA_PUBKEY_SIZE (91)
#define OC_ECDSA_PRIVKEY_SIZE (200)
typedef struct oc_ecdsa_keypair_t
{
struct oc_ecdsa_keypair_t *next;
size_t device;
uint8_t public_key[OC_KEYPAIR_PUBKEY_SIZE];
uint8_t private_key[OC_KEYPAIR_PRIVKEY_SIZE];
uint8_t public_key[OC_ECDSA_PUBKEY_SIZE];
uint8_t private_key[OC_ECDSA_PRIVKEY_SIZE];
size_t private_key_size;
} oc_ecdsa_keypair_t;
......
......@@ -82,7 +82,7 @@ OC_LIST(oc_cache);
/* Public/Private key-pair for the local domain's root of trust */
#ifdef OC_PKI
const char *root_subject = "C=US, O=OCF, CN=IoTivity-Lite OBT Root";
uint8_t private_key[OC_KEYPAIR_PRIVKEY_SIZE];
uint8_t private_key[OC_ECDSA_PRIVKEY_SIZE];
size_t private_key_size;
int root_cert_credid;
#endif /* OC_PKI */
......@@ -1221,7 +1221,7 @@ device_CSR(oc_client_response_t *data)
oc_string_t subject, cert;
memset(&subject, 0, sizeof(oc_string_t));
memset(&cert, 0, sizeof(oc_string_t));
uint8_t pub_key[OC_KEYPAIR_PUBKEY_SIZE];
uint8_t pub_key[OC_ECDSA_PUBKEY_SIZE];
if (data->code >= OC_STATUS_BAD_REQUEST) {
goto err_device_CSR;
......@@ -1258,13 +1258,13 @@ device_CSR(oc_client_response_t *data)
/** 5) generate identity cert
*/
ret = oc_obt_generate_identity_cert(oc_string(subject), pub_key,
OC_KEYPAIR_PUBKEY_SIZE, root_subject,
OC_ECDSA_PUBKEY_SIZE, root_subject,
private_key, private_key_size, &cert);
} else {
/** 5) generate role cert
*/
ret = oc_obt_generate_role_cert(p->roles, oc_string(subject), pub_key,
OC_KEYPAIR_PUBKEY_SIZE, root_subject,
OC_ECDSA_PUBKEY_SIZE, root_subject,
private_key, private_key_size, &cert);
}
if (ret < 0) {
......@@ -2641,18 +2641,18 @@ oc_obt_init(void)
oc_sec_dump_acl(0);
#ifdef OC_PKI
uint8_t public_key[OC_KEYPAIR_PUBKEY_SIZE];
uint8_t public_key[OC_ECDSA_PUBKEY_SIZE];
size_t public_key_size = 0;
if (oc_generate_ecdsa_keypair(
public_key, OC_KEYPAIR_PUBKEY_SIZE, &public_key_size, private_key,
OC_KEYPAIR_PRIVKEY_SIZE, &private_key_size) < 0) {
public_key, OC_ECDSA_PUBKEY_SIZE, &public_key_size, private_key,
OC_ECDSA_PRIVKEY_SIZE, &private_key_size) < 0) {
OC_ERR("oc_obt: could not generate ECDSA keypair for local domain root "
"certificate");
} else if (public_key_size != OC_KEYPAIR_PUBKEY_SIZE) {
} else if (public_key_size != OC_ECDSA_PUBKEY_SIZE) {
OC_ERR("oc_obt: invalid ECDSA keypair for local domain root certificate");
} else {
root_cert_credid = oc_obt_generate_self_signed_root_cert(
root_subject, public_key, OC_KEYPAIR_PUBKEY_SIZE, private_key,
root_subject, public_key, OC_ECDSA_PUBKEY_SIZE, private_key,
private_key_size);
if (root_cert_credid > 0) {
oc_obt_dump_state();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment