mirror of
https://codeberg.org/scip/pcp.git
synced 2025-12-17 03:50:57 +01:00
fixed yet another endian issue (I used the wrong define for it)
This commit is contained in:
2
TODO
2
TODO
@@ -1 +1,3 @@
|
||||
aix works now so far, but -R doesnt work - now it does but decryption fails for some unknown reason.
|
||||
|
||||
libpcp/z85.c:148 free(z85) leads to coredump on aix sometimes
|
||||
|
||||
2
configure
vendored
2
configure
vendored
@@ -12658,7 +12658,7 @@ fi
|
||||
|
||||
|
||||
if test -n "$bigendian"; then
|
||||
CFLAGS="$CFLAGS -D__BIG_ENDIAN=1"
|
||||
CFLAGS="$CFLAGS -D__CPU_IS_BIG_ENDIAN=1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
# define htobe64 hto64be
|
||||
# endif
|
||||
# else // no sys/endian.h
|
||||
# ifdef __BIG_ENDIAN
|
||||
# ifdef __CPU_IS_BIG_ENDIAN
|
||||
# define be32toh(x) (x)
|
||||
# define htobe32(x) (x)
|
||||
# define be64toh(x) (x)
|
||||
|
||||
@@ -85,7 +85,11 @@ unsigned char *pcp_box_encrypt(pcp_key_t *secret, pcp_pubkey_t *public,
|
||||
unsigned char *message, size_t messagesize,
|
||||
size_t *csize) {
|
||||
|
||||
unsigned char *nonce = pcp_gennonce();
|
||||
//unsigned char *nonce = pcp_gennonce();
|
||||
|
||||
unsigned char *nonce = ucmalloc(crypto_secretbox_NONCEBYTES);
|
||||
memset(nonce, 1, crypto_secretbox_NONCEBYTES);
|
||||
|
||||
unsigned char *cipher;
|
||||
|
||||
size_t es = pcp_sodium_box(&cipher, message, messagesize, nonce,
|
||||
@@ -96,6 +100,12 @@ unsigned char *pcp_box_encrypt(pcp_key_t *secret, pcp_pubkey_t *public,
|
||||
goto errbec;
|
||||
}
|
||||
|
||||
// scip
|
||||
//fprintf(stderr, "public: "); pcpprint_bin(stderr, public->public, 32); fprintf(stderr, "\n");
|
||||
//fprintf(stderr, "secret: "); pcpprint_bin(stderr, secret->secret, 32); fprintf(stderr, "\n");
|
||||
//fprintf(stderr, "cipher: "); pcpprint_bin(stderr, cipher, es); fprintf(stderr, "\n");
|
||||
//fprintf(stderr, " nonce: "); pcpprint_bin(stderr, nonce, crypto_secretbox_NONCEBYTES); fprintf(stderr, "\n");
|
||||
|
||||
// put nonce and cipher together
|
||||
unsigned char *combined = ucmalloc(es + crypto_secretbox_NONCEBYTES);
|
||||
memcpy(combined, nonce, crypto_secretbox_NONCEBYTES);
|
||||
|
||||
@@ -78,7 +78,7 @@ pcp_sig_t *pcp_ed_newsig(unsigned char *hash, char *id) {
|
||||
}
|
||||
|
||||
pcp_sig_t *sig2native(pcp_sig_t *s) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return s;
|
||||
#else
|
||||
s->version = be32toh(s->version);
|
||||
@@ -88,7 +88,7 @@ pcp_sig_t *sig2native(pcp_sig_t *s) {
|
||||
}
|
||||
|
||||
pcp_sig_t *sig2be(pcp_sig_t *s) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return s;
|
||||
#else
|
||||
s->version = htobe32(s->version);
|
||||
|
||||
@@ -228,7 +228,7 @@ unsigned char *pcpkey_getchecksum(pcp_key_t *k) {
|
||||
|
||||
|
||||
pcp_key_t * key2be(pcp_key_t *k) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return k;
|
||||
#else
|
||||
uint32_t version = k->version;
|
||||
@@ -243,7 +243,7 @@ pcp_key_t * key2be(pcp_key_t *k) {
|
||||
}
|
||||
|
||||
pcp_key_t *key2native(pcp_key_t *k) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return k;
|
||||
#else
|
||||
k->version = be32toh(k->version);
|
||||
@@ -254,7 +254,7 @@ pcp_key_t *key2native(pcp_key_t *k) {
|
||||
}
|
||||
|
||||
pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return k;
|
||||
#else
|
||||
uint32_t version = k->version;
|
||||
@@ -269,7 +269,7 @@ pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k) {
|
||||
}
|
||||
|
||||
pcp_pubkey_t *pubkey2native(pcp_pubkey_t *k) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return k;
|
||||
#else
|
||||
k->version = be32toh(k->version);
|
||||
|
||||
@@ -358,7 +358,7 @@ int pcpvault_close(vault_t *vault) {
|
||||
}
|
||||
|
||||
vault_header_t * vh2be(vault_header_t *h) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return h;
|
||||
#else
|
||||
h->version = htobe32(h->version);
|
||||
@@ -367,7 +367,7 @@ vault_header_t * vh2be(vault_header_t *h) {
|
||||
}
|
||||
|
||||
vault_header_t * vh2native(vault_header_t *h) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return h;
|
||||
#else
|
||||
h->version = be32toh(h->version);
|
||||
@@ -376,7 +376,7 @@ vault_header_t * vh2native(vault_header_t *h) {
|
||||
}
|
||||
|
||||
vault_item_header_t * ih2be(vault_item_header_t *h) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return h;
|
||||
#else
|
||||
h->version = htobe32(h->version);
|
||||
@@ -386,7 +386,7 @@ vault_item_header_t * ih2be(vault_item_header_t *h) {
|
||||
}
|
||||
|
||||
vault_item_header_t * ih2native(vault_item_header_t *h) {
|
||||
#ifdef __BIG_ENDIAN
|
||||
#ifdef __CPU_IS_BIG_ENDIAN
|
||||
return h;
|
||||
#else
|
||||
h->version = be32toh(h->version);
|
||||
|
||||
Reference in New Issue
Block a user