mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
removed endian conversion code, now we just write in big-endian on output with shifts, not swaps etc
This commit is contained in:
@@ -7,6 +7,7 @@ extern "C" {
|
||||
|
||||
#include "pcp/config.h"
|
||||
#include "pcp/buffer.h"
|
||||
#include "pcp/config.h"
|
||||
#include "pcp/context.h"
|
||||
#include "pcp/crypto.h"
|
||||
#include "pcp/defines.h"
|
||||
|
||||
@@ -9,15 +9,9 @@
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#undef HAVE_ARPA_INET_H
|
||||
|
||||
/* Define if be32toh() is available */
|
||||
#undef HAVE_BE32TOH
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#undef HAVE_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
@@ -51,9 +45,6 @@
|
||||
/* Define to 1 if you have the `getopt_long' function. */
|
||||
#undef HAVE_GETOPT_LONG
|
||||
|
||||
/* Define if htobe32() is available */
|
||||
#undef HAVE_HTOBE32
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
@@ -126,9 +117,6 @@
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
#undef HAVE_SYS_ENDIAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
|
||||
@@ -271,6 +271,10 @@ void pcp_seckeyblob(Buffer *b, pcp_key_t *k);
|
||||
void pcp_pubkeyblob(Buffer *b, pcp_pubkey_t *k);
|
||||
Buffer *pcp_keyblob(void *k, int type); /* allocates blob */
|
||||
|
||||
/* reads key from blob */
|
||||
pcp_key_t *pcp_blob2key(Buffer *b); /* allocates key */
|
||||
pcp_pubkey_t *pcp_blob2pubkey(Buffer *b);
|
||||
|
||||
/** Make a sanity check of the given public key structure.
|
||||
|
||||
\param[in] ptx pcp context.
|
||||
|
||||
@@ -25,59 +25,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_ENDIAN_H
|
||||
# include <endian.h>
|
||||
#else /* no endian.h */
|
||||
# ifdef HAVE_SYS_ENDIAN_H
|
||||
# include <sys/types.h>
|
||||
# include <sys/endian.h>
|
||||
# ifndef HAVE_BE32TOH
|
||||
# /* openbsd, use aliases */
|
||||
# define be16toh betoh16
|
||||
# define be32toh betoh32
|
||||
# define be64toh betoh64
|
||||
# endif
|
||||
# else /* no sys/endian.h */
|
||||
# ifdef __CPU_IS_BIG_ENDIAN
|
||||
# define be16toh(x) (x)
|
||||
# define htobe16(x) (x)
|
||||
# define be32toh(x) (x)
|
||||
# define htobe32(x) (x)
|
||||
# define be64toh(x) (x)
|
||||
# define htobe64(x) (x)
|
||||
# elif defined(__APPLE__) /* from https://gist.github.com/panzi/6856583 */
|
||||
# include <libkern/OSByteOrder.h>
|
||||
# define htobe16(x) OSSwapHostToBigInt16(x)
|
||||
# define be16toh(x) OSSwapBigToHostInt16(x)
|
||||
# define htobe32(x) OSSwapHostToBigInt32(x)
|
||||
# define be32toh(x) OSSwapBigToHostInt32(x)
|
||||
# define htobe64(x) OSSwapHostToBigInt64(x)
|
||||
# define be64toh(x) OSSwapBigToHostInt64(x)
|
||||
# define __BYTE_ORDER BYTE_ORDER
|
||||
# define __BIG_ENDIAN BIG_ENDIAN
|
||||
# define __LITTLE_ENDIAN LITTLE_ENDIAN
|
||||
# define __PDP_ENDIAN PDP_ENDIAN
|
||||
# else
|
||||
# ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
# else
|
||||
# ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
# else
|
||||
# error Need either netinet/in.h or arpa/inet.h for ntohl() and htonl()
|
||||
# endif
|
||||
# endif
|
||||
# define be16toh(x) ((uint16_t)ntohl((uint16_t)(x)))
|
||||
# define htobe16(x) ((uint16_t)htonl((uint16_t)(x)))
|
||||
# define be32toh(x) ((uint32_t)ntohl((uint32_t)(x)))
|
||||
# define htobe32(x) ((uint32_t)htonl((uint32_t)(x)))
|
||||
# define be64toh(x) ((uint64_t)ntohl((uint64_t)(x)))
|
||||
# define htobe64(x) ((uint64_t)htonl((uint64_t)(x)))
|
||||
# endif
|
||||
# endif /* HAVE_SYS_ENDIAN_H */
|
||||
#endif /* HAVE_ENDIAN_H */
|
||||
|
||||
|
||||
#ifndef HAVE_ARC4RANDOM
|
||||
#include <sodium.h>
|
||||
#define arc4random() randombytes_random()
|
||||
|
||||
@@ -123,6 +123,19 @@ size_t _hex2bin(const char *hex_str, unsigned char *byte_array, size_t byte_arra
|
||||
*/
|
||||
int cst_time_memcmp(const void *m1, const void *m2, size_t n);
|
||||
|
||||
|
||||
|
||||
// be32toh
|
||||
uint64_t _wireto64(byte *data);
|
||||
uint32_t _wireto32(byte *data);
|
||||
uint16_t _wireto16(byte *data);
|
||||
|
||||
// htobe32
|
||||
void _64towire(uint64_t i, byte *data);
|
||||
void _32towire(uint32_t i, byte *data);
|
||||
void _16towire(uint16_t i, byte *data);
|
||||
|
||||
|
||||
#endif /* _HAVE_PCP_UTIL_H */
|
||||
|
||||
/**@}*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
This file is part of Pretty Curved Privacy (pcp1).
|
||||
|
||||
Copyright (C) 2013-2014 T.v.Dein.
|
||||
Copyright (C) 2013-2016 T.v.Dein.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -24,8 +24,8 @@
|
||||
#define _HAVE_PCP_VERSION
|
||||
|
||||
#define PCP_VERSION_MAJOR 0
|
||||
#define PCP_VERSION_MINOR 3
|
||||
#define PCP_VERSION_PATCH 1
|
||||
#define PCP_VERSION_MINOR 4
|
||||
#define PCP_VERSION_PATCH 0
|
||||
|
||||
#define PCP_VERSION PCP_MAKE_VERSION(PCP_VERSION_MAJOR, PCP_VERSION_MINOR, PCP_VERSION_PATCH)
|
||||
#define PCP_MAKE_VERSION(major, minor, patch) ((major * 10000) + (minor * 100) + (patch))
|
||||
|
||||
Reference in New Issue
Block a user