1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
15 /* Unique key for each agent */
16 typedef struct _keyentry {
27 struct sockaddr_storage peer_info;
32 typedef struct _keystore {
33 /* Array with all the keys */
34 keyentry **keyentries;
36 /* Hashes, based on the ID/IP to look up the keys */
47 /** Function prototypes -- key management **/
49 /* Check if the authentication keys are present */
50 int OS_CheckKeys(void);
52 void OS_PassEmptyKeyfile(void);
55 void OS_ReadKeys(keystore *keys) __attribute((nonnull));
57 /* Free the auth keys */
58 void OS_FreeKeys(keystore *keys) __attribute((nonnull));
60 /* Check if key changed */
61 int OS_CheckUpdateKeys(const keystore *keys) __attribute((nonnull));
63 /* Update the keys if they changed on the system */
64 int OS_UpdateKeys(keystore *keys) __attribute((nonnull));
66 /* Start counter for all agents */
67 void OS_StartCounter(keystore *keys) __attribute((nonnull));
69 /* Remove counter for id */
70 void OS_RemoveCounter(const char *id) __attribute((nonnull));
72 /* Configure to pass if keys file is empty */
73 void OS_PassEmptyKeyfile();
75 /** Function prototypes -- agent authorization **/
77 /* Check if the IP is allowed */
78 int OS_IsAllowedIP(keystore *keys, const char *srcip) __attribute((nonnull(1)));
80 /* Check if the ID is allowed */
81 int OS_IsAllowedID(keystore *keys, const char *id) __attribute((nonnull(1)));
83 /* Check if the name is valid */
84 int OS_IsAllowedName(const keystore *keys, const char *name) __attribute((nonnull));
86 /* Check if the id is valid and dynamic */
87 int OS_IsAllowedDynamicID(keystore *keys, const char *id, const char *srcip) __attribute((nonnull(1)));
90 /** Function prototypes -- send/recv messages **/
92 /* Decrypt and decompress a remote message */
93 char *ReadSecMSG(keystore *keys, char *buffer, char *cleartext,
94 int id, unsigned int buffer_size) __attribute((nonnull));
96 /* Create an OSSEC message (encrypt and compress) */
97 size_t CreateSecMSG(const keystore *keys, const char *msg, char *msg_encrypted, unsigned int id) __attribute((nonnull));
100 /** Remote IDs directories and internal definitions */
102 #define RIDS_DIR "/queue/rids"
104 #define RIDS_DIR "rids"
107 #define SENDER_COUNTER "sender_counter"