Skip to content

Commit a11f404

Browse files
committed
lib: add minisign ed25519 public-key cryptography api
1 parent c78231f commit a11f404

File tree

22 files changed

+5913
-21
lines changed

22 files changed

+5913
-21
lines changed

configure

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ for f in all extra error shadow "format=2" missing-prototypes \
282282
missing-include-dirs old-style-definition \
283283
init-self redundant-decls float-equal missing-noreturn \
284284
cast-align cast-qual pointer-arith comment \
285-
declaration-after-statement write-strings stack-protector; do
285+
write-strings stack-protector; do
286286
check_compiler_flag ${f} W
287287
done
288288

@@ -613,6 +613,48 @@ else
613613
fi
614614
rm -f _$func.c _$func
615615

616+
#
617+
# Check for getrandom().
618+
#
619+
func=getrandom
620+
printf "Checking for $func() ... "
621+
cat <<EOF > _$func.c
622+
#include <sys/random.h>
623+
int main(void) {
624+
char buf[16];
625+
getrandom(buf, sizeof(buf), 0);
626+
return 0;
627+
}
628+
EOF
629+
if $XCC _$func.c -o _$func 2>/dev/null; then
630+
echo yes.
631+
echo "CPPFLAGS += -DHAVE_GETRANDOM" >>$CONFIG_MK
632+
else
633+
echo no.
634+
fi
635+
rm -f _$func.c _$func
636+
637+
#
638+
# Check for arc4random_buf().
639+
#
640+
func=arc4random_buf
641+
printf "Checking for $func() ... "
642+
cat <<EOF > _$func.c
643+
#include <stdlib.h>
644+
int main(void) {
645+
char buf[16];
646+
arc4random_buf(buf, sizeof(buf));
647+
return 0;
648+
}
649+
EOF
650+
if $XCC _$func.c -o _$func 2>/dev/null; then
651+
echo yes.
652+
echo "CPPFLAGS += -DHAVE_ARC4RANDOM_BUF" >>$CONFIG_MK
653+
else
654+
echo no.
655+
fi
656+
rm -f _$func.c _$func
657+
616658
#
617659
# zlib is required.
618660
#
@@ -757,6 +799,8 @@ if [ "$SET_RPATH" ]; then
757799
sed -i 's,XORIGIN,$$ORIGIN,' $CONFIG_MK
758800
fi
759801

802+
echo "CFLAGS += -Wno-error=deprecated-declarations" >>$CONFIG_MK
803+
760804
echo
761805
echo " XBPS has been configured with the following options:"
762806
echo

include/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ all:
1010
install:
1111
install -d $(DESTDIR)$(INCLUDEDIR)/xbps
1212
install -m 644 $(INCS) $(DESTDIR)$(INCLUDEDIR)
13-
for f in array bool data dictionary number object string; do \
13+
for f in array bool data dictionary number object string crypto; do \
1414
install -m 644 xbps/xbps_$${f}.h $(DESTDIR)$(INCLUDEDIR)/xbps; \
1515
done
1616

include/macro.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef XBPS_MACRO_H
2+
#define XBPS_MACRO_H
3+
4+
#include <stdio.h>
5+
6+
/*
7+
* By default all public functions have default visibility, unless
8+
* visibility has been detected by configure and the HIDDEN definition
9+
* is used.
10+
*/
11+
#if HAVE_VISIBILITY
12+
#define HIDDEN __attribute__ ((visibility("hidden")))
13+
#else
14+
#define HIDDEN
15+
#endif
16+
17+
#ifndef __UNCONST
18+
#define __UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
19+
#endif
20+
21+
#ifndef __arraycount
22+
#define __arraycount(x) (sizeof(x) / sizeof(*x))
23+
#endif
24+
25+
26+
/* XXX: struct_size overflow check */
27+
#define struct_size(p, member, count) \
28+
((sizeof(*(p)->member) * count) + sizeof(*(p)))
29+
30+
#ifndef container_of
31+
#define container_of(ptr, type, member) ({ \
32+
void *__mptr = (void *)(ptr); \
33+
((type *)(__mptr - offsetof(type, member))); })
34+
#endif
35+
36+
#if 0
37+
#undef assert
38+
#define assert(expr) do { \
39+
if (!(expr)) { \
40+
fprintf(stderr, "assert failed %s\n", #expr); \
41+
abort(); \
42+
} \
43+
} while(0)
44+
#endif
45+
46+
47+
#endif /*!XBPS_MACRO_H*/

0 commit comments

Comments
 (0)