mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
equix: Portability fixes for big endian platforms
Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
This commit is contained in:
parent
daa08557ad
commit
ae86d98815
@ -42,11 +42,23 @@ static int initialize_program(hashx_ctx* ctx, hashx_program* program,
|
||||
int hashx_make(hashx_ctx* ctx, const void* seed, size_t size) {
|
||||
assert(ctx != NULL && ctx != HASHX_NOTSUPP);
|
||||
assert(seed != NULL || size == 0);
|
||||
siphash_state keys[2];
|
||||
|
||||
uint8_t keys_bytes[2 * sizeof(siphash_state)];
|
||||
blake2b_state hash_state;
|
||||
hashx_blake2b_init_param(&hash_state, &hashx_blake2_params);
|
||||
hashx_blake2b_update(&hash_state, seed, size);
|
||||
hashx_blake2b_final(&hash_state, &keys, sizeof(keys));
|
||||
hashx_blake2b_final(&hash_state, keys_bytes, sizeof(keys_bytes));
|
||||
|
||||
siphash_state keys[2];
|
||||
keys[0].v0 = load64(keys_bytes + 0 * sizeof(uint64_t));
|
||||
keys[0].v1 = load64(keys_bytes + 1 * sizeof(uint64_t));
|
||||
keys[0].v2 = load64(keys_bytes + 2 * sizeof(uint64_t));
|
||||
keys[0].v3 = load64(keys_bytes + 3 * sizeof(uint64_t));
|
||||
keys[1].v0 = load64(keys_bytes + 4 * sizeof(uint64_t));
|
||||
keys[1].v1 = load64(keys_bytes + 5 * sizeof(uint64_t));
|
||||
keys[1].v2 = load64(keys_bytes + 6 * sizeof(uint64_t));
|
||||
keys[1].v3 = load64(keys_bytes + 7 * sizeof(uint64_t));
|
||||
|
||||
if (ctx->type & HASHX_COMPILED) {
|
||||
hashx_program program;
|
||||
if (!initialize_program(ctx, &program, keys)) {
|
||||
|
@ -17,12 +17,26 @@ static inline bool tree_cmp1(const equix_idx* left, const equix_idx* right) {
|
||||
return *left <= *right;
|
||||
}
|
||||
|
||||
static inline uint32_t tree_idx2(const equix_idx* idx) {
|
||||
return
|
||||
(uint32_t)idx[1] << 1*16 |
|
||||
(uint32_t)idx[0] << 0*16;
|
||||
}
|
||||
|
||||
static inline bool tree_cmp2(const equix_idx* left, const equix_idx* right) {
|
||||
return load32(left) <= load32(right);
|
||||
return tree_idx2(left) <= tree_idx2(right);
|
||||
}
|
||||
|
||||
static inline uint64_t tree_idx4(const equix_idx* idx) {
|
||||
return
|
||||
(uint64_t)idx[3] << 3*16 |
|
||||
(uint64_t)idx[2] << 2*16 |
|
||||
(uint64_t)idx[1] << 1*16 |
|
||||
(uint64_t)idx[0] << 0*16;
|
||||
}
|
||||
|
||||
static inline bool tree_cmp4(const equix_idx* left, const equix_idx* right) {
|
||||
return load64(left) <= load64(right);
|
||||
return tree_idx4(left) <= tree_idx4(right);
|
||||
}
|
||||
|
||||
EQUIX_PRIVATE int equix_solver_solve(hashx_ctx* hash_func, solver_heap* heap, equix_solution output[EQUIX_MAX_SOLS]);
|
||||
|
Loading…
Reference in New Issue
Block a user