Loading src/lib/kinetic_exchange.c +8 −0 Original line number Diff line number Diff line Loading @@ -24,11 +24,19 @@ void KineticExchange_Init( KineticExchange* const exchange, int64_t identity, uint8_t* key, size_t keyLength, int64_t connectionID, KineticConnection* const connection) { memset(exchange, 0, sizeof(KineticExchange)); exchange->identity = identity; if (key != NULL && keyLength > 0) { memcpy(&exchange->key, key, keyLength); exchange->keyLength = keyLength; exchange->has_key = true; } exchange->connectionID = connectionID; exchange->connection = connection; } Loading src/lib/kinetic_exchange.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,13 @@ typedef struct _KineticExchange // HMAC key (shared secret) to verify the HMAC. int64_t identity; // Required field // This is the identity's HMAC Key. This is a shared secret between the // client and the device, used to sign requests. bool has_key; size_t keyLength; uint8_t key[KINETIC_MAX_KEY_LEN]; // Required field // A unique number for this connection between the source and target. // On the first request to the drive, this should be the time of day in Loading @@ -61,6 +68,8 @@ typedef struct _KineticExchange void KineticExchange_Init( KineticExchange* const exchange, int64_t identity, uint8_t* key, size_t keyLength, int64_t connectionID, KineticConnection* const connection); Loading src/lib/kinetic_message.c +3 −13 Original line number Diff line number Diff line Loading @@ -20,22 +20,12 @@ #include "kinetic_types.h" #include "kinetic_message.h" #include "kinetic_hmac.h" void KineticMessage_Init(KineticMessage* const message) { // Initialize protobuf fields KineticProto_init(&message->proto); KineticProto_command_init(&message->command); KineticProto_header_init(&message->header); KineticProto_body_init(&message->body); KineticProto_status_init(&message->status); // Assemble the message message->proto.hmac.data = message->hmacData; message->command.header = &message->header; message->command.body = &message->body; message->command.status = &message->status; message->proto.command = &message->command; // Initialize protobuf fields and ssemble the message KINETIC_MESSSAGE_INIT(message); } void KineticMessage_BuildNoop(KineticMessage* const message) Loading src/lib/kinetic_message.h +8 −9 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ #include "kinetic_proto.h" #include <openssl/sha.h> // #define KINETIC_HMAC_SHA1_LEN (SHA_DIGEST_LENGTH) typedef struct _KineticMessage { // Kinetic Protocol Buffer Elements Loading @@ -35,6 +32,8 @@ typedef struct _KineticMessage KineticProto_Header header; KineticProto_Body body; KineticProto_Status status; KineticProto_Security security; KineticProto_Security_ACL acl; uint8_t hmacData[SHA_DIGEST_LENGTH]; } KineticMessage; Loading src/lib/kinetic_types.h +25 −1 Original line number Diff line number Diff line Loading @@ -26,12 +26,15 @@ #include <stdbool.h> #endif #include <stdint.h> #include <assert.h> #include <stddef.h> #include <string.h> #include <stdio.h> #include <assert.h> #include <limits.h> #include <netinet/in.h> #include <ifaddrs.h> // Windows doesn't use <unistd.h> nor does it define HOST_NAME_MAX. #if defined(WIN32) #include <windows.h> Loading Loading @@ -69,4 +72,25 @@ typedef struct _KineticConnection char Host[HOST_NAME_MAX]; } KineticConnection; #include <protobuf-c/protobuf-c.h> #include "kinetic_proto.h" #include "kinetic_message.h" #define KINETIC_MAX_KEY_LEN 128 #define KINETIC_MESSSAGE_INIT(msg) \ msg->proto = KINETIC_PROTO_INIT; \ msg->command = KINETICPROTO_COMMAND_INIT; \ msg->header = KINETIC_PROTO_HEADER_INIT; \ msg->body = KINETIC_PROTO_BODY_INIT; \ msg->status = KINETIC_PROTO_STATUS_INIT; \ msg->security = KINETIC_PROTO_SECURITY_INIT; \ msg->acl = KINETIC_PROTO_SECURITY_ACL_INIT; \ msg->proto.hmac.data = msg->hmacData; \ msg->command.header = &msg->header; \ msg->command.body = &msg->body; \ msg->command.status = &msg->status; \ msg->proto.command = &msg->command; \ msmset(msg->hmac_data, 0, SHA_DIGEST_LENGTH); #endif // _KINETIC_TYPES_H Loading
src/lib/kinetic_exchange.c +8 −0 Original line number Diff line number Diff line Loading @@ -24,11 +24,19 @@ void KineticExchange_Init( KineticExchange* const exchange, int64_t identity, uint8_t* key, size_t keyLength, int64_t connectionID, KineticConnection* const connection) { memset(exchange, 0, sizeof(KineticExchange)); exchange->identity = identity; if (key != NULL && keyLength > 0) { memcpy(&exchange->key, key, keyLength); exchange->keyLength = keyLength; exchange->has_key = true; } exchange->connectionID = connectionID; exchange->connection = connection; } Loading
src/lib/kinetic_exchange.h +9 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,13 @@ typedef struct _KineticExchange // HMAC key (shared secret) to verify the HMAC. int64_t identity; // Required field // This is the identity's HMAC Key. This is a shared secret between the // client and the device, used to sign requests. bool has_key; size_t keyLength; uint8_t key[KINETIC_MAX_KEY_LEN]; // Required field // A unique number for this connection between the source and target. // On the first request to the drive, this should be the time of day in Loading @@ -61,6 +68,8 @@ typedef struct _KineticExchange void KineticExchange_Init( KineticExchange* const exchange, int64_t identity, uint8_t* key, size_t keyLength, int64_t connectionID, KineticConnection* const connection); Loading
src/lib/kinetic_message.c +3 −13 Original line number Diff line number Diff line Loading @@ -20,22 +20,12 @@ #include "kinetic_types.h" #include "kinetic_message.h" #include "kinetic_hmac.h" void KineticMessage_Init(KineticMessage* const message) { // Initialize protobuf fields KineticProto_init(&message->proto); KineticProto_command_init(&message->command); KineticProto_header_init(&message->header); KineticProto_body_init(&message->body); KineticProto_status_init(&message->status); // Assemble the message message->proto.hmac.data = message->hmacData; message->command.header = &message->header; message->command.body = &message->body; message->command.status = &message->status; message->proto.command = &message->command; // Initialize protobuf fields and ssemble the message KINETIC_MESSSAGE_INIT(message); } void KineticMessage_BuildNoop(KineticMessage* const message) Loading
src/lib/kinetic_message.h +8 −9 Original line number Diff line number Diff line Loading @@ -24,9 +24,6 @@ #include "kinetic_proto.h" #include <openssl/sha.h> // #define KINETIC_HMAC_SHA1_LEN (SHA_DIGEST_LENGTH) typedef struct _KineticMessage { // Kinetic Protocol Buffer Elements Loading @@ -35,6 +32,8 @@ typedef struct _KineticMessage KineticProto_Header header; KineticProto_Body body; KineticProto_Status status; KineticProto_Security security; KineticProto_Security_ACL acl; uint8_t hmacData[SHA_DIGEST_LENGTH]; } KineticMessage; Loading
src/lib/kinetic_types.h +25 −1 Original line number Diff line number Diff line Loading @@ -26,12 +26,15 @@ #include <stdbool.h> #endif #include <stdint.h> #include <assert.h> #include <stddef.h> #include <string.h> #include <stdio.h> #include <assert.h> #include <limits.h> #include <netinet/in.h> #include <ifaddrs.h> // Windows doesn't use <unistd.h> nor does it define HOST_NAME_MAX. #if defined(WIN32) #include <windows.h> Loading Loading @@ -69,4 +72,25 @@ typedef struct _KineticConnection char Host[HOST_NAME_MAX]; } KineticConnection; #include <protobuf-c/protobuf-c.h> #include "kinetic_proto.h" #include "kinetic_message.h" #define KINETIC_MAX_KEY_LEN 128 #define KINETIC_MESSSAGE_INIT(msg) \ msg->proto = KINETIC_PROTO_INIT; \ msg->command = KINETICPROTO_COMMAND_INIT; \ msg->header = KINETIC_PROTO_HEADER_INIT; \ msg->body = KINETIC_PROTO_BODY_INIT; \ msg->status = KINETIC_PROTO_STATUS_INIT; \ msg->security = KINETIC_PROTO_SECURITY_INIT; \ msg->acl = KINETIC_PROTO_SECURITY_ACL_INIT; \ msg->proto.hmac.data = msg->hmacData; \ msg->command.header = &msg->header; \ msg->command.body = &msg->body; \ msg->command.status = &msg->status; \ msg->proto.command = &msg->command; \ msmset(msg->hmac_data, 0, SHA_DIGEST_LENGTH); #endif // _KINETIC_TYPES_H