This is an automated email from the ASF dual-hosted git repository. sandreoli pushed a commit to branch review-bls in repository https://gitbox.apache.org/repos/asf/incubator-milagro-crypto-c.git
commit 8bdaae298288d85a316905ce21e163af0b464c79 Author: samuele-andreoli <[email protected]> AuthorDate: Wed Nov 13 16:21:14 2019 +0000 code cleanup --- src/bls.c.in | 18 ++++-------------- src/bls192.c.in | 19 +++++-------------- src/bls256.c.in | 19 +++++-------------- 3 files changed, 14 insertions(+), 42 deletions(-) diff --git a/src/bls.c.in b/src/bls.c.in index 1909110..009dabd 100644 --- a/src/bls.c.in +++ b/src/bls.c.in @@ -128,6 +128,7 @@ int BLS_ZZZ_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W) PAIR_ZZZ_G2mul(&G,s); ECP2_ZZZ_toOctet(W,&G); + return BLS_OK; } @@ -141,6 +142,7 @@ int BLS_ZZZ_SIGN(octet *SIG,char *m,octet *S) PAIR_ZZZ_G1mul(&D,s); // compress output ECP_ZZZ_toOctet(SIG,&D,true); + return BLS_OK; } @@ -336,13 +338,8 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory BIG_XXX_fromBytes(y,Y[i].val); + BIG_XXX_modmul(prod,y,coefs[i],r); BIG_XXX_add(secret, secret, prod); @@ -354,6 +351,7 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) // Output secret BIG_XXX_toBytes(SK->val,secret); + SK->len = MODBYTES_XXX; return BLS_OK; } @@ -370,12 +368,6 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory if (!ECP_ZZZ_fromOctet(&y,&Y[i])) { return BLS_INVALID_G1; @@ -389,5 +381,3 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) return BLS_OK; } - - diff --git a/src/bls192.c.in b/src/bls192.c.in index 86d850b..97c631d 100644 --- a/src/bls192.c.in +++ b/src/bls192.c.in @@ -128,6 +128,7 @@ int BLS_ZZZ_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W) PAIR_ZZZ_G2mul(&G,s); ECP4_ZZZ_toOctet(W,&G); + return BLS_OK; } @@ -140,6 +141,7 @@ int BLS_ZZZ_SIGN(octet *SIG,char *m,octet *S) BIG_XXX_fromBytes(s,S->val); PAIR_ZZZ_G1mul(&D,s); ECP_ZZZ_toOctet(SIG,&D,true); /* compress output */ + return BLS_OK; } @@ -171,6 +173,7 @@ int BLS_ZZZ_VERIFY(octet *SIG,char *m,octet *W) { return BLS_FAIL; } + return BLS_OK; } @@ -336,13 +339,8 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory BIG_XXX_fromBytes(y,Y[i].val); + BIG_XXX_modmul(prod,y,coefs[i],r); BIG_XXX_add(secret, secret, prod); @@ -354,6 +352,7 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) // Output secret BIG_XXX_toBytes(SK->val,secret); + SK->len = MODBYTES_XXX; return BLS_OK; } @@ -370,12 +369,6 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory if (!ECP_ZZZ_fromOctet(&y,&Y[i])) { return BLS_INVALID_G1; @@ -389,5 +382,3 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) return BLS_OK; } - - diff --git a/src/bls256.c.in b/src/bls256.c.in index ad528be..f847b3f 100644 --- a/src/bls256.c.in +++ b/src/bls256.c.in @@ -128,6 +128,7 @@ int BLS_ZZZ_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W) PAIR_ZZZ_G2mul(&G,s); ECP8_ZZZ_toOctet(W,&G); + return BLS_OK; } @@ -140,6 +141,7 @@ int BLS_ZZZ_SIGN(octet *SIG,char *m,octet *S) BIG_XXX_fromBytes(s,S->val); PAIR_ZZZ_G1mul(&D,s); ECP_ZZZ_toOctet(SIG,&D,true); /* compress output */ + return BLS_OK; } @@ -172,6 +174,7 @@ int BLS_ZZZ_VERIFY(octet *SIG,char *m,octet *W) { return BLS_FAIL; } + return BLS_OK; } @@ -336,13 +339,8 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory BIG_XXX_fromBytes(y,Y[i].val); + BIG_XXX_modmul(prod,y,coefs[i],r); BIG_XXX_add(secret, secret, prod); @@ -354,6 +352,7 @@ int BLS_ZZZ_RECOVER_SECRET(int k, octet* X, octet* Y, octet* SK) // Output secret BIG_XXX_toBytes(SK->val,secret); + SK->len = MODBYTES_XXX; return BLS_OK; } @@ -370,12 +369,6 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) for(int i=0; i<k; i++) { - // TODO - // This is validating the input as we go, giving the opportunity - // for an attacker to forge a malicious input which would only - // fail after most of the computation is done. - // - // Might want to change this sacrificing some memory if (!ECP_ZZZ_fromOctet(&y,&Y[i])) { return BLS_INVALID_G1; @@ -389,5 +382,3 @@ int BLS_ZZZ_RECOVER_SIGNATURE(int k, octet* X, octet* Y, octet* SIG) return BLS_OK; } - -
