Skip to content

Commit e6787b2

Browse files
author
unknown
committed
chacha20 poly1305
1 parent a7e3b59 commit e6787b2

14 files changed

+1305
-26
lines changed

Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ all: test
4545
runtest: test
4646
@echo "running libsrtp2 test applications..."
4747
$(FIND_LIBRARIES) crypto/test/cipher_driver$(EXE) -v >/dev/null
48-
$(FIND_LIBRARIES) crypto/test/kernel_driver$(EXE) -v >/dev/null
48+
$(FIND_LIBRARIES) crypto/test/kernel_driver$(EXE) -v
4949
$(FIND_LIBRARIES) test/test_srtp$(EXE) >/dev/null
5050
$(FIND_LIBRARIES) test/rdbx_driver$(EXE) -v >/dev/null
5151
$(FIND_LIBRARIES) test/srtp_driver$(EXE) -v >/dev/null

config_in.h

+18-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
/* Define if building universal (internal helper macro) */
44
#undef AC_APPLE_UNIVERSAL_BUILD
55

6+
/* Define this to use CHACHA20-POLY1305. */
7+
#undef CHAPOLY
8+
69
/* Define if building for a CISC machine (e.g. Intel). */
710
#undef CPU_CISC
811

@@ -18,6 +21,9 @@
1821
/* Define to redirect logging to stdout. */
1922
#undef ERR_REPORTING_STDOUT
2023

24+
/* Define this to use AES-GCM. */
25+
#undef GCM
26+
2127
/* Define to 1 if you have the <arpa/inet.h> header file. */
2228
#undef HAVE_ARPA_INET_H
2329

@@ -42,6 +48,12 @@
4248
/* Define to 1 if you have the `dl' library (-ldl). */
4349
#undef HAVE_LIBDL
4450

51+
/* Define to 1 if you have the `nspr4' library (-lnspr4). */
52+
#undef HAVE_LIBNSPR4
53+
54+
/* Define to 1 if you have the `nss3' library (-lnss3). */
55+
#undef HAVE_LIBNSS3
56+
4557
/* Define to 1 if you have the `socket' library (-lsocket). */
4658
#undef HAVE_LIBSOCKET
4759

@@ -57,6 +69,9 @@
5769
/* Define to 1 if you have the <netinet/in.h> header file. */
5870
#undef HAVE_NETINET_IN_H
5971

72+
/* Define to 1 if you have the <nss.h> header file. */
73+
#undef HAVE_NSS_H
74+
6075
/* Define to 1 if you have the `winpcap' library (-lwpcap) */
6176
#undef HAVE_PCAP
6277

@@ -120,6 +135,9 @@
120135
/* Define to use X86 inlined assembly code */
121136
#undef HAVE_X86
122137

138+
/* Define this to use NSS crypto. */
139+
#undef NSS
140+
123141
/* Define this to use OpenSSL crypto. */
124142
#undef OPENSSL
125143

@@ -129,12 +147,6 @@
129147
/* Define this to use OpenSSL KDF for SRTP. */
130148
#undef OPENSSL_KDF
131149

132-
/* Define this to use NSS crypto. */
133-
#undef NSS
134-
135-
/* Define this to use AES-GCM. Requires OPENSSL or NSS */
136-
#undef GCM
137-
138150
/* Define to the address where bug reports for this package should be sent. */
139151
#undef PACKAGE_BUGREPORT
140152

configure

+84-9
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ infodir
682682
docdir
683683
oldincludedir
684684
includedir
685+
runstatedir
685686
localstatedir
686687
sharedstatedir
687688
sysconfdir
@@ -768,6 +769,7 @@ datadir='${datarootdir}'
768769
sysconfdir='${prefix}/etc'
769770
sharedstatedir='${prefix}/com'
770771
localstatedir='${prefix}/var'
772+
runstatedir='${localstatedir}/run'
771773
includedir='${prefix}/include'
772774
oldincludedir='/usr/include'
773775
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1020,6 +1022,15 @@ do
10201022
| -silent | --silent | --silen | --sile | --sil)
10211023
silent=yes ;;
10221024

