Parcourir la source

Consistently return -1 on failure

master
Joost Rijneveld il y a 7 ans
Parent
révision
b9b84b9f9e
Aucune clé connue n'a été trouvée dans la base pour cette signature ID de la clé GPG: A4FE39CF49CBC553
5 fichiers modifiés avec 22 ajouts et 22 suppressions
  1. +1
    -1
      hash.c
  2. +7
    -7
      params.c
  3. +4
    -4
      params.h
  4. +6
    -6
      xmss.c
  5. +4
    -4
      xmss_core_fast.c

+ 1
- 1
hash.c Voir le fichier

@@ -38,7 +38,7 @@ static int core_hash(const xmss_params *params,
shake256(out, 64, in, inlen);
}
else {
return 1;
return -1;
}
return 0;
}


+ 7
- 7
params.c Voir le fichier

@@ -174,7 +174,7 @@ int xmss_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}
switch (oid) {
case 0x01000001:
@@ -198,7 +198,7 @@ int xmss_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}
switch (oid) {
case 0x01000001:
@@ -223,7 +223,7 @@ int xmss_parse_oid(xmss_params *params, const uint32_t oid)

break;
default:
return 1;
return -1;
}
params->d = 1;
params->tree_height = params->full_height / params->d;
@@ -289,7 +289,7 @@ int xmssmt_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}
switch (oid) {
case 0x01000001:
@@ -333,7 +333,7 @@ int xmssmt_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}
switch (oid) {
case 0x01000001:
@@ -387,7 +387,7 @@ int xmssmt_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}
switch (oid) {
case 0x01000001:
@@ -441,7 +441,7 @@ int xmssmt_parse_oid(xmss_params *params, const uint32_t oid)
break;

default:
return 1;
return -1;
}

params->tree_height = params->full_height / params->d;


+ 4
- 4
params.h Voir le fichier

@@ -33,26 +33,26 @@ typedef struct {
/**
* Accepts strings such as "XMSS-SHA2_10_256"
* and outputs OIDs such as 0x01000001.
* Returns 1 when the parameter set is not found, 0 otherwise
* Returns -1 when the parameter set is not found, 0 otherwise
*/
int xmss_str_to_oid(uint32_t *oid, const char* s);

/**
* Accepts takes strings such as "XMSSMT-SHA2_20/2_256"
* and outputs OIDs such as 0x01000001.
* Returns 1 when the parameter set is not found, 0 otherwise
* Returns -1 when the parameter set is not found, 0 otherwise
*/
int xmssmt_str_to_oid(uint32_t *oid, const char* s);

/**
* Accepts OIDs such as 0x01000001, and configures params accordingly.
* Returns 1 when the OID is not found, 0 otherwise.
* Returns -1 when the OID is not found, 0 otherwise.
*/
int xmss_parse_oid(xmss_params *params, const uint32_t oid);

/**
* Accepts OIDs such as 0x01000001, and configures params accordingly.
* Returns 1 when the OID is not found, 0 otherwise.
* Returns -1 when the OID is not found, 0 otherwise.
*/
int xmssmt_parse_oid(xmss_params *params, const uint32_t oid);



+ 6
- 6
xmss.c Voir le fichier

@@ -13,7 +13,7 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk, const uint32_t oid)
unsigned int i;

if (xmss_parse_oid(&params, oid)) {
return 1;
return -1;
}
for (i = 0; i < XMSS_OID_LEN; i++) {
pk[i] = (oid >> (8 * i)) & 0xFF;
@@ -37,7 +37,7 @@ int xmss_sign(unsigned char *sk,
oid |= sk[i] << (i * 8);
}
if (xmss_parse_oid(&params, oid)) {
return 1;
return -1;
}
return xmss_core_sign(&params, sk + XMSS_OID_LEN, sm, smlen, m, mlen);
}
@@ -54,7 +54,7 @@ int xmss_sign_open(unsigned char *m, unsigned long long *mlen,
oid |= pk[i] << (i * 8);
}
if (xmss_parse_oid(&params, oid)) {
return 1;
return -1;
}
return xmss_core_sign_open(&params, m, mlen, sm, smlen, pk + XMSS_OID_LEN);
}
@@ -65,7 +65,7 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk, const uint32_t oid)
unsigned int i;

if (xmssmt_parse_oid(&params, oid)) {
return 1;
return -1;
}
for (i = 0; i < XMSS_OID_LEN; i++) {
pk[i] = (oid >> (8 * i)) & 0xFF;
@@ -86,7 +86,7 @@ int xmssmt_sign(unsigned char *sk,
oid |= sk[i] << (i * 8);
}
if (xmssmt_parse_oid(&params, oid)) {
return 1;
return -1;
}
return xmssmt_core_sign(&params, sk + XMSS_OID_LEN, sm, smlen, m, mlen);
}
@@ -103,7 +103,7 @@ int xmssmt_sign_open(unsigned char *m, unsigned long long *mlen,
oid |= pk[i] << (i * 8);
}
if (xmssmt_parse_oid(&params, oid)) {
return 1;
return -1;
}
return xmssmt_core_sign_open(&params, m, mlen, sm, smlen, pk + XMSS_OID_LEN);
}

+ 4
- 4
xmss_core_fast.c Voir le fichier

@@ -328,8 +328,8 @@ static void treehash_update(const xmss_params *params,
}

/**
* Performs one treehash update on the instance that needs it the most.
* Returns 1 if such an instance was not found
* Performs treehash updates on the instance that needs it the most.
* Returns the updated number of available updates.
**/
static char bds_treehash_update(const xmss_params *params,
bds_state *state, unsigned int updates,
@@ -370,7 +370,7 @@ static char bds_treehash_update(const xmss_params *params,

/**
* Updates the state (typically NEXT_i) by adding a leaf and updating the stack
* Returns 1 if all leaf nodes have already been processed
* Returns -1 if all leaf nodes have already been processed
**/
static char bds_state_update(const xmss_params *params,
bds_state *state, const unsigned char *sk_seed,
@@ -384,7 +384,7 @@ static char bds_state_update(const xmss_params *params,
unsigned int nodeh;
int idx = state->next_leaf;
if (idx == 1 << params->tree_height) {
return 1;
return -1;
}

// only copy layer and tree address parts


Chargement…
Annuler
Enregistrer