Skip to content

Commit

Permalink
hcrypto: Add X25519
Browse files Browse the repository at this point in the history
The X25519 implementation comes from libsodium. Explicit copyright
notices have been added to each file as well as some portability changes
(e.g. align.h).
  • Loading branch information
lhoward authored and nicowilliams committed Apr 26, 2020
1 parent 20f9b2b commit beda11a
Show file tree
Hide file tree
Showing 20 changed files with 8,184 additions and 5 deletions.
11 changes: 9 additions & 2 deletions lib/hcrypto/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif

AM_CPPFLAGS += -I$(top_srcdir)/lib/hx509 \
-I$(srcdir)/libtommath -DUSE_HCRYPTO_LTM=1 \
-I$(srcdir)/x25519 \
-I$(srcdir)/..

lib_LTLIBRARIES = libhcrypto.la
Expand Down Expand Up @@ -55,9 +56,10 @@ hcryptoinclude_HEADERS = \
rsa.h \
sha.h \
ui.h \
undef.h
undef.h \
x25519_ref10.h

install-build-headers:: $(hcryptoinclude_HEADERS)
install-build-headers:: $(hcryptoinclude_HEADERS) $(x25519include_HEADERS)
@foo='$(hcryptoinclude_HEADERS)'; \
for f in $$foo; do \
f=`basename $$f`; \
Expand Down Expand Up @@ -107,6 +109,7 @@ test_rand_LDADD = $(LDADD) -lm

libhcrypto_la_SOURCES = \
$(ltmsources) \
$(x25519sources)\
aes.c \
aes.h \
bn.c \
Expand Down Expand Up @@ -330,6 +333,10 @@ ltmsources = \
libtommath/bn_s_mp_toom_mul.c \
libtommath/bn_s_mp_toom_sqr.c

x25519sources = \
x25519/ed25519_ref10.c \
x25519/x25519_ref10.c

$(libhcrypto_la_OBJECTS) $(test_rand_OBJECTS): hcrypto-link

libhcrypto_la_CPPFLAGS = -DBUILD_HCRYPTO_LIB $(AM_CPPFLAGS)
Expand Down
5 changes: 3 additions & 2 deletions lib/hcrypto/NTMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#

SUBDIRS=libtommath
SUBDIRS=libtommath x25519

RELDIR=lib\hcrypto

Expand Down Expand Up @@ -87,7 +87,8 @@ INCFILES= \
$(HCRYPTOINCLUDEDIR)\rsa.h \
$(HCRYPTOINCLUDEDIR)\sha.h \
$(HCRYPTOINCLUDEDIR)\ui.h \
$(HCRYPTOINCLUDEDIR)\undef.h
$(HCRYPTOINCLUDEDIR)\undef.h \
$(HCRYPTOINCLUDEDIR)\x25519_ref10.h \

mkincdir:
!if !exist($(HCRYPTOINCLUDEDIR))
Expand Down
3 changes: 2 additions & 1 deletion lib/hcrypto/libhcrypto-exports.def
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,5 @@ EXPORTS
hc_EVP_CipherFinal_ex

hc_hcrypto_validate

hc_hcrypto_scalarmult_curve25519
hc_hcrypto_scalarmult_curve25519_base
2 changes: 2 additions & 0 deletions lib/hcrypto/version-script.map
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ HEIMDAL_CRYPTO_1.0 {
hc_EVP_CipherUpdate;
hc_EVP_CipherFinal_ex;
hc_hcrypto_validate;
hc_hcrypto_scalarmult_curve25519;
hc_hcrypto_scalarmult_curve25519_base;
local:
*;
};
46 changes: 46 additions & 0 deletions lib/hcrypto/x25519/NTMakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
########################################################################
#
# Copyright (c) 2009, Secure Endpoints 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.
#
# 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 HOLDER 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.
#

RELDIR=lib\hcrypto\x25519

!include ../../../windows/NTMakefile.w32

intcflags=-I$(SRC)\lib\hcrypto

libx25519_OBJs= \
$(OBJ)\ed25519_ref10.obj \
$(OBJ)\x25519_ref10.obj

$(LIBX25519): $(libx25519_OBJs)
$(LIBCON)

all:: $(LIBX25519)

7 changes: 7 additions & 0 deletions lib/hcrypto/x25519/align.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef CRYPTO_ALIGN
# if defined(__INTEL_COMPILER) || defined(_MSC_VER)
# define CRYPTO_ALIGN(x) __declspec(align(x))
# else
# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x)))
# endif
#endif

0 comments on commit beda11a

Please sign in to comment.