libradsec_la_LIBADD = radius/libradsec-radius.la
libradsec_la_LDFLAGS = -version-info 0:0:0 -export-symbols radsec.sym
-libradsec_la_CFLAGS = $(AM_CFLAGS) -Werror # -DDEBUG -DDEBUG_LEVENT
+libradsec_la_CFLAGS = $(AM_CFLAGS) -DHAVE_CONFIG_H -Werror # -DDEBUG -DDEBUG_LEVENT
# Checks for header files.
AC_CHECK_HEADERS(
- [netdb.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h unistd.h])
+ [sys/time.h time.h netdb.h netinet/in.h stdint.h stdlib.h strings.h string.h \
+ sys/socket.h unistd.h syslog.h sys/select.h fcntl.h arpa/inet.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
#ifndef _RADSEC_RADSEC_H_
#define _RADSEC_RADSEC_H_ 1
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+#ifdef HAVE_STDINT_H
#include <stdint.h>
-
-#include <arpa/inet.h>
-#include <sys/time.h>
+#endif
enum rs_error_code {
RSE_OK = 0,
custom.c \
dict.c \
id.c \
- packet.c \
parse.c \
print.c \
+ radpkt.c \
static.c \
valuepair.c
-libradsec_radius_la_CFLAGS = $(AM_CFLAGS)
+libradsec_radius_la_CFLAGS = $(AM_CFLAGS) -DHAVE_CONFIG_H
DICTIONARIES = \
share/dictionary.txt \
#endif
-#ifdef FLAG_ENCRYPT_ASCEND_SECRET:
+#ifdef FLAG_ENCRYPT_ASCEND_SECRET
/*
* Ascend-Send-Secret
* Ascend-Receive-Secret
/*
* System-specific header files.
*/
+#include <config.h>
#include <errno.h>
#include <stdio.h>
+#ifdef HAVE_STDINT_H
#include <stdint.h>
+#endif
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#include <stdarg.h>
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <radsec/radsec.h>
-
-/*
- * Definitions of attributes.
- */
+#include <radsec/radsec-impl.h>
#include <radsec/radius.h>
/** \defgroup build Build Helpers
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * Copyright (c) 2006 Kungliga Tekniska HAÎåÎÝgskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the Institute nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
/** \file custom.c
* \brief Functions which should be customized for your local system.
#include <unistd.h>
#include <fcntl.h>
+#ifdef WIN32
+#include <wincrypt.h>
+
+volatile static HCRYPTPROV nr_cryptprovider = 0;
+
+static HCRYPTPROV
+nr_CryptProvider(void)
+{
+ BOOL rv;
+ HCRYPTPROV cryptprovider = 0;
+
+ if (nr_cryptprovider != 0)
+ return nr_cryptprovider;
+
+ rv = CryptAcquireContext(&cryptprovider, NULL,
+ MS_ENHANCED_PROV, PROV_RSA_FULL,
+ 0);
+
+ if (GetLastError() == NTE_BAD_KEYSET) {
+ if(!rv)
+ rv = CryptAcquireContext(&cryptprovider, NULL,
+ MS_ENHANCED_PROV, PROV_RSA_FULL,
+ CRYPT_NEWKEYSET);
+ }
+
+ if (rv &&
+ InterlockedCompareExchangePointer((PVOID *) &nr_cryptprovider,
+ (PVOID) cryptprovider, 0) != 0) {
+
+ CryptReleaseContext(cryptprovider, 0);
+ cryptprovider = nr_cryptprovider;
+ }
+
+ return cryptprovider;
+}
+
+ssize_t nr_rand_bytes(uint8_t *data, size_t data_len)
+{
+ if (CryptGenRandom(nr_CryptProvider(), data_len, data))
+ return 0;
+ return data_len;
+}
+#else
ssize_t nr_rand_bytes(uint8_t *data, size_t data_len)
{
static int fd = -1;
return read(fd, data, data_len);
}
+#endif /* WIN32 */
uint32_t nr_rand(void)
{
*/
#include "client.h"
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
/** \file id.c
* \brief Handling of ID allocation / freeing
if (s->used > 0) return -RSE_INUSE;
- if (s->sockfd >= 0) close(s->sockfd);
+ if (s->sockfd >= 0) evutil_closesocket(s->sockfd);
return 0;
}
*/
#include "client.h"
+
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
ssize_t nr_vp_sscanf_value(VALUE_PAIR *vp, const char *value)
{
char *end;
switch (vp->da->type) {
- case RS_TYPE_STRING:
- strlcpy(vp->vp_strvalue, value, sizeof(vp->vp_strvalue));
- vp->length = strlen(vp->vp_strvalue);
- return vp->length;
+ case RS_TYPE_STRING: {
+ size_t len = strlen(value);
+ if (len >= RS_MAX_STRING_LEN)
+ return -RSE_ATTR_TOO_LARGE;
+
+ memcpy(vp->vp_strvalue, value, len + 1);
+ return (vp->length = len);
+ }
case RS_TYPE_DATE:
case RS_TYPE_INTEGER:
vp->vp_integer = strtoul(value, &end, 10);
break;
default:
+ len = 0;
break;
}
RS_MD5Init(&ctx);
RS_MD5Update(&ctx, data, length);
- RS_MD5Update(&ctx, original->secret, original->sizeof_secret);
+ RS_MD5Update(&ctx, (const unsigned char *)original->secret, original->sizeof_secret);
RS_MD5Final(calc_digest, &ctx);
memcpy(data + 4, packet_vector, sizeof(packet_vector));
}
if ((memcmp(&packet->src, &original->dst, sizeof(packet->src)) != 0) &&
- (evutil_sockaddr_cmp(&(packet->src), &(original->dst)) != 0)) {
+ (evutil_sockaddr_cmp((struct sockaddr *)&packet->src, (struct sockaddr *)&original->dst, 1) != 0)) {
nr_debug_error("Ignoring response from wrong IP/port");
return -RSE_INVALID_RESPONSE_SRC;
}
RS_MD5Init(&ctx);
RS_MD5Update(&ctx, packet->data, packet->length);
- RS_MD5Update(&ctx, packet->secret, packet->sizeof_secret);
+ RS_MD5Update(&ctx, (const unsigned char *)packet->secret, packet->sizeof_secret);
RS_MD5Final(packet->vector, &ctx);
}
{
VALUE_PAIR *next, *vp;
- if (!head || !*head) return;
-
- vp = *head;
- do {
- if (vp) next = vp->next;
+ for (vp = *head; vp != NULL; vp = next) {
+ next = vp->next;
if (vp->da->flags.encrypt) {
memset(vp, 0, sizeof(vp));
}
free(vp);
- vp = next;
- } while (next);
+ }
*head = NULL;
}