1 /* @(#) $Id: ./src/headers/sec.h, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
18 /* Unique key for each agent. */
19 typedef struct _keyentry
31 struct sockaddr_in peer_info;
37 typedef struct _keystore
39 /* Array with all the keys */
40 keyentry **keyentries;
43 /* Hashes, based on the id/ip to lookup the keys. */
57 /** Function prototypes -- key management **/
59 /* Checks if the authentication keys are present */
63 void OS_ReadKeys(keystore *keys);
65 /* Frees the auth keys. */
66 void OS_FreeKeys(keystore *keys);
68 /* Checks if key changed. */
69 int OS_CheckUpdateKeys(keystore *keys);
71 /* Update the keys if they changed on the system. */
72 int OS_UpdateKeys(keystore *keys);
75 /* Starts counter for all agents */
76 void OS_StartCounter(keystore *keys);
78 /* Remove counter for id. */
79 void OS_RemoveCounter(char *id);
82 /** Function prototypes -- agent authorization **/
84 /* Checks if the ip is allowed */
85 int OS_IsAllowedIP(keystore *keys, char *srcip);
87 /* Checks if the id is allowed */
88 int OS_IsAllowedID(keystore *keys, char *id);
90 /* Checks if name is valid */
91 int OS_IsAllowedName(keystore *keys, char *name);
93 /* Check if the id is valid and dynamic */
94 int OS_IsAllowedDynamicID(keystore *keys, char *id, char *srcip);
98 /** Function prototypes -- send/recv messages **/
100 /* Decrypt and decompress a remote message. */
101 char *ReadSecMSG(keystore *keys, char *buffer, char *cleartext,
102 int id, int buffer_size);
104 /* Creates an ossec message (encrypts and compress) */
105 int CreateSecMSG(keystore *keys, char *msg, char *msg_encrypted, int id);
110 /** Remote IDs directories and internal definitions */
112 #define RIDS_DIR "/queue/rids"
114 #define RIDS_DIR "rids"
117 #define SENDER_COUNTER "sender_counter"