Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • nettle/nettle
  • briansmith/nettle
  • ajlawrence/nettle
  • mhoffmann/nettle
  • devnexen/nettle
  • wiml/nettle
  • lumag/nettle
  • michaelweiser/nettle
  • aberaud/nettle
  • mamonet/nettle
  • npocs/nettle
  • babelouest/nettle
  • ueno/nettle
  • rth/nettle
14 results
Show changes
OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
AM_CPPFLAGS = -I$(top_srcdir)
# We need .. to be searched before standard places, in order to pick
# up the newly built libnettle.a/libnettle.so, rather than any
# installed version.
AM_LDFLAGS = -L..
# There's no program "io", it's just a trick to get automake to keep track
# of dependencies for io.o.
EXTRA_PROGRAMS = rsa-keygen rsa-sign rsa-verify rsa-encrypt rsa-decrypt io
noinst_PROGRAMS = nettle-benchmark @RSA_EXAMPLES@
nettle_benchmark_SOURCES = nettle-benchmark.c nettle-openssl.c
# libnettle.a for the dependency
LDADD = io.o -lnettle ../libnettle.a
nettle_benchmark_LDADD = -lnettle ../libnettle.a $(OPENSSL_LIBFLAGS)
TS_PROGS = rsa-sign-test rsa-verify-test rsa-encrypt-test
EXTRA_DIST = io.h rsa-session.h run-tests setup-env teardown-env $(TS_PROGS)
.PHONY: run-tests
run-tests: $(TS_PROGS)
LD_LIBRARY_PATH=../.lib srcdir="$(srcdir)" \
"$(srcdir)"/run-tests $(TS_PROGS)
check: run-tests
@SET_MAKE@
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
include ../config.make
PRE_CPPFLAGS = -I.. -I$(top_srcdir)
PRE_LDFLAGS = -L..
OPENSSL_LIBFLAGS = @OPENSSL_LIBFLAGS@
BENCH_LIBS = @BENCH_LIBS@ -lm
HOGWEED_TARGETS = rsa-keygen$(EXEEXT) rsa-sign$(EXEEXT) \
rsa-verify$(EXEEXT) rsa-encrypt$(EXEEXT) rsa-decrypt$(EXEEXT) \
random-prime$(EXEEXT) \
hogweed-benchmark$(EXEEXT) ecc-benchmark$(EXEEXT)
ENC_TARGETS = base16enc$(EXEEXT) base16dec$(EXEEXT) \
base64enc$(EXEEXT) base64dec$(EXEEXT)
TARGETS = nettle-benchmark$(EXEEXT) \
$(ENC_TARGETS) @IF_HOGWEED@ $(HOGWEED_TARGETS)
SOURCES = nettle-benchmark.c hogweed-benchmark.c ecc-benchmark.c \
random-prime.c \
nettle-openssl.c \
io.c read_rsa_key.c \
rsa-encrypt.c rsa-decrypt.c rsa-keygen.c rsa-sign.c rsa-verify.c \
base16enc.c base16dec.c base64enc.c base64dec.c timing.c
GETOPT_OBJS = ../getopt.$(OBJEXT) ../getopt1.$(OBJEXT)
TS_ALL = rsa-sign-test rsa-verify-test rsa-encrypt-test
DISTFILES= $(SOURCES) Makefile.in $(TS_ALL) setup-env teardown-env \
io.h rsa-session.h timing.h
all: $(TARGETS)
%.$(OBJEXT): %.c
$(COMPILE) -c $< && $(DEP_PROCESS)
# NOTE: If we required GNU make, we could use a single rule with $(@F)
# or $(notdir $@)
../getopt.$(OBJEXT):
( cd .. && $(MAKE) getopt.$(OBJEXT))
../getopt1.$(OBJEXT):
( cd .. && $(MAKE) getopt1.$(OBJEXT))
../non-nettle.$(OBJEXT):
( cd .. && $(MAKE) non-nettle.$(OBJEXT))
# For Solaris and BSD make, we have to use an explicit rule for each executable
random-prime$(EXEEXT): random-prime.$(OBJEXT) io.$(OBJEXT) $(GETOPT_OBJS)
$(LINK) random-prime.$(OBJEXT) io.$(OBJEXT) $(GETOPT_OBJS) \
-lhogweed -lnettle $(LIBS) -o random-prime$(EXEEXT)
rsa-keygen$(EXEEXT): rsa-keygen.$(OBJEXT) io.$(OBJEXT) $(GETOPT_OBJS)
$(LINK) rsa-keygen.$(OBJEXT) io.$(OBJEXT) $(GETOPT_OBJS) \
-lhogweed -lnettle $(LIBS) -o rsa-keygen$(EXEEXT)
rsa-sign$(EXEEXT): rsa-sign.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT)
$(LINK) rsa-sign.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT) \
-lhogweed -lnettle $(LIBS) -o rsa-sign$(EXEEXT)
rsa-verify$(EXEEXT): rsa-verify.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT)
$(LINK) rsa-verify.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT) \
-lhogweed -lnettle $(LIBS) -o rsa-verify$(EXEEXT)
rsa-encrypt$(EXEEXT): rsa-encrypt.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT) $(GETOPT_OBJS)
$(LINK) rsa-encrypt.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT) \
$(GETOPT_OBJS) \
-lhogweed -lnettle $(LIBS) -o rsa-encrypt$(EXEEXT)
rsa-decrypt$(EXEEXT): rsa-decrypt.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT)
$(LINK) rsa-decrypt.$(OBJEXT) io.$(OBJEXT) read_rsa_key.$(OBJEXT) \
-lhogweed -lnettle $(LIBS) -o rsa-decrypt$(EXEEXT)
base16enc$(EXEEXT): base16enc.$(OBJEXT) io.$(OBJEXT)
$(LINK) base16enc.$(OBJEXT) io.$(OBJEXT) \
-lnettle $(LIBS) -o base16enc$(EXEEXT)
base16dec$(EXEEXT): base16dec.$(OBJEXT) io.$(OBJEXT)
$(LINK) base16dec.$(OBJEXT) io.$(OBJEXT) \
-lnettle $(LIBS) -o base16dec$(EXEEXT)
base64enc$(EXEEXT): base64enc.$(OBJEXT) io.$(OBJEXT)
$(LINK) base64enc.$(OBJEXT) io.$(OBJEXT) \
-lnettle $(LIBS) -o base64enc$(EXEEXT)
base64dec$(EXEEXT): base64dec.$(OBJEXT) io.$(OBJEXT)
$(LINK) base64dec.$(OBJEXT) io.$(OBJEXT) \
-lnettle $(LIBS) -o base64dec$(EXEEXT)
BENCH_OBJS = nettle-benchmark.$(OBJEXT) nettle-openssl.$(OBJEXT) \
$(GETOPT_OBJS) ../non-nettle.$(OBJEXT) timing.$(OBJEXT)
nettle-benchmark$(EXEEXT): $(BENCH_OBJS)
$(LINK) $(BENCH_OBJS) -lnettle $(BENCH_LIBS) $(OPENSSL_LIBFLAGS) -o nettle-benchmark$(EXEEXT)
ECC_BENCH_OBJS = ecc-benchmark.$(OBJEXT) timing.$(OBJEXT)
ecc-benchmark$(EXEEXT): $(ECC_BENCH_OBJS)
$(LINK) $(ECC_BENCH_OBJS) -lhogweed -lnettle $(BENCH_LIBS) $(LIBS) \
-o ecc-benchmark$(EXEEXT)
HOGWEED_BENCH_OBJS = hogweed-benchmark.$(OBJEXT) timing.$(OBJEXT)
hogweed-benchmark$(EXEEXT): $(HOGWEED_BENCH_OBJS)
$(LINK) $(HOGWEED_BENCH_OBJS) \
-lhogweed -lnettle $(BENCH_LIBS) $(LIBS) $(OPENSSL_LIBFLAGS) \
-o hogweed-benchmark$(EXEEXT)
$(TARGETS) : io.$(OBJEXT) ../libnettle.stamp
$(HOGWEED_TARGETS): ../libhogweed.stamp
check: $(TS_ALL)
TEST_SHLIB_DIR="$(TEST_SHLIB_DIR)" \
srcdir="$(srcdir)" EMULATOR="$(EMULATOR)" EXEEXT="$(EXEEXT)" \
"$(top_srcdir)"/run-tests $(TS_ALL)
Makefile: $(srcdir)/Makefile.in ../config.status
cd .. && $(SHELL) ./config.status examples/$@
install uninstall:
true
# NOTE: I'd like to use $^, but that's a GNU extension. $? should be
# more portable, equivalent for phony targets.
distdir: $(DISTFILES)
cp $? $(distdir)
clean:
-rm -f $(TARGETS) *.$(OBJEXT) *.$(OBJEXT).d
distclean: clean
-rm -f Makefile *.d
tags:
etags -o $(srcdir)/TAGS --include $(top_srcdir) $(srcdir)/*.c $(srcdir)/*.h
-include $(SOURCES:.c=.$(OBJEXT).d)
/* base16dec -- an decoder for base16
Copyright (C) 2006, 2012 Jeronimo Pellegrini, Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <fcntl.h>
#endif
#include "base16.h"
#include "io.h"
#define CHUNK_SIZE 16392
/* The maximum number of bytes generated for each chunk: */
#define DECODED_SIZE BASE16_DECODE_LENGTH(CHUNK_SIZE)
/*
* Reads base-16 encoded from stdin, writes decoded to stdout.
*/
int
main(int argc UNUSED, char **argv UNUSED)
{
/* "buffer" will hold the bytes from disk: */
char * buffer = xalloc (CHUNK_SIZE);
/* "result" will hold bytes before output: */
uint8_t * result = xalloc (DECODED_SIZE);
/* We need a Base16 context for decoding: */
struct base16_decode_ctx b16_ctx;
/* Init the context: */
base16_decode_init (&b16_ctx);
#ifdef WIN32
_setmode(1, O_BINARY);
#endif
for (;;)
{
int nbytes; /* Number of bytes read frmo disk at each iteration */
size_t decoded_bytes; /* Bytes actually generated at each iteration */
nbytes = fread(buffer, 1, CHUNK_SIZE, stdin);
if (nbytes < CHUNK_SIZE && ferror(stdin))
{
werror ("Error reading file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
/* Decodes one chunk: */
if (!base16_decode_update(&b16_ctx, &decoded_bytes, result, nbytes, buffer))
{
werror ("Error decoding input (not base16?)\n");
return EXIT_FAILURE;
}
if (!write_data (stdout, decoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (nbytes < CHUNK_SIZE)
{
/* Check if decoding finalized OK: */
if (!base16_decode_final(&b16_ctx))
{
werror("Decoding did not finish properly.\n");
return EXIT_FAILURE;
}
break;
}
}
if (fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
free (buffer);
free (result);
return EXIT_SUCCESS;
}
/* base16enc -- an encoder for base16
Copyright (C) 2006, 2012 Jeronimo Pellegrini, Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <fcntl.h>
#endif
#include "base16.h"
#include "io.h"
/* The number of bytes read in each iteration, we do one line at a time: */
#define CHUNK_SIZE 36
/* The *maximum* size of an encoded chunk: */
#define ENCODED_SIZE BASE16_ENCODE_LENGTH(CHUNK_SIZE)
/*
* Reads bytes from standard input and writes base64-encoded
* on standard output.
*/
int
main(int argc UNUSED, char **argv UNUSED)
{
#ifdef WIN32
_setmode(0, O_BINARY);
#endif
/* There is no context to initialize. */
for (;;)
{
/* "buffer" will hold the bytes from disk: */
uint8_t buffer[CHUNK_SIZE];
/* "result" will hold bytes before output: */
char result[ENCODED_SIZE + 1];
unsigned nbytes; /* Number of bytes read from stdin */
int encoded_bytes; /* Total number of bytes encoded per iteration */
nbytes = fread(buffer,1,CHUNK_SIZE,stdin);
/* We overwrite result with more data */
base16_encode_update(result, nbytes, buffer);
encoded_bytes = BASE16_ENCODE_LENGTH(nbytes);
result[encoded_bytes++] = '\n';
if (nbytes < CHUNK_SIZE)
{
if (ferror(stdin))
{
werror ("Error reading file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (!write_data (stdout, encoded_bytes, result)
|| fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* The result vector is printed */
if (!write_data(stdout, encoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
}
}
/* base64dec -- an decoder for base64
Copyright (C) 2006, 2012 Jeronimo Pellegrini, Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <fcntl.h>
#endif
#include "base64.h"
#include "io.h"
#define CHUNK_SIZE 16392
/* The maximum number of bytes generated for each chunk: */
#define DECODED_SIZE BASE64_DECODE_LENGTH(CHUNK_SIZE)
/*
* Reads base-64 encoded from stdin, writes decoded to stdout.
*/
int
main(int argc UNUSED, char **argv UNUSED)
{
/* "buffer" will hold the bytes from disk: */
char * buffer = xalloc (CHUNK_SIZE);
/* "result" will hold bytes before output: */
uint8_t * result = xalloc (DECODED_SIZE);
/* We need a Base64 context for decoding: */
struct base64_decode_ctx b64_ctx;
/* Init the context: */
base64_decode_init(&b64_ctx);
#ifdef WIN32
_setmode(1, O_BINARY);
#endif
for (;;)
{
int nbytes; /* Number of bytes read frmo disk at each iteration */
size_t decoded_bytes; /* Bytes actually generated at each iteration */
nbytes = fread(buffer, 1, CHUNK_SIZE, stdin);
if (nbytes < CHUNK_SIZE && ferror(stdin))
{
werror ("Error reading file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
/* Decodes one chunk: */
if (!base64_decode_update(&b64_ctx, &decoded_bytes, result, nbytes, buffer))
{
werror ("Error decoding input (not base64?)\n");
return EXIT_FAILURE;
}
if (!write_data (stdout, decoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (nbytes < CHUNK_SIZE)
{
/* Check if decoding finalized OK: */
if (!base64_decode_final(&b64_ctx))
{
werror ("Decoding did not finish properly.\n");
return EXIT_FAILURE;
}
break;
}
}
if (fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
free (buffer);
free (result);
return EXIT_SUCCESS;
}
/* base64enc -- an encoder for base64
Copyright (C) 2006, 2012 Jeronimo Pellegrini, Niels Möller
This file is part of GNU Nettle.
GNU Nettle is free software: you can redistribute it and/or
modify it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version.
or both in parallel, as here.
GNU Nettle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received copies of the GNU General Public License and
the GNU Lesser General Public License along with this program. If
not, see http://www.gnu.org/licenses/.
*/
#if HAVE_CONFIG_H
# include "config.h"
#endif
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <fcntl.h>
#endif
#include "base64.h"
#include "io.h"
/* The number of bytes read in each iteration, we do one line at a time: */
#define CHUNK_SIZE 54
/* The *maximum* size of an encoded chunk: */
#define ENCODED_SIZE BASE64_ENCODE_LENGTH(CHUNK_SIZE)
/*
* Reads bytes from standard input and writes base64-encoded
* on standard output.
*/
int
main(int argc UNUSED, char **argv UNUSED)
{
struct base64_encode_ctx b64_ctx;
/* Init the context: */
base64_encode_init(&b64_ctx);
#ifdef WIN32
_setmode(0, O_BINARY);
#endif
for (;;)
{
/* "buffer" will hold the bytes from disk: */
uint8_t buffer[CHUNK_SIZE];
/* "result" is the result vector: */
char result[ENCODED_SIZE + BASE64_ENCODE_FINAL_LENGTH + 1];
unsigned nbytes; /* Number of bytes read from stdin */
int encoded_bytes; /* total number of bytes encoded per iteration */
nbytes = fread(buffer,1,CHUNK_SIZE,stdin);
/* We overwrite result with more data */
encoded_bytes = base64_encode_update(&b64_ctx, result, nbytes, buffer);
if (nbytes < CHUNK_SIZE)
{
if (ferror(stdin))
{
werror ("Error reading file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
encoded_bytes += base64_encode_final(&b64_ctx,result + encoded_bytes);
result[encoded_bytes++] = '\n';
if (!write_data (stdout, encoded_bytes, result)
|| fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
/* The result vector is written */
result[encoded_bytes++] = '\n';
if (!write_data (stdout, encoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
}
}