X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=dsa%2Fdsa_sign.c;h=b13ec45dc4a7d582ae511b051620a21bcdf4ba14;hb=3a9f9d918fb95474996af535c225a7e187d88372;hp=fab21976ed4b98038f3d4085940206e778905f4c;hpb=d1181933dc28db92d787cf5604e2fc96ab0d8f9f;p=avr-crypto-lib.git diff --git a/dsa/dsa_sign.c b/dsa/dsa_sign.c index fab2197..b13ec45 100644 --- a/dsa/dsa_sign.c +++ b/dsa/dsa_sign.c @@ -24,10 +24,10 @@ #include "hashfunction_descriptor.h" #include "hfal-basic.h" -uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m, - const dsa_ctx_t* ctx, const bigint_t* k){ +uint8_t dsa_sign_bigint(dsa_signature_t *s, const bigint_t *m, + const dsa_ctx_t *ctx, const bigint_t *k){ bigint_t tmp, tmp2; - uint8_t tmp_b[ctx->domain.p.length_B+5], tmp2_b[ctx->domain.q.length_B+5]; + uint8_t tmp_b[ctx->domain.p.length_W+5], tmp2_b[ctx->domain.q.length_W+5]; tmp.wordv= tmp_b; tmp2.wordv = tmp2_b; bigint_expmod_u(&tmp, &(ctx->domain.g), k, &(ctx->domain.p)); @@ -40,31 +40,31 @@ uint8_t dsa_sign_bigint(dsa_signature_t* s, const bigint_t* m, bigint_reduce(&tmp, &(ctx->domain.q)); bigint_copy(&(s->s), &tmp); - if(s->s.length_B==0 || s->r.length_B==0){ + if(s->s.length_W==0 || s->r.length_W==0){ return 1; } return 0; } -uint8_t dsa_sign_message(dsa_signature_t* s, const void* m, uint16_t m_len_b, - const hfdesc_t* hash_desc, const dsa_ctx_t* ctx, +uint8_t dsa_sign_message(dsa_signature_t *s, const void *m, uint16_t m_len_b, + const hfdesc_t *hash_desc, const dsa_ctx_t *ctx, const rand_func_ptr_t rand_in){ bigint_t z, k; - uint8_t i, n_B = ctx->domain.q.length_B; + uint8_t i, n_B = ctx->domain.q.length_W; uint8_t hash_value[(n_B>(hfal_hash_getHashsize(hash_desc)+7)/8)?n_B:(hfal_hash_getHashsize(hash_desc)+7)/8]; uint8_t k_b[n_B]; hfal_hash_mem(hash_desc, hash_value, m, m_len_b); z.wordv = hash_value; - z.length_B = n_B; + z.length_W = n_B; bigint_changeendianess(&z); k.wordv = k_b; - k.length_B = n_B; + k.length_W = n_B; do{ for(i=0; i