Commit b67061f6 authored by David McGrew's avatar David McGrew

autoconf fixes and minor code cleanup

parent 7c01b719
......@@ -10,12 +10,14 @@
# libcrypt.a static library implementing crypto engine
# libsrtp.a static library implementing srtp
# clean removes objects, libs, and executables
# distribution cleans and builds a .tgz
# tags builds etags file from all .c and .h files
# distribution cleans and builds a .tgz
# tags builds etags file from all .c and .h files
.PHONY: test all runtest
.PHONY: all test
runtest: test
all: test
runtest: table_apps test
@echo "running libsrtp test applications..."
test/cipher_driver$(EXE) -v >/dev/null
test/rdbx_driver$(EXE) -v >/dev/null
......@@ -23,30 +25,37 @@ runtest: test
test/roc_driver$(EXE) -v >/dev/null
test/kernel_driver$(EXE) -v >/dev/null
@echo "libsrtp test applications passed."
all: test tables
cd crypto/; $(MAKE) runtest
# makefile variables
CC = @CC@
CFLAGS = -Wall -O4 -fexpensive-optimizations -funroll-loops
CDEFS = -DHAVE_CONFIG_H
INCDIR = -I./include/ -I./crypto/include
LIBS = @LIBS@ -lsrtp
LIBDIR = -L.
INCDIR = -I./include -I./crypto/include
CDEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@ $(CDEFS) $(INCDIR)
CFLAGS = @CFLAGS@
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@ -L.
SRTPLIB = -lsrtp
INSTALL = @INSTALL@
prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
# implicit rules for object files and test apps
%.o: %.c
$(CC) $(CDEFS) -c $(CFLAGS) $(INCDIR) $< -o $@
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
%: %.c libsrtp.a
$(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) $(LIBS)
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) $(SRTPLIB)
# libcrypt.a (the crypto engine)
ciphers = crypto/cipher/cipher.o crypto/cipher/null_cipher.o \
crypto/cipher/aes.o crypto/cipher/aes_icm.o \
crypto/cipher/aes_cbc.o
......@@ -99,7 +108,7 @@ libaesicm.a: $(aesicmobj)
# generate tables and verify cryptoalgorithm implementations - this
# library is not meant to be included in production code
cryptomath = crypto/math/math.o crypto/math/gf2_8.o crypto/math/gf2_128.o
cryptomath = crypto/math/math.o crypto/math/gf2_8.o
libcryptomath.a: $(cryptomath)
ar cr libcryptomath.a $(cryptomath)
......@@ -111,13 +120,13 @@ libcryptomath.a: $(cryptomath)
testapp = test/cipher_driver test/datatypes_driver test/srtp_driver \
test/replay_driver test/roc_driver test/rdbx_driver \
test/stat_driver test/sha1_driver test/kernel_driver \
test/aes_calc test/rand_gen # test/ust_driver @GDOI_APPS@
# test/auth_driver test/rtpw \
test/aes_calc test/rand_gen test/rtpw
test/rtpw: test/rtpw.c test/rtp.c
$(CC) $(CDEFS) $(CFLAGS) $(INCDIR) -o test/rtpw test/rtpw.c test/rtp.c $(LIBDIR) $(LIBS)
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(SRTPLIB)
test: $(testapp)
@echo "Build done. Please run '$(MAKE) runtest' to run self tests."
memtest: test/srtp_driver
@test/srtp_driver -v -d "alloc" > tmp
......@@ -132,12 +141,13 @@ memtest: test/srtp_driver
# implementations; these need only be generated during porting, not
# for building libsrtp or the test applications
table_apps = tables/aes_tables tables/gf_128_tables
table_apps: tables/aes_tables
# in the tables/ subdirectory, we use libcryptomath instead of libsrtp
tables/%: tables/%.c libcryptomath.a
$(CC) $(CDEFS) $(CFLAGS) $(INCDIR) $< -o $@ $(LIBDIR) libcryptomath.a
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $@ $(LDFLAGS) $(LIBS) libcryptomath.a
# the target 'plot' runs the timing test (test/srtp_driver -t) then
# uses gnuplot to produce plots of the results - see the script file
......@@ -157,7 +167,7 @@ tags:
# libsrtp
libsrtpdoc:
cd doc; make
cd doc; $(MAKE)
# EXE defines the suffix on executables - it's .exe for cygwin, and
# null on linux, bsd, and OS X and other OSes. we define this so that
......@@ -168,19 +178,21 @@ EXE = @EXE@
.PHONY: clean superclean install
install:
if [ -d /usr/local/include/srtp ]; then \
@if [ -d $(DESTDIR)$(includedir)/srtp ]; then \
echo "you should run 'make uninstall' first"; exit 1; \
fi
mkdir /usr/local/include/srtp
cp include/*.h /usr/local/include/srtp
cp crypto/include/*.h /usr/local/include/srtp
cp libsrtp.a /usr/local/lib/
if [ -f libaesicm.a ]; then cp libaesicm.a /usr/local/lib/; fi
$(INSTALL) -d $(DESTDIR)$(includedir)/srtp
$(INSTALL) -d $(DESTDIR)$(libdir)
cp include/*.h $(DESTDIR)$(includedir)/srtp
cp crypto/include/*.h $(DESTDIR)$(includedir)/srtp
cp libsrtp.a $(DESTDIR)$(libdir)/
if [ -f libaesicm.a ]; then cp libaesicm.a $(DESTDIR)$(libdir)/; fi
uninstall:
rm -rf /usr/local/include/srtp
rm -rf /usr/local/lib/libsrtp.a
rm -rf /usr/local/lib/libaesicm.a
rm -rf $(DESTDIR)$(includedir)/srtp
rm -rf $(DESTDIR)$(libdir)/libsrtp.a
rm -rf $(DESTDIR)$(libdir)/libaesicm.a; fi
clean:
rm -rf $(cryptobj) $(srtpobj) $(cryptomath) $(table_apps) TAGS \
......@@ -191,8 +203,8 @@ clean:
for a in $(testapp) $(table_apps); do rm -rf $$a$(EXE); done
rm -rf *.pict *.jpg *.dat
rm -rf freed allocated tmp
cd doc; make clean
cd crypto; make clean
cd doc; $(MAKE) clean
cd crypto; $(MAKE) clean
superclean: clean
......@@ -202,7 +214,7 @@ superclean: clean
distname = srtp-$(shell cat VERSION)
distribution: superclean
distribution: runtest superclean
if ! [ -f VERSION ]; then exit 1; fi
if [ -f ../$(distname).tgz ]; then \
mv ../$(distname).tgz ../$(distname).tgz.bak; \
......
......@@ -59,7 +59,9 @@
/* define ERR_REPORTING_FILE to have messages sent to file */
#define ERR_REPORTING_FILE
#define ERR_REPORTING_FILE ""
#define USE_ERR_REPORTING_FILE 0
/*
* set ENABLE_DEBUGGING to 1 to compile in dynamic debugging system,
......@@ -90,8 +92,6 @@
#define CPU_ALTIVEC 0
/*
* if /dev/urandom is available, then DEV_URANDOM == 1
*
* /dev/urandom is a (true) random number generator which is
* implemented in many modern operating systems
*/
......
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script.
AC_INIT(srtp)
dnl Must come before AC_PROG_CC
if test -z "$CFLAGS"; then
dnl Default value for CFLAGS if not specified.
CFLAGS="-Wall -O4 -fexpensive-optimizations -funroll-loops"
fi
dnl Checks for programs.
AC_PROG_RANLIB
AC_PROG_CC
dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(srtp, srtp_init)
AC_PROG_INSTALL
dnl Check for /dev/urandom
AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=1, DEV_URANDOM=0)
if test $DEV_URANDOM = 1; then
AC_DEFINE(DEV_URANDOM)
AC_CHECK_FILE(/dev/urandom, DEV_URANDOM=/dev/urandom,
[AC_CHECK_FILE(/dev/random, DEV_URANDOM=/dev/random)])
AC_MSG_CHECKING(which random device to use)
if test -n "$DEV_URANDOM"; then
AC_DEFINE_UNQUOTED(DEV_URANDOM, "$DEV_URANDOM", [Path to random device])
RNG_OBJS=crypto/rng/rand_source.c
AC_SUBST(RNG_OBJS)
fi
AC_SUBST(RNG_OBJS)
AC_MSG_RESULT([$DEV_URANDOM])
dnl Checks for header files.
......@@ -44,78 +51,99 @@ AC_C_INLINE
AC_TYPE_SIZE_T
dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_CHECK_FUNCS(socket strerror inet_aton)
AC_CHECK_FUNCS(socket inet_aton)
dnl Checks for libraries.
AC_CHECK_LIB(socket, socket)
dnl Check the byte order
AC_C_BIGENDIAN
AC_CANONICAL_HOST
echo "host_cpu: $host_cpu"
if test $host_cpu = x86; then
echo "x86 cpu found"
fi
dnl check host_cpu type, set defines appropriately
case $host_cpu in
i*86 )
AC_DEFINE(CPU_CISC)
AC_DEFINE(HAVE_X86, 1);; # use x86 inline assembly
AC_DEFINE(CPU_CISC, 1,
[Define if building for a CISC machine (e.g. Intel).])
AC_DEFINE(HAVE_X86, 1,
[Define to use X86 inlined assembly code]);;
* )
AC_DEFINE(CPU_RISC);;
AC_DEFINE(CPU_RISC, 1,
[Define if building for a RISC machine (with slow byte access)]);;
esac
dnl Check if we're on a cygwin (GNU on MSWin) platform, set HAVE_MS_TYPES
case $host_os in
*cygwin* )
AC_DEFINE(HAVE_MS_TYPES, 1)
AC_DEFINE(HAVE_MS_TYPES, 1,
[Define to use microsoft integer definitions (e.g. cygwin).])
EXE=.exe;;
* ) EXE="";;
esac
AC_SUBST(EXE) # define executable suffix; this is needed for `make clean'
AC_ARG_ENABLE(debug, debug (compile in dynamic debugging system), USE_DEBUG=0, USE_DEBUG=1)
if test $USE_DEBUG = 1; then
AC_DEFINE(ENABLE_DEBUGGING)
AC_MSG_CHECKING(whether to compile in debugging)
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--disable-debug],
[do not compile in dynamic debugging system])],
[], enable_debug=yes)
if test "$enable_debug" = "yes"; then
AC_DEFINE(ENABLE_DEBUGGING, 1,
[Define to compile in dynamic debugging system.])
fi
AC_ARG_ENABLE(generic-aesicm, generic-aesicm (compile in changes for ismacryp), GENERIC_AESICM=0, GENERIC_AESICM=1)
if test $GENERIC_AESICM = 1; then
AC_DEFINE(GENERIC_AESICM)
AC_MSG_RESULT($enable_debug)
AC_MSG_CHECKING(whether to use ISMAcryp code)
AC_ARG_ENABLE(generic-aesicm,
[AS_HELP_STRING([--enable-generic-aesicm],
[compile in changes for ISMAcryp])],
[], enable_generic_aesicm=no)
if test "$enable_generic_aesicm" = "yes"; then
AC_DEFINE(GENERIC_AESICM, 1, [Define this to use ISMAcryp code.])
fi
AC_ARG_ENABLE(syslog, syslog (use syslog for error reporting), USE_SYSLOG=1, USE_SYSLOG=0)
if test $USE_SYSLOG = 1; then
AC_DEFINE(USE_SYSLOG)
AC_MSG_RESULT($enable_generic_aesicm)
AC_MSG_CHECKING(whether to use syslog for error reporting)
AC_ARG_ENABLE(syslog,
[AS_HELP_STRING([--enable-syslog], [use syslog for error reporting])],
[], enable_syslog=no)
if test "$enable_syslog" = "yes"; then
AC_DEFINE(USE_SYSLOG, 1, [Define to use syslog logging.])
fi
AC_ARG_ENABLE(stdout, stdout (use stdout for error reporting), ERR_STDOUT=0, ERR_STDOUT=1)
if test $ERR_STDOUT = 1; then
AC_DEFINE(ERR_REPORTING_STDOUT, 1)
AC_MSG_RESULT($enable_syslog)
AC_MSG_CHECKING(whether to use stdout for error reporting)
AC_ARG_ENABLE(stdout,
[AS_HELP_STRING([--disable-stdout], [don't use stdout for error reporting])],
[], enable_stdout=yes)
if test "$enable_stdout" = "yes"; then
AC_DEFINE(ERR_REPORTING_STDOUT, 1, [Define to use logging to stdout.])
fi
AC_ARG_ENABLE(console, console (use /dev/console for error reporting), ERR_FILE=1, ERR_FILE=0)
if test $ERR_FILE = 1; then
AC_DEFINE(ERR_REPORTING_FILE, "/dev/console")
AC_MSG_RESULT($enable_stdout)
AC_MSG_CHECKING(whether to use /dev/console for error reporting)
AC_ARG_ENABLE(console,
[AS_HELP_STRING([--enable-console], [use /dev/console for error reporting])],
[], enable_console=no)
if test "$enable_console" = "yes"; then
AC_DEFINE(USE_ERR_REPORTING_FILE, 1, [Write errors to this file])
AC_DEFINE(ERR_REPORTING_FILE, "/dev/console", [Report errors to this file.])
fi
AC_ARG_ENABLE(gdoi, gdoi (GDOI key management), GDOI=1, GDOI=0)
if test $GDOI = 1; then
AC_MSG_CHECKING(for GDOI key management)
AC_MSG_RESULT(?)
AC_DEFINE(SRTP_GDOI)
AC_MSG_RESULT($enable_console)
AC_MSG_CHECKING(whether to use GDOI key management)
AC_ARG_ENABLE(gdoi,
[AS_HELP_STRING([--enable-gdoi], [enable GDOI key management])],
[], enable_gdoi=no)
if test "$enable_gdoi" = "yes"; then
AC_DEFINE(SRTP_GDOI, 1, [Define to use GDOI.])
GDOI_OBJS=gdoi/srtp+gdoi.o
AC_SUBST(GDOI_OBJS)
fi
AC_MSG_RESULT($enable_gdoi)
AC_CONFIG_HEADER(crypto/include/config.h:config_in.h)
......
......@@ -20,13 +20,19 @@ endif
dummy : all runtest
# test applications
testapp = test/cipher_driver test/datatypes_driver \
test/stat_driver test/sha1_driver test/kernel_driver \
test/aes_calc test/rand_gen test/env
# data values used to test the aes_calc application
k=000102030405060708090a0b0c0d0e0f
p=00112233445566778899aabbccddeeff
c=69c4e0d86a7b0430d8cdb78070b4c55a
runtest: $(testapp)
runtest: libcryptomodule.a $(testapp)
test/env # print out information on the build environment
@echo "running libcryptomodule test applications..."
test `test/aes_calc $k $p` = $c
......@@ -82,20 +88,8 @@ libcryptomodule.a: $(cryptobj)
$(AR) cr libcryptomodule.a $(cryptobj)
$(RANLIB) libcryptomodule.a
# test applications
testapp = test/cipher_driver test/datatypes_driver \
test/stat_driver test/sha1_driver test/kernel_driver \
test/aes_calc test/rand_gen test/env
all: libcryptomodule.a $(testapp)
test: libcryptomodule.a $(testapp)
@echo "running libcryptomodule test applications..."
test/kernel_driver$(EXE) -v >/dev/null
test/cipher_driver$(EXE) -v >/dev/null
@echo "libcryptomodule test applications passed."
# housekeeping functions
clean:
......
......@@ -70,7 +70,7 @@
*
* @param iv location to write the Initialization Vector (IV)
*
* @param protected location of the data to be encrypted and
* @param protect location of the data to be encrypted and
* authenticated (before the function call), and the ciphertext
* and authentication tag (after the call)
*
......@@ -85,7 +85,7 @@ typedef err_status_t (*cryptoalg_func_t)
const void *clear,
unsigned clear_len,
void *iv,
void *protected,
void *protect,
unsigned *protected_len);
typedef
......
......@@ -89,7 +89,7 @@ typedef union {
/*
* octet_weight(x) returns the hamming weight (number of bits equal to
* octet_get_weight(x) returns the hamming weight (number of bits equal to
* one) in the octet x
*/
......
......@@ -48,9 +48,7 @@
#include "config.h" /* check for ERR_REPORTING_SYSLOG */
#ifdef ERR_REPORTING_FILE
#include <stdio.h>
#endif
#include <stdarg.h>
......
......@@ -37,7 +37,7 @@
*
* @param iv location to write the Initialization Vector (IV)
*
* @param protected location of the data to be encrypted and
* @param protect location of the data to be encrypted and
* authenticated (before the function call), and the ciphertext
* and authentication tag (after the call)
*
......@@ -53,8 +53,8 @@ typedef err_status_t (*xfm_func_t)
void *clear,
unsigned clear_len,
void *iv,
void *opaque,
unsigned *opaque_len,
void *protect,
unsigned *protected_len,
void *auth_tag
);
......
......@@ -67,7 +67,7 @@ err_reporting_init(char *ident) {
#if ERR_REPORTING_STDOUT
err_file = stdout;
#else
#ifdef ERR_REPORTING_FILE
#if USE_ERR_REPORTING_FILE
/* open file for error reporting */
err_file = fopen(ERR_REPORTING_FILE, "w");
if (err_file == NULL)
......
......@@ -64,7 +64,7 @@ err_status_t
key_limit_clone(key_limit_t original, key_limit_t *new_key) {
if (original == NULL)
return err_status_bad_param;
*new = original;
*new_key = original;
return err_status_ok;
}
......
......@@ -42,7 +42,7 @@
*
*/
#include "math.h"
#include "crypto_math.h"
#include <stdlib.h> /* malloc() used in bitvector_alloc */
int
......@@ -240,7 +240,7 @@ v32_bit_string(v32_t x) {
}
char *
v64_bit_string(v64_t *x) {
v64_bit_string(const v64_t *x) {
int i, mask, index;
for (i = index = 0; i < 8; i++) {
......@@ -291,7 +291,8 @@ octet_hex_string(octet_t x) {
}
char *
octet_string_hex_string(const octet_t *str, int length) {
octet_string_hex_string(const void *str, int length) {
const octet_t *s = str;
int i;
/* double length, since one octet takes two hex characters */
......@@ -302,8 +303,8 @@ octet_string_hex_string(const octet_t *str, int length) {
length = MAX_STRING_LENGTH-1;
for (i=0; i < length; i+=2) {
bit_string[i] = nibble_to_hex_char(*str >> 4);
bit_string[i+1] = nibble_to_hex_char(*str++ & 0xF);
bit_string[i] = nibble_to_hex_char(*s >> 4);
bit_string[i+1] = nibble_to_hex_char(*s++ & 0xF);
}
bit_string[i] = 0; /* null terminate string */
return bit_string;
......@@ -336,7 +337,7 @@ v32_hex_string(v32_t x) {
}
char *
v64_hex_string(v64_t *x) {
v64_hex_string(const v64_t *x) {
int i, j;
for (i=j=0; i < 8; i++) {
......
......@@ -42,13 +42,10 @@
*
*/
#include "config.h"
#include "rand_source.h"
/* FIX! move to configuration file */
#define HAS_DEV_RANDOM
#ifdef HAS_DEV_RANDOM
#ifdef DEV_URANDOM
#include <fcntl.h> /* for open() */
#include <unistd.h> /* for close() */
#endif
......@@ -61,18 +58,16 @@ int dev_random_fdes = 0;
err_status_t
rand_source_init() {
#ifdef HAS_DEV_RANDOM
/* open /dev/random for reading */
dev_random_fdes = open("/dev/urandom", O_RDONLY, 0);
#ifdef DEV_URANDOM
/* open random source for reading */
dev_random_fdes = open(DEV_URANDOM, O_RDONLY, 0);
if (dev_random_fdes == 0)
return err_status_init_fail;
return err_status_ok;
#else
/* Generic C-library (rand()) version */
/* call srand() here if needed */
/* FIX libsrtp needs a goodrandom value source/seed */
/* no random source available; let the caller know */
return err_status_fail;
#endif
return err_status_ok;
}
err_status_t
......@@ -83,7 +78,7 @@ rand_source_get_octet_string(void *dest, int len) {
* check return value to make sure enough octets were
* written
*/
#ifdef HAS_DEV_RANDOM
#ifdef DEV_URANDOM
if (read(dev_random_fdes, dest, len) != len)
return err_status_fail;
#else
......@@ -105,7 +100,7 @@ rand_source_get_octet_string(void *dest, int len) {
err_status_t
rand_source_deinit() {
#ifdef HAS_DEV_RANDOM
#ifdef DEV_URANDOM
if (dev_random_fdes == 0)
return err_status_dealloc_fail; /* well, we haven't really failed, *
* but there is something wrong */
......
......@@ -43,12 +43,12 @@
*/
#include <stdio.h>
#include <string.h> /* for srtcmp() */
#include "config.h"
int
main() {
int status = 0;
int err_count = 0;
#if WORDS_BIGENDIAN
printf("CPU set to big-endian\t\t\t(WORDS_BIGENDIAN == 1)\n");
......@@ -56,14 +56,13 @@ main() {
printf("CPU set to little-endian\t\t(WORDS_BIGENDIAN == 0)\n");
#endif
#if CPU_RISC
printf("CPU set to RISC\t\t\t\t(CPU_RISC == 1)\n");
#elif CPU_CISC
printf("CPU set to CISC\t\t\t\t(CPU_CISC == 1)\n");
#else
printf("CPU set to an unknown type, probably due to a configuration error\n");
status = 1;
err_count++;
#endif
#if CPU_ALTIVEC
......@@ -80,12 +79,15 @@ main() {
printf("using stdout for error reporting\t(ERR_REPORTING_STDOUT == 1)\n");
#endif
#if DEV_URANDOM
printf("using /dev/urandom as a random source\t(DEV_URANDOM == 1)\n");
#endif
if (status)
printf("warning: configuration is probably in error\n");
printf("using %s as a random source\t(DEV_URANDOM == %s)\n",
DEV_URANDOM, DEV_URANDOM);
if (strcmp("", DEV_URANDOM) == 0) {
err_count++;
}
if (err_count)
printf("warning: configuration is probably in error "
"(found %d problems)\n", err_count);
return status;
return err_count;
}
......@@ -761,29 +761,29 @@ srtp_install_event_handler(srtp_event_handler_func_t func);
#if (WORDS_BIGENDIAN == 0) /* assume LITTLE_ENDIAN */
typedef struct {
unsigned char cc:4; /* CSRC count */
unsigned char x:1; /* header extension flag */
unsigned char p:1; /* padding flag */
unsigned char version:2; /* protocol version */
unsigned char pt:7; /* payload type */
unsigned char m:1; /* marker bit */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
unsigned cc:4; /* CSRC count */
unsigned x:1; /* header extension flag */
unsigned p:1; /* padding flag */
unsigned version:2; /* protocol version */
unsigned pt:7; /* payload type */
unsigned m:1; /* marker bit */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
} srtp_hdr_t;
#else /* BIG_ENDIAN */
typedef struct {
unsigned char version:2; /* protocol version */
unsigned char p:1; /* padding flag */
unsigned char x:1; /* header extension flag */
unsigned char cc:4; /* CSRC count */
unsigned char m:1; /* marker bit */
unsigned char pt:7; /* payload type */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
unsigned version:2; /* protocol version */
unsigned p:1; /* padding flag */
unsigned x:1; /* header extension flag */
unsigned cc:4; /* CSRC count */
unsigned m:1; /* marker bit */
unsigned pt:7; /* payload type */
uint16_t seq; /* sequence number */
uint32_t ts; /* timestamp */
uint32_t ssrc; /* synchronization source */
} srtp_hdr_t;
#endif
......
/*
* srtp.h
*
* interface to libsrtp
*
* David A. McGrew
* Cisco Systems, Inc.
*/
/*
*
* Copyright (c) 2001-2005, Cisco Systems, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 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.
*
* Neither the name of the Cisco Systems, Inc. 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 COPYRIGHT HOLDERS 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
* COPYRIGHT HOLDERS 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.
*
*/
#ifndef SRTP_H
#define SRTP_H
#include "crypto_kernel.h"
#include "rdbx.h"
#include "integers.h"
/* a sec_serv_t describes a set of security services */
typedef enum {
sec_serv_none = 0,
sec_serv_conf = 1,
sec_serv_auth = 2,
sec_serv_conf_and_auth = 3
} sec_serv_t;
/* srtp_ctx_t stores all of the state needed for an srtp session */
#include "ust.h"
typedef struct {
ust_ctx_t ust;
sec_serv_t services;
uint32_t ssrc;
} srtp_ctx_t;
/*
* an srtp_hdr_t represents the srtp header
*
* in this implementation, an srtp_hdr_t is assumed to be 32-bit aligned
*