1025+
-runstatedir | --runstatedir | --runstatedi | --runstated \
1026+
| --runstate | --runstat | --runsta | --runst | --runs \
1027+
| --run | --ru | --r)
1028+
ac_prev=runstatedir ;;
1029+
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
1030+
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
1031+
| --run=* | --ru=* | --r=*)
1032+
runstatedir=$ac_optarg ;;
1033+
10231034
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
10241035
ac_prev=sbindir ;;
10251036
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1157,7 +1168,7 @@ fi
11571168
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
11581169
datadir sysconfdir sharedstatedir localstatedir includedir \
11591170
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1160-
libdir localedir mandir
1171+
libdir localedir mandir runstatedir
11611172
do
11621173
eval ac_val=\$$ac_var
11631174
# Remove trailing slashes.
@@ -1310,6 +1321,7 @@ Fine tuning of the installation directories:
13101321
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
13111322
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
13121323
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
1324+
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
13131325
--libdir=DIR object code libraries [EPREFIX/lib]
13141326
--includedir=DIR C header files [PREFIX/include]
13151327
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -5196,8 +5208,8 @@ fi
51965208
if test "x$PKG_CONFIG" != "x"; then
51975209
51985210
pkg_failed=no
5199-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcrypto >= 1.0.1" >&5
5200-
$as_echo_n "checking for libcrypto >= 1.0.1... " >&6; }
5211+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypto" >&5
5212+
$as_echo_n "checking for crypto... " >&6; }
52015213
52025214
if test -n "$crypto_CFLAGS"; then
52035215
pkg_cv_crypto_CFLAGS="$crypto_CFLAGS"
@@ -5237,7 +5249,7 @@ fi
52375249
52385250
52395251
if test $pkg_failed = yes; then
5240-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5252+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
52415253
$as_echo "no" >&6; }
52425254
52435255
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -5264,7 +5276,7 @@ Alternatively, you may set the environment variables crypto_CFLAGS
52645276
and crypto_LIBS to avoid the need to call pkg-config.
52655277
See the pkg-config man page for more details." "$LINENO" 5
52665278
elif test $pkg_failed = untried; then
5267-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5279+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
52685280
$as_echo "no" >&6; }
52695281
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
52705282
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -5568,14 +5580,74 @@ as_fn_error $? "can't find openssl >= 1.0.1 crypto lib
55685580
See \`config.log' for more details" "$LINENO" 5; }
55695581
fi
55705582
5583+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing EVP_chacha20_poly1305" >&5
5584+
$as_echo_n "checking for library containing EVP_chacha20_poly1305... " >&6; }
5585+
if ${ac_cv_search_EVP_chacha20_poly1305+:} false; then :
5586+
$as_echo_n "(cached) " >&6
5587+
else
5588+
ac_func_search_save_LIBS=$LIBS
5589+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5590+
/* end confdefs.h. */
5591+
5592+
/* Override any GCC internal prototype to avoid an error.
5593+
Use char because int might match the return type of a GCC
5594+
builtin and then its argument prototype would still apply. */
5595+
#ifdef __cplusplus
5596+
extern "C"
5597+
#endif
5598+
char EVP_chacha20_poly1305 ();
5599+
int
5600+
main ()
5601+
{
5602+
return EVP_chacha20_poly1305 ();
5603+
;
5604+
return 0;
5605+
}
5606+
_ACEOF
5607+
for ac_lib in '' crypto; do
5608+
if test -z "$ac_lib"; then
5609+
ac_res="none required"
5610+
else
5611+
ac_res=-l$ac_lib
5612+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
5613+
fi
5614+
if ac_fn_c_try_link "$LINENO"; then :
5615+
ac_cv_search_EVP_chacha20_poly1305=$ac_res
5616+
fi
5617+
rm -f core conftest.err conftest.$ac_objext \
5618+
conftest$ac_exeext
5619+
if ${ac_cv_search_EVP_chacha20_poly1305+:} false; then :
5620+
break
5621+
fi
5622+
done
5623+
if ${ac_cv_search_EVP_chacha20_poly1305+:} false; then :
5624+
5625+
else
5626+
ac_cv_search_EVP_chacha20_poly1305=no
5627+
fi
5628+
rm conftest.$ac_ext
5629+
LIBS=$ac_func_search_save_LIBS
5630+
fi
5631+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_EVP_chacha20_poly1305" >&5
5632+
$as_echo "$ac_cv_search_EVP_chacha20_poly1305" >&6; }
5633+
ac_res=$ac_cv_search_EVP_chacha20_poly1305
5634+
if test "$ac_res" != no; then :
5635+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
5636+
5637+
5638+
$as_echo "#define CHAPOLY 1" >>confdefs.h
5639+
5640+
CHAPOLY_OBJ="crypto/cipher/chacha20_poly1305_ossl.o"
5641+
fi
5642+
55715643
55725644
55735645
$as_echo "#define GCM 1" >>confdefs.h
55745646
55755647
55765648
$as_echo "#define OPENSSL 1" >>confdefs.h
55775649
5578-
AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
5650+
AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o $CHAPOLY_OBJ"
55795651
HMAC_OBJS=crypto/hash/hmac_ossl.o
55805652
USE_EXTERNAL_CRYPTO=1
55815653
@@ -5796,7 +5868,7 @@ fi
57965868
57975869
57985870
if test $pkg_failed = yes; then
5799-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5871+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
58005872
$as_echo "no" >&6; }
58015873
58025874
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -5823,7 +5895,7 @@ Alternatively, you may set the environment variables nss_CFLAGS
58235895
and nss_LIBS to avoid the need to call pkg-config.
58245896
See the pkg-config man page for more details." "$LINENO" 5
58255897
elif test $pkg_failed = untried; then
5826-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5898+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
58275899
$as_echo "no" >&6; }
58285900
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
58295901
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -5968,9 +6040,12 @@ fi
59686040
$as_echo "#define GCM 1" >>confdefs.h
59696041
59706042
6043+
$as_echo "#define CHAPOLY 1" >>confdefs.h
6044+
6045+
59716046
$as_echo "#define NSS 1" >>confdefs.h
59726047
5973-
AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o"
6048+
AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o crypto/cipher/chacha20_poly1305_nss.o"
59746049
59756050
# TODO(RLB): Use NSS for HMAC
59766051
HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"

configure.ac

+6-2
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,13 @@ if test "$enable_openssl" = "yes"; then
255255
[], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])])
256256
AC_SEARCH_LIBS([EVP_aes_128_gcm], [crypto],
257257
[], [AC_MSG_FAILURE([can't find openssl >= 1.0.1 crypto lib])])
258+
AC_SEARCH_LIBS([EVP_chacha20_poly1305], [crypto], [
259+
AC_DEFINE([CHAPOLY], [1], [Define this to use CHACHA20-POLY1305.])
260+
CHAPOLY_OBJ="crypto/cipher/chacha20_poly1305_ossl.o"])
258261

259262
AC_DEFINE([GCM], [1], [Define this to use AES-GCM.])
260263
AC_DEFINE([OPENSSL], [1], [Define this to use OpenSSL crypto.])
261-
AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o"
264+
AES_ICM_OBJS="crypto/cipher/aes_icm_ossl.o crypto/cipher/aes_gcm_ossl.o $CHAPOLY_OBJ"
262265
HMAC_OBJS=crypto/hash/hmac_ossl.o
263266
AC_SUBST([USE_EXTERNAL_CRYPTO], [1])
264267

@@ -343,8 +346,9 @@ elif test "$enable_nss" = "yes"; then
343346
fi
344347

345348
AC_DEFINE([GCM], [1], [Define this to use AES-GCM.])
349+
AC_DEFINE([CHAPOLY], [1], [Define this to use CHACHA20-POLY1305.])
346350
AC_DEFINE([NSS], [1], [Define this to use NSS crypto.])
347-
AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o"
351+
AES_ICM_OBJS="crypto/cipher/aes_icm_nss.o crypto/cipher/aes_gcm_nss.o crypto/cipher/chacha20_poly1305_nss.o"
348352

349353
# TODO(RLB): Use NSS for HMAC
350354
HMAC_OBJS="crypto/hash/hmac.o crypto/hash/sha1.o"

0 commit comments

Comments
 (0)