1 /* @(#) $Id: sec.h,v 1.20 2009/06/24 17:06:26 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
17 /* Unique key for each agent. */
18 typedef struct _keyentry
30 struct sockaddr_in peer_info;
36 typedef struct _keystore
38 /* Array with all the keys */
39 keyentry **keyentries;
42 /* Hashes, based on the id/ip to lookup the keys. */
56 /** Function prototypes -- key management **/
58 /* Checks if the authentication keys are present */
62 void OS_ReadKeys(keystore *keys);
64 /* Frees the auth keys. */
65 void OS_FreeKeys(keystore *keys);
67 /* Checks if key changed. */
68 int OS_CheckUpdateKeys(keystore *keys);
70 /* Update the keys if they changed on the system. */
71 int OS_UpdateKeys(keystore *keys);
74 /* Starts counter for all agents */
75 void OS_StartCounter(keystore *keys);
77 /* Remove counter for id. */
78 void OS_RemoveCounter(char *id);
81 /** Function prototypes -- agent authorization **/
83 /* Checks if the ip is allowed */
84 int OS_IsAllowedIP(keystore *keys, char *srcip);
86 /* Checks if the id is allowed */
87 int OS_IsAllowedID(keystore *keys, char *id);
89 /* Checks if name is valid */
90 int OS_IsAllowedName(keystore *keys, char *name);
92 /* Check if the id is valid and dynamic */
93 int OS_IsAllowedDynamicID(keystore *keys, char *id, char *srcip);
97 /** Function prototypes -- send/recv messages **/
99 /* Decrypt and decompress a remote message. */
100 char *ReadSecMSG(keystore *keys, char *buffer, char *cleartext,
101 int id, int buffer_size);
103 /* Creates an ossec message (encrypts and compress) */
104 int CreateSecMSG(keystore *keys, char *msg, char *msg_encrypted, int id);
109 /** Remote IDs directories and internal definitions */
111 #define RIDS_DIR "/queue/rids"
113 #define RIDS_DIR "rids"
116 #define SENDER_COUNTER "sender_counter"