mirror of
https://github.com/henrydcase/pqc.git
synced 2024-11-26 17:31:38 +00:00
Resolve type coercions
This commit is contained in:
parent
a14dcefb32
commit
a300190d5b
@ -12,11 +12,11 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_prf_addr(
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random(
|
||||
unsigned char *R,
|
||||
const unsigned char *sk_prf, const unsigned char *optrand,
|
||||
const unsigned char *m, unsigned long long mlen);
|
||||
const unsigned char *m, size_t mlen);
|
||||
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message(
|
||||
unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx,
|
||||
const unsigned char *R, const unsigned char *pk,
|
||||
const unsigned char *m, unsigned long long mlen);
|
||||
const unsigned char *m, size_t mlen);
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_prf_addr(
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random(
|
||||
unsigned char *R,
|
||||
const unsigned char *sk_prf, const unsigned char *optrand,
|
||||
const unsigned char *m, unsigned long long mlen) {
|
||||
const unsigned char *m, size_t mlen) {
|
||||
uint64_t s_inc[26];
|
||||
|
||||
shake256_inc_init(s_inc);
|
||||
@ -54,7 +54,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_gen_message_random(
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message(
|
||||
unsigned char *digest, uint64_t *tree, uint32_t *leaf_idx,
|
||||
const unsigned char *R, const unsigned char *pk,
|
||||
const unsigned char *m, unsigned long long mlen) {
|
||||
const unsigned char *m, size_t mlen) {
|
||||
#define SPX_TREE_BITS (SPX_TREE_HEIGHT * (SPX_D - 1))
|
||||
#define SPX_TREE_BYTES ((SPX_TREE_BITS + 7) / 8)
|
||||
#define SPX_LEAF_BITS SPX_TREE_HEIGHT
|
||||
@ -84,7 +84,7 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_hash_message(
|
||||
*tree &= (~(uint64_t)0) >> (64 - SPX_TREE_BITS);
|
||||
bufp += SPX_TREE_BYTES;
|
||||
|
||||
*leaf_idx = PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull(
|
||||
*leaf_idx = (uint32_t)PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull(
|
||||
bufp, SPX_LEAF_BYTES);
|
||||
*leaf_idx &= (~(uint32_t)0) >> (32 - SPX_LEAF_BITS);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ int PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_crypto_sign_signature(
|
||||
unsigned char optrand[SPX_N];
|
||||
unsigned char mhash[SPX_FORS_MSG_BYTES];
|
||||
unsigned char root[SPX_N];
|
||||
unsigned long long i;
|
||||
uint32_t i;
|
||||
uint64_t tree;
|
||||
uint32_t idx_leaf;
|
||||
uint32_t wots_addr[8] = {0};
|
||||
|
@ -1,21 +1,21 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "address.h"
|
||||
#include "hash.h"
|
||||
#include "params.h"
|
||||
#include "thash.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* Converts the value of 'in' to 'outlen' bytes in big-endian byte order.
|
||||
*/
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes(
|
||||
unsigned char *out, unsigned int outlen, unsigned long long in) {
|
||||
int i;
|
||||
unsigned char *out, size_t outlen, unsigned long long in) {
|
||||
|
||||
/* Iterate over out in decreasing order, for big-endianness. */
|
||||
for (i = outlen - 1; i >= 0; i--) {
|
||||
out[i] = in & 0xff;
|
||||
for (size_t i = outlen; i > 0; i--) {
|
||||
out[i - 1] = in & 0xff;
|
||||
in = in >> 8;
|
||||
}
|
||||
}
|
||||
@ -24,11 +24,10 @@ void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes(
|
||||
* Converts the inlen bytes in 'in' from big-endian byte order to an integer.
|
||||
*/
|
||||
unsigned long long PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull(
|
||||
const unsigned char *in, unsigned int inlen) {
|
||||
const unsigned char *in, size_t inlen) {
|
||||
unsigned long long retval = 0;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < inlen; i++) {
|
||||
for (size_t i = 0; i < inlen; i++) {
|
||||
retval |= ((unsigned long long)in[i]) << (8 * (inlen - 1 - i));
|
||||
}
|
||||
return retval;
|
||||
|
@ -2,19 +2,20 @@
|
||||
#define SPX_UTILS_H
|
||||
|
||||
#include "params.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Converts the value of 'in' to 'outlen' bytes in big-endian byte order.
|
||||
*/
|
||||
void PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_ull_to_bytes(
|
||||
unsigned char *out, unsigned int outlen, unsigned long long in);
|
||||
unsigned char *out, size_t outlen, unsigned long long in);
|
||||
|
||||
/**
|
||||
* Converts the inlen bytes in 'in' from big-endian byte order to an integer.
|
||||
*/
|
||||
unsigned long long PQCLEAN_SPHINCSSHAKE256128FSIMPLE_CLEAN_bytes_to_ull(
|
||||
const unsigned char *in, unsigned int inlen);
|
||||
const unsigned char *in, size_t inlen);
|
||||
|
||||
/**
|
||||
* Computes a root node given a leaf and an auth path.
|
||||
|
Loading…
Reference in New Issue
Block a user