Skip to content

Commit 708e5e1

Browse files
committed
tuning ECC xs code
1 parent 49031cb commit 708e5e1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

inc/CryptX_PK_ECC.xs.inc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,11 +417,11 @@ sign_hash(Crypt::PK::ECC self, SV * data, const char * hash_name = NULL, const c
417417
sign_hash_eth = 4
418418
CODE:
419419
{
420-
int rv, id, hash_rfc6979_id;
420+
int rv, id, hash_rfc6979_id, r = -1;
421421
unsigned char buffer[1024], tmp[MAXBLOCKSIZE], *data_ptr = NULL;
422422
unsigned long tmp_len = MAXBLOCKSIZE, buffer_len = 1024;
423423
STRLEN data_len = 0;
424-
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962 };
424+
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962, .recid = &r, .rfc6979_hash_alg = NULL };
425425

426426
// Handle dual signature modes for backward compatibility
427427
// For sign_hash_*: if only 2 params passed, treat second as RFC6979 hash
@@ -482,11 +482,11 @@ verify_hash(Crypt::PK::ECC self, SV * sig, SV * data, const char * hash_name = "
482482
verify_hash_eth = 4
483483
CODE:
484484
{
485-
int rv, stat, id;
485+
int rv, stat, id, r = -1;
486486
unsigned char tmp[MAXBLOCKSIZE], *data_ptr = NULL, *sig_ptr = NULL;
487487
unsigned long tmp_len = MAXBLOCKSIZE;
488488
STRLEN data_len = 0, sig_len = 0;
489-
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962 };
489+
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962, .recid = &r, .rfc6979_hash_alg = NULL };
490490

491491
data_ptr = (unsigned char *)SvPVbyte(data, data_len);
492492
sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
@@ -543,7 +543,7 @@ recovery_pub(Crypt::PK::ECC self, SV * sig, SV* hash, SV* recid = NULL)
543543
int rv, r = -1;
544544
unsigned char *sig_ptr = NULL, *hash_ptr = NULL;
545545
STRLEN hash_len = 0, sig_len = 0;
546-
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962 };
546+
ltc_ecc_sig_opts sig_opts = { .prng = &self->pstate, .wprng = self->pindex, .type = LTC_ECCSIG_ANSIX962, .recid = &r, .rfc6979_hash_alg = NULL };
547547

548548
if (recid != NULL) {
549549
r = (int) SvIV(recid);
@@ -555,7 +555,6 @@ recovery_pub(Crypt::PK::ECC self, SV * sig, SV* hash, SV* recid = NULL)
555555
croak("FATAL: recovery_pub requires recid argument");
556556
}
557557
}
558-
sig_opts.recid = &r;
559558

560559
sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
561560
hash_ptr = (unsigned char *)SvPVbyte(hash, hash_len);

0 commit comments

Comments
 (0)