Skip to content

Commit

Permalink
lib: add minisign ed25519 public-key cryptography api
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Feb 26, 2023
1 parent c78231f commit 709845a
Show file tree
Hide file tree
Showing 21 changed files with 5,641 additions and 21 deletions.
46 changes: 45 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ for f in all extra error shadow "format=2" missing-prototypes \
missing-include-dirs old-style-definition \
init-self redundant-decls float-equal missing-noreturn \
cast-align cast-qual pointer-arith comment \
declaration-after-statement write-strings stack-protector; do
write-strings stack-protector; do
check_compiler_flag ${f} W
done

Expand Down Expand Up @@ -613,6 +613,48 @@ else
fi
rm -f _$func.c _$func

#
# Check for getrandom().
#
func=getrandom
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <sys/random.h>
int main(void) {
char buf[16];
getrandom(buf, sizeof(buf), 0);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_GETRANDOM" >>$CONFIG_MK
else
echo no.
fi
rm -f _$func.c _$func

#
# Check for arc4random_buf().
#
func=arc4random_buf
printf "Checking for $func() ... "
cat <<EOF > _$func.c
#include <stdlib.h>
int main(void) {
char buf[16];
arc4random_buf(buf, sizeof(buf));
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
echo "CPPFLAGS += -DHAVE_ARC4RANDOM_BUF" >>$CONFIG_MK
else
echo no.
fi
rm -f _$func.c _$func

#
# zlib is required.
#
Expand Down Expand Up @@ -757,6 +799,8 @@ if [ "$SET_RPATH" ]; then
sed -i 's,XORIGIN,$$ORIGIN,' $CONFIG_MK
fi

echo "CFLAGS += -Wno-error=deprecated-declarations" >>$CONFIG_MK

echo
echo " XBPS has been configured with the following options:"
echo
Expand Down
2 changes: 1 addition & 1 deletion include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ all:
install:
install -d $(DESTDIR)$(INCLUDEDIR)/xbps
install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR)
for f in array bool data dictionary number object string; do \
for f in array bool data dictionary number object string crypto; do \
install -m 644 xbps/xbps_$${f}.h $(DESTDIR)$(INCLUDEDIR)/xbps; \
done

Expand Down
47 changes: 47 additions & 0 deletions include/macro.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef XBPS_MACRO_H
#define XBPS_MACRO_H

#include <stdio.h>

/*
* By default all public functions have default visibility, unless
* visibility has been detected by configure and the HIDDEN definition
* is used.
*/
#if HAVE_VISIBILITY
#define HIDDEN __attribute__ ((visibility("hidden")))
#else
#define HIDDEN
#endif

#ifndef __UNCONST
#define __UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
#endif

#ifndef __arraycount
#define __arraycount(x) (sizeof(x) / sizeof(*x))
#endif


/* XXX: struct_size overflow check */
#define struct_size(p, member, count) \
((sizeof(*(p)->member) * count) + sizeof(*(p)))

#ifndef container_of
#define container_of(ptr, type, member) ({ \
void *__mptr = (void *)(ptr); \
((type *)(__mptr - offsetof(type, member))); })
#endif

#if 0
#undef assert
#define assert(expr) do { \
if (!(expr)) { \
fprintf(stderr, "assert failed %s\n", #expr); \
abort(); \
} \
} while(0)
#endif


#endif /*!XBPS_MACRO_H*/
Loading

0 comments on commit 709845a

Please sign in to comment.