diff --git a/CryptX.xs b/CryptX.xs index 5d76d98..98a4cae 100644 --- a/CryptX.xs +++ b/CryptX.xs @@ -241,7 +241,7 @@ void _ecc_oid_lookup(ecc_key *key) { int err; - unsigned i; + unsigned i, j; void *tmp; const ltc_ecc_curve *cu; @@ -264,9 +264,20 @@ break; /* found */ } ltc_mp.deinit(tmp); - if (cu->prime != NULL) { - key->dp.oidlen = cu->oidlen; - for(i = 0; i < cu->oidlen; i++) key->dp.oid[i] = cu->oid[i]; + if (cu->prime && cu->OID) { + for (i = 0; i < 16; i++) key->dp.oid[i] = 0; + for (i = 0, j = 0; i < strlen(cu->OID); i++) { + if (cu->OID[i] == '.') { + if (++j >= 16) return; + } + else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { + key->dp.oid[j] = key->dp.oid[j] * 10 + (cu->OID[i] - '0'); + } + else { + return; + } + } + key->dp.oidlen = j + 1; } } @@ -276,23 +287,23 @@ HV *hc, *hl, *h; SV *sv_crv, **pref; SV **sv_cofactor, **sv_prime, **sv_A, **sv_B, **sv_order, **sv_Gx, **sv_Gy, **sv_oid; - char *ch_name; - STRLEN l_name, i, j; + char *ptr_crv; + STRLEN len_crv; int err; if (!SvOK(curve)) croak("FATAL: undefined curve"); if (SvPOK(curve)) { /* string */ - ch_name = SvPV(curve, l_name); + ptr_crv = SvPV(curve, len_crv); if ((hl = get_hv("Crypt::PK::ECC::curve2ltc", 0)) == NULL) croak("FATAL: no curve2ltc register"); - pref = hv_fetch(hl, ch_name, (U32)l_name, 0); + pref = hv_fetch(hl, ptr_crv, (U32)len_crv, 0); if (pref && SvOK(*pref)) { sv_crv = *pref; /* found in %cutve2ltc */ } else { if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register"); - pref = hv_fetch(hc, ch_name, (U32)l_name, 0); + pref = hv_fetch(hc, ptr_crv, (U32)len_crv, 0); if (pref && SvOK(*pref)) { sv_crv = *pref; /* found in %curve */ } @@ -312,8 +323,8 @@ if (SvPOK(sv_crv)) { /* string - curve name */ const ltc_ecc_curve *cu; - ch_name = SvPV(sv_crv, l_name); - if (ecc_get_curve_by_name(ch_name, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ch_name); + ptr_crv = SvPV(sv_crv, len_crv); + if (ecc_get_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv); return ecc_set_dp(cu, key); } else { @@ -338,32 +349,16 @@ if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); + sv_oid = hv_fetchs(h, "oid", 0); /* 'oid' is optional */ + cu.OID = (sv_oid && SvOK(*sv_oid)) ? SvPV_nolen(*sv_oid) : NULL; + cu.prime = SvPV_nolen(*sv_prime); cu.A = SvPV_nolen(*sv_A); cu.B = SvPV_nolen(*sv_B); cu.order = SvPV_nolen(*sv_order); cu.Gx = SvPV_nolen(*sv_Gx); cu.Gy = SvPV_nolen(*sv_Gy); - cu.cofactor = (unsigned long)SvUV(*sv_cofactor), - cu.oidlen = 0; - - sv_oid = hv_fetchs(h, "oid", 0); - if (sv_oid && SvPOK(*sv_oid)) { - ch_name = SvPV(*sv_oid, l_name); - for (i = 0, j = 0; i < l_name; i++) { - if (ch_name[i] == '.') { - if (++j >= 16) return CRYPT_ERROR; - } - else if(ch_name[i] >= '0' && ch_name[i] <= '9') { - cu.oid[j] = cu.oid[j] * 10 + (ch_name[i] - '0'); - } - else { - return CRYPT_ERROR; - } - } - if (j == 0) return CRYPT_ERROR; - cu.oidlen = j + 1; - } + cu.cofactor = (unsigned long)SvUV(*sv_cofactor); if ((err = ecc_set_dp(&cu, key)) != CRYPT_OK) return err; if (key->dp.oidlen == 0) _ecc_oid_lookup(key); @@ -493,7 +488,8 @@ int rv; STRLEN in_len; unsigned long out_len; - unsigned char *out_data, *in_data; + unsigned char *in_data; + char *out_data; if (!SvPOK(in)) XSRETURN_UNDEF; in_data = (unsigned char *) SvPVbyte(in, in_len); @@ -504,7 +500,7 @@ out_len = (unsigned long)(4 * ((in_len + 2) / 3) + 1); RETVAL = NEWSV(0, out_len); /* avoid zero! */ SvPOK_only(RETVAL); - out_data = (unsigned char *)SvPVX(RETVAL); + out_data = SvPVX(RETVAL); if (ix == 1) rv = base64url_encode(in_data, (unsigned long)in_len, out_data, &out_len); else @@ -528,10 +524,11 @@ int rv; STRLEN in_len; unsigned long out_len; - unsigned char *out_data, *in_data; + unsigned char *out_data; + char *in_data; if (!SvPOK(in)) XSRETURN_UNDEF; - in_data = (unsigned char *)SvPVbyte(in, in_len); + in_data = SvPVbyte(in, in_len); if (in_len == 0) { RETVAL = newSVpvn("", 0); } diff --git a/Makefile.PL b/Makefile.PL index 11f9956..891df7e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -50,8 +50,13 @@ my ($maj, $min) = $arver =~ /^GNU ar [^\d]*(\d)\.(\d+)\.\d+/s; $myarflags = 'rcD' if ($maj && $min && $maj >= 2 && $min >= 20) || $arver=~ /^BSD ar /; } + + # turn on extra warnings in AUTHOR_MODE (it is gcc only!!) + $mycflags = "$mycflags -Wall -Werror -Wextra" if $ENV{AUTHOR_MODE}; + @EUMM_INC_LIB = ( - INC => '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm', + INC => $ENV{AUTHOR_MODE} ? '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm -Wall -Werror -Wextra' #gcc only!! + : '-DLTM_DESC -Isrc/ltc/headers -Isrc/ltm', MYEXTLIB => "src/liballinone$Config{lib_ext}", clean => { 'FILES' => join(' ', @myobjs, "src/liballinone$Config{lib_ext}") }, ); diff --git a/_generators/Mac.xs.inc.tt b/_generators/Mac.xs.inc.tt index 781cf2f..ebcbbe5 100644 --- a/_generators/Mac.xs.inc.tt +++ b/_generators/Mac.xs.inc.tt @@ -128,17 +128,17 @@ [%-END%] outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -248,19 +248,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Checksum_Adler32.xs.inc b/inc/CryptX_Checksum_Adler32.xs.inc index 6b2292a..7966f56 100644 --- a/inc/CryptX_Checksum_Adler32.xs.inc +++ b/inc/CryptX_Checksum_Adler32.xs.inc @@ -59,7 +59,8 @@ CODE: { int rv; - unsigned char hash[4], out[9]; + unsigned char hash[4]; + char out[9]; unsigned long outlen = 9; unsigned int ui32; @@ -67,7 +68,7 @@ if (ix == 1) { rv = base16_encode(hash, 4, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *)out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { LOAD32H(ui32, hash); @@ -89,7 +90,8 @@ { adler32_state st; int rv, j; - unsigned char hash[4], out[9], *in; + unsigned char hash[4], *in; + char out[9]; unsigned long outlen = 9; unsigned int ui32; STRLEN inlen; @@ -105,7 +107,7 @@ if (ix == 1) { rv = base16_encode(hash, 4, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *)out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { LOAD32H(ui32, hash); diff --git a/inc/CryptX_Checksum_CRC32.xs.inc b/inc/CryptX_Checksum_CRC32.xs.inc index 700db43..486bf64 100644 --- a/inc/CryptX_Checksum_CRC32.xs.inc +++ b/inc/CryptX_Checksum_CRC32.xs.inc @@ -59,7 +59,8 @@ CODE: { int rv; - unsigned char hash[4], out[9]; + unsigned char hash[4]; + char out[9]; unsigned long outlen = 9; unsigned int ui32; @@ -67,7 +68,7 @@ if (ix == 1) { rv = base16_encode(hash, 4, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *)out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { LOAD32H(ui32, hash); @@ -89,7 +90,8 @@ { crc32_state st; int rv, j; - unsigned char hash[4], out[9], *in; + unsigned char hash[4], *in; + char out[9]; unsigned long outlen = 9; unsigned int ui32; STRLEN inlen; @@ -105,7 +107,7 @@ if (ix == 1) { rv = base16_encode(hash, 4, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *)out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { LOAD32H(ui32, hash); diff --git a/inc/CryptX_Digest.xs.inc b/inc/CryptX_Digest.xs.inc index bbf337a..96a3dbb 100644 --- a/inc/CryptX_Digest.xs.inc +++ b/inc/CryptX_Digest.xs.inc @@ -86,17 +86,17 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen); + rv = base64url_encode(hash, self->desc->hashsize, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { - rv = base64_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen); + rv = base64_encode(hash, self->desc->hashsize, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(hash, self->desc->hashsize, (unsigned char *)out, &outlen, 0); + rv = base16_encode(hash, self->desc->hashsize, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -141,19 +141,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(hash, len, (unsigned char *)out, &outlen); + rv = base64url_encode(hash, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 2) { - rv = base64_encode(hash, len, (unsigned char *)out, &outlen); + rv = base64_encode(hash, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(hash, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(hash, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) hash, len); diff --git a/inc/CryptX_Mac_BLAKE2b.xs.inc b/inc/CryptX_Mac_BLAKE2b.xs.inc index 8c00ed4..a8f5113 100644 --- a/inc/CryptX_Mac_BLAKE2b.xs.inc +++ b/inc/CryptX_Mac_BLAKE2b.xs.inc @@ -77,17 +77,17 @@ if (rv != CRYPT_OK) croak("FATAL: blake2bmac_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -130,19 +130,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_BLAKE2s.xs.inc b/inc/CryptX_Mac_BLAKE2s.xs.inc index f9fd0a1..d1b4292 100644 --- a/inc/CryptX_Mac_BLAKE2s.xs.inc +++ b/inc/CryptX_Mac_BLAKE2s.xs.inc @@ -77,17 +77,17 @@ if (rv != CRYPT_OK) croak("FATAL: blake2smac_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -130,19 +130,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_F9.xs.inc b/inc/CryptX_Mac_F9.xs.inc index b21099e..f3ce96f 100644 --- a/inc/CryptX_Mac_F9.xs.inc +++ b/inc/CryptX_Mac_F9.xs.inc @@ -81,17 +81,17 @@ if (rv != CRYPT_OK) croak("FATAL: f9_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -135,19 +135,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_HMAC.xs.inc b/inc/CryptX_Mac_HMAC.xs.inc index da87bc1..44aa085 100644 --- a/inc/CryptX_Mac_HMAC.xs.inc +++ b/inc/CryptX_Mac_HMAC.xs.inc @@ -81,17 +81,17 @@ if (rv != CRYPT_OK) croak("FATAL: hmac_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -135,19 +135,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_OMAC.xs.inc b/inc/CryptX_Mac_OMAC.xs.inc index 0510825..ed2ee8e 100644 --- a/inc/CryptX_Mac_OMAC.xs.inc +++ b/inc/CryptX_Mac_OMAC.xs.inc @@ -81,17 +81,17 @@ if (rv != CRYPT_OK) croak("FATAL: omac_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -135,19 +135,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_PMAC.xs.inc b/inc/CryptX_Mac_PMAC.xs.inc index f8eb832..45cfe66 100644 --- a/inc/CryptX_Mac_PMAC.xs.inc +++ b/inc/CryptX_Mac_PMAC.xs.inc @@ -81,17 +81,17 @@ if (rv != CRYPT_OK) croak("FATAL: pmac_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -135,19 +135,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_Pelican.xs.inc b/inc/CryptX_Mac_Pelican.xs.inc index ea2e22a..b3e9f15 100644 --- a/inc/CryptX_Mac_Pelican.xs.inc +++ b/inc/CryptX_Mac_Pelican.xs.inc @@ -77,17 +77,17 @@ if (rv != CRYPT_OK) croak("FATAL: pelican_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -130,19 +130,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_Poly1305.xs.inc b/inc/CryptX_Mac_Poly1305.xs.inc index c42d3a9..f816e48 100644 --- a/inc/CryptX_Mac_Poly1305.xs.inc +++ b/inc/CryptX_Mac_Poly1305.xs.inc @@ -77,17 +77,17 @@ if (rv != CRYPT_OK) croak("FATAL: poly1305_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -129,19 +129,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_Mac_XCBC.xs.inc b/inc/CryptX_Mac_XCBC.xs.inc index 809f583..a5a0205 100644 --- a/inc/CryptX_Mac_XCBC.xs.inc +++ b/inc/CryptX_Mac_XCBC.xs.inc @@ -81,17 +81,17 @@ if (rv != CRYPT_OK) croak("FATAL: xcbc_done failed: %s", error_to_string(rv)); outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64url_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 2) { - rv = base64_encode(mac, maclen, (unsigned char*)out, &outlen); + rv = base64_encode(mac, maclen, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } if (ix == 1) { - rv = base16_encode(mac, maclen, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, maclen, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn(out, outlen); } @@ -135,19 +135,19 @@ outlen = sizeof(out); if (ix == 3) { - rv = base64url_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64url_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64url_encode failed: %s", error_to_string(rv)); RETVAL = newSVpvn((char *) out, outlen); } else if (ix == 2) { - rv = base64_encode(mac, len, (unsigned char *)out, &outlen); + rv = base64_encode(mac, len, out, &outlen); if (rv != CRYPT_OK) croak("FATAL: base64_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else if (ix == 1) { - rv = base16_encode(mac, len, (unsigned char *)out, &outlen, 0); + rv = base16_encode(mac, len, out, &outlen, 0); if (rv != CRYPT_OK) croak("FATAL: base16_encode failed: %s", error_to_string(rv)); - RETVAL = newSVpvn((char *) out, outlen); + RETVAL = newSVpvn(out, outlen); } else { RETVAL = newSVpvn((char *) mac, len); diff --git a/inc/CryptX_PRNG.xs.inc b/inc/CryptX_PRNG.xs.inc index ddc19fa..62ee07c 100644 --- a/inc/CryptX_PRNG.xs.inc +++ b/inc/CryptX_PRNG.xs.inc @@ -105,7 +105,8 @@ IV curpid = (IV)PerlProc_getpid(); int rv_len, rv; unsigned long len; - unsigned char *rdata, *tmp; + unsigned char *tmp; + char *rdata; unsigned char entropy_buf[40]; if (output_len == 0) { @@ -127,7 +128,7 @@ RETVAL = NEWSV(0, output_len * 2 + 1); /* avoid zero! */ SvPOK_only(RETVAL); SvCUR_set(RETVAL, output_len * 2 + 1); - rdata = (unsigned char *)SvPVX(RETVAL); + rdata = SvPVX(RETVAL); len = output_len * 2 + 1; rv = base16_encode(tmp, output_len, rdata, &len, 0); SvCUR_set(RETVAL, len); @@ -146,7 +147,7 @@ RETVAL = NEWSV(0, output_len * 2); /* avoid zero! */ SvPOK_only(RETVAL); SvCUR_set(RETVAL, output_len * 2); - rdata = (unsigned char *)SvPVX(RETVAL); + rdata = SvPVX(RETVAL); len = output_len * 2; rv = ix == 3 ? base64url_encode(tmp, output_len, rdata, &len) : base64_encode(tmp, output_len, rdata, &len); @@ -162,8 +163,8 @@ RETVAL = NEWSV(0, output_len); /* avoid zero! */ SvPOK_only(RETVAL); SvCUR_set(RETVAL, output_len); - rdata = (unsigned char *)SvPVX(RETVAL); - rv_len = (self->desc->read)(rdata, (unsigned long)output_len, &self->state); + rdata = SvPVX(RETVAL); + rv_len = (self->desc->read)((unsigned char*)rdata, (unsigned long)output_len, &self->state); if ((UV)rv_len != output_len) { SvREFCNT_dec(RETVAL); croak("FATAL: PRNG_read failed"); diff --git a/t/002_all_pm.t b/t/002_all_pm.t index 3daceed..d1ea17f 100644 --- a/t/002_all_pm.t +++ b/t/002_all_pm.t @@ -3,7 +3,7 @@ use Test::More; -plan skip_all => "set TEST_POD to enable this test (developer only!)" unless $ENV{TEST_POD}; +plan skip_all => "set AUTHOR_MODE to enable this test (developer only!)" unless $ENV{AUTHOR_MODE}; plan skip_all => "File::Find not installed" unless eval { require File::Find }; plan tests => 1; diff --git a/t/003_all_pm_pod.t b/t/003_all_pm_pod.t index 47c3ccc..85771b5 100644 --- a/t/003_all_pm_pod.t +++ b/t/003_all_pm_pod.t @@ -3,7 +3,7 @@ use Test::More; -plan skip_all => "set TEST_POD to enable this test (developer only!)" unless $ENV{TEST_POD}; +plan skip_all => "set AUTHOR_MODE to enable this test (developer only!)" unless $ENV{AUTHOR_MODE}; plan skip_all => "File::Find not installed" unless eval { require File::Find }; plan skip_all => "Test::Pod not installed" unless eval { require Test::Pod }; plan tests => 107; diff --git a/t/004_all_pm_pod_spelling.t b/t/004_all_pm_pod_spelling.t index 5e6de67..b692782 100644 --- a/t/004_all_pm_pod_spelling.t +++ b/t/004_all_pm_pod_spelling.t @@ -3,7 +3,7 @@ use Test::More; -plan skip_all => "set TEST_POD to enable this test (developer only!)" unless $ENV{TEST_POD}; +plan skip_all => "set AUTHOR_MODE to enable this test (developer only!)" unless $ENV{AUTHOR_MODE}; plan skip_all => "File::Find not installed" unless eval { require File::Find }; plan skip_all => "Test::Pod::Spelling or Text::Aspell not installed" unless eval { require Test::Pod::Spelling; require Text::Aspell; }; diff --git a/t/005_all_pm_pod_coverage.t b/t/005_all_pm_pod_coverage.t index ce06bc4..f922b23 100644 --- a/t/005_all_pm_pod_coverage.t +++ b/t/005_all_pm_pod_coverage.t @@ -3,7 +3,7 @@ use Test::More; -plan skip_all => "set TEST_POD to enable this test (developer only!)" unless $ENV{TEST_POD}; +plan skip_all => "set AUTHOR_MODE to enable this test (developer only!)" unless $ENV{AUTHOR_MODE}; plan skip_all => "Pod::Coverage not installed" unless eval { require Pod::Coverage }; plan skip_all => "File::Find not installed" unless eval { require File::Find }; plan tests => 107;