handling compiler warnings
Karel Miko
10 years ago
5 | 5 | |
6 | 6 | my $flags = '-Isrc/ltc/headers -Isrc/ltm -DLTC_SOURCE -DLTC_NO_TEST -DLTC_NO_PROTOTYPES -DLTM_DESC'; |
7 | 7 | #$flags .= ' -DLTC_NO_ASM'; |
8 | $flags .= ' -Wall'; | |
8 | #$flags .= ' -Wall'; | |
9 | 9 | |
10 | 10 | unless ($ENV{CRYPTX_USE_ASM} || $Config{archname} =~ /MSWin32-x86/) { |
11 | 11 | $flags .= ' -DLTC_NO_ASM'; |
219 | 219 | SvPV_nolen(*sv_order), |
220 | 220 | SvPV_nolen(*sv_Gx), |
221 | 221 | SvPV_nolen(*sv_Gy), |
222 | SvIV(*sv_cofactor), | |
222 | (unsigned long)SvUV(*sv_cofactor), | |
223 | 223 | ch_name ); |
224 | 224 | return err == CRYPT_OK ? dp : NULL; |
225 | 225 | } |
239 | 239 | char *Gy; |
240 | 240 | |
241 | 241 | /** The co-factor */ |
242 | int cofactor; | |
242 | unsigned long cofactor; | |
243 | 243 | } ltc_ecc_set_type; |
244 | 244 | |
245 | 245 | /** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */ |
280 | 280 | int ecc_get_size(ecc_key *key); |
281 | 281 | |
282 | 282 | int ecc_dp_init(ltc_ecc_set_type *dp); |
283 | int ecc_dp_set(ltc_ecc_set_type *dp, char *ch_prime, char *ch_A, char *ch_B, char *ch_order, char *ch_Gx, char *ch_Gy, int cofactor, char *ch_name); | |
283 | int ecc_dp_set(ltc_ecc_set_type *dp, char *ch_prime, char *ch_A, char *ch_B, char *ch_order, char *ch_Gx, char *ch_Gy, unsigned long cofactor, char *ch_name); | |
284 | 284 | int ecc_dp_clear(ltc_ecc_set_type *dp); |
285 | 285 | |
286 | 286 | int ecc_make_key(prng_state *prng, int wprng, int keysize, ecc_key *key); |
15 | 15 | |
16 | 16 | #ifdef LTC_MECC |
17 | 17 | |
18 | int ecc_dp_set(ltc_ecc_set_type *dp, char *ch_prime, char *ch_A, char *ch_B, char *ch_order, char *ch_Gx, char *ch_Gy, int cofactor, char *ch_name) | |
18 | int ecc_dp_set(ltc_ecc_set_type *dp, char *ch_prime, char *ch_A, char *ch_B, char *ch_order, char *ch_Gx, char *ch_Gy, unsigned long cofactor, char *ch_name) | |
19 | 19 | { |
20 | 20 | unsigned long l_name, l_prime, l_A, l_B, l_order, l_Gx, l_Gy; |
21 | 21 | |
22 | if (!dp || !ch_prime || !ch_A || !ch_B || !ch_order || !ch_Gx || !ch_Gy || cofactor<=0) return CRYPT_INVALID_ARG; | |
22 | if (!dp || !ch_prime || !ch_A || !ch_B || !ch_order || !ch_Gx || !ch_Gy || cofactor==0) return CRYPT_INVALID_ARG; | |
23 | 23 | |
24 | l_name = strlen(ch_name); | |
25 | l_prime = strlen(ch_prime); | |
26 | l_A = strlen(ch_A); | |
27 | l_B = strlen(ch_B); | |
28 | l_order = strlen(ch_order); | |
29 | l_Gx = strlen(ch_Gx); | |
30 | l_Gy = strlen(ch_Gy); | |
24 | l_name = (unsigned long)strlen(ch_name); | |
25 | l_prime = (unsigned long)strlen(ch_prime); | |
26 | l_A = (unsigned long)strlen(ch_A); | |
27 | l_B = (unsigned long)strlen(ch_B); | |
28 | l_order = (unsigned long)strlen(ch_order); | |
29 | l_Gx = (unsigned long)strlen(ch_Gx); | |
30 | l_Gy = (unsigned long)strlen(ch_Gy); | |
31 | 31 | |
32 | 32 | dp->cofactor = cofactor; |
33 | 33 |
16 | 16 | |
17 | 17 | #ifdef LTC_MECC |
18 | 18 | |
19 | static int _populate_dp(void *a, void *b, void *prime, void *order, void *gx, void *gy, int cofactor, ltc_ecc_set_type *dp) | |
19 | static int _populate_dp(void *a, void *b, void *prime, void *order, void *gx, void *gy, unsigned long cofactor, ltc_ecc_set_type *dp) | |
20 | 20 | { |
21 | 21 | unsigned char buf[ECC_BUF_SIZE]; |
22 | 22 | unsigned long len; |
23 | 23 | |
24 | 24 | /* a */ |
25 | 25 | mp_tohex(a, (char *)buf); |
26 | len = strlen((char *)buf); | |
26 | len = (unsigned long)strlen((char *)buf); | |
27 | 27 | if ((dp->A = XMALLOC(1+len)) == NULL) goto cleanup1; |
28 | 28 | strncpy(dp->A, (char*)buf, 1+len); |
29 | 29 | /* b */ |
30 | 30 | mp_tohex(b, (char *)buf); |
31 | len = strlen((char *)buf); | |
31 | len = (unsigned long)strlen((char *)buf); | |
32 | 32 | if ((dp->B = XMALLOC(1+len)) == NULL) goto cleanup2; |
33 | 33 | strncpy(dp->B, (char*)buf, 1+len); |
34 | 34 | /* order */ |
35 | 35 | mp_tohex(order, (char *)buf); |
36 | len = strlen((char *)buf); | |
36 | len = (unsigned long)strlen((char *)buf); | |
37 | 37 | if ((dp->order = XMALLOC(1+len)) == NULL) goto cleanup3; |
38 | 38 | strncpy(dp->order, (char*)buf, 1+len); |
39 | 39 | /* prime */ |
40 | 40 | mp_tohex(prime, (char *)buf); |
41 | len = strlen((char *)buf); | |
41 | len = (unsigned long)strlen((char *)buf); | |
42 | 42 | if ((dp->prime = XMALLOC(1+len)) == NULL) goto cleanup4; |
43 | 43 | strncpy(dp->prime, (char*)buf, 1+len); |
44 | 44 | /* gx */ |
45 | 45 | mp_tohex(gx, (char *)buf); |
46 | len = strlen((char *)buf); | |
46 | len = (unsigned long)strlen((char *)buf); | |
47 | 47 | if ((dp->Gx = XMALLOC(1+len)) == NULL) goto cleanup5; |
48 | 48 | strncpy(dp->Gx, (char*)buf, 1+len); |
49 | 49 | /* gy */ |
50 | 50 | mp_tohex(gy, (char *)buf); |
51 | len = strlen((char *)buf); | |
51 | len = (unsigned long)strlen((char *)buf); | |
52 | 52 | if ((dp->Gy = XMALLOC(1+len)) == NULL) goto cleanup6; |
53 | 53 | strncpy(dp->Gy, (char*)buf, 1+len); |
54 | 54 | /* cofactor & size */ |
17 | 17 | |
18 | 18 | int ecc_import_point(const unsigned char *in, unsigned long inlen, void *prime, void *a, void *b, void *x, void *y) |
19 | 19 | { |
20 | int err, size; | |
20 | int err; | |
21 | unsigned long size; | |
21 | 22 | void *t1, *t2; |
22 | 23 | |
23 | 24 | /* init key + temporary numbers */ |
83 | 84 | |
84 | 85 | int ecc_import_raw(const unsigned char *in, unsigned long inlen, ecc_key *key, ltc_ecc_set_type *dp) |
85 | 86 | { |
86 | int err, size = 0, type = -1; | |
87 | int err, type = -1; | |
88 | unsigned long size = 0; | |
87 | 89 | void *prime, *a, *b; |
88 | 90 | ecc_point *base; |
89 | 91 | |
96 | 98 | return CRYPT_MEM; |
97 | 99 | } |
98 | 100 | |
99 | if (inlen == dp->size) { | |
101 | if (inlen == (unsigned long)dp->size) { | |
100 | 102 | /* read PRIVATE key */ |
101 | 103 | type = PK_PRIVATE; |
102 | 104 | size = inlen; |
38 | 38 | ecc_key pubkey; |
39 | 39 | void *r, *s, *e, *p; |
40 | 40 | int err; |
41 | int pbits, pbytes, i, shift_right; | |
41 | unsigned long pbits, pbytes, i, shift_right; | |
42 | 42 | unsigned char ch, buf[MAXBLOCKSIZE]; |
43 | 43 | |
44 | 44 | LTC_ARGCHK(in != NULL); |
70 | 70 | pbits = mp_count_bits(p); |
71 | 71 | pbytes = (pbits+7) >> 3; |
72 | 72 | if (pbits > inlen*8) { |
73 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)in, (int)inlen)) != CRYPT_OK) { goto errnokey; } | |
73 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)in, inlen)) != CRYPT_OK) { goto errnokey; } | |
74 | 74 | } |
75 | 75 | else if (pbits % 8 == 0) { |
76 | 76 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)in, pbytes)) != CRYPT_OK) { goto errnokey; } |
48 | 48 | void *r, *s, *v, *w, *u1, *u2, *e, *p, *m, *a; |
49 | 49 | void *mp; |
50 | 50 | int err; |
51 | int pbits, pbytes, i, shift_right; | |
51 | unsigned long pbits, pbytes, i, shift_right; | |
52 | 52 | unsigned char ch, buf[MAXBLOCKSIZE]; |
53 | 53 | |
54 | 54 | LTC_ARGCHK(sig != NULL); |
105 | 105 | pbits = mp_count_bits(p); |
106 | 106 | pbytes = (pbits+7) >> 3; |
107 | 107 | if (pbits > hashlen*8) { |
108 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)hash, (int)hashlen)) != CRYPT_OK) { goto error; } | |
108 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)hash, hashlen)) != CRYPT_OK) { goto error; } | |
109 | 109 | } |
110 | 110 | else if (pbits % 8 == 0) { |
111 | 111 | if ((err = mp_read_unsigned_bin(e, (unsigned char *)hash, pbytes)) != CRYPT_OK) { goto error; } |