summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Miko <karel.miko@gmail.com>2018-04-08 14:08:07 +0200
committerKarel Miko <karel.miko@gmail.com>2018-04-08 14:08:07 +0200
commitb0e17181f74c35e561af261b901c4e88ebe6d38d (patch)
treeeafe3d67f43d145cfdbccd57d92b7fe1aafb9d49
parenta428ba77bbe08f94a0a153ebb9df97862782b241 (diff)
adopt to updated ltc
-rw-r--r--CryptX.xs67
-rw-r--r--Makefile.PL7
-rw-r--r--_generators/Mac.xs.inc.tt16
-rw-r--r--inc/CryptX_Checksum_Adler32.xs.inc10
-rw-r--r--inc/CryptX_Checksum_CRC32.xs.inc10
-rw-r--r--inc/CryptX_Digest.xs.inc18
-rw-r--r--inc/CryptX_Mac_BLAKE2b.xs.inc16
-rw-r--r--inc/CryptX_Mac_BLAKE2s.xs.inc16
-rw-r--r--inc/CryptX_Mac_F9.xs.inc16
-rw-r--r--inc/CryptX_Mac_HMAC.xs.inc16
-rw-r--r--inc/CryptX_Mac_OMAC.xs.inc16
-rw-r--r--inc/CryptX_Mac_PMAC.xs.inc16
-rw-r--r--inc/CryptX_Mac_Pelican.xs.inc16
-rw-r--r--inc/CryptX_Mac_Poly1305.xs.inc16
-rw-r--r--inc/CryptX_Mac_XCBC.xs.inc16
-rw-r--r--inc/CryptX_PRNG.xs.inc11
-rw-r--r--t/002_all_pm.t2
-rw-r--r--t/003_all_pm_pod.t2
-rw-r--r--t/004_all_pm_pod_spelling.t2
-rw-r--r--t/005_all_pm_pod_coverage.t2
20 files changed, 149 insertions, 142 deletions
diff --git a/CryptX.xs b/CryptX.xs
index 5d76d982..98a4cae5 100644
--- a/CryptX.xs
+++ b/CryptX.xs
@@ -241,7 +241,7 @@ STATIC SV * sv_from_mpi(mp_int *mpi) {
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 @@ void _ecc_oid_lookup(ecc_key *key)
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 @@ int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
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 @@ int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
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 @@ int _ecc_set_dp_from_SV(ecc_key *key, SV *curve)
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 @@ encode_b64(SV * in)
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 @@ encode_b64(SV * in)
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 @@ decode_b64(SV * in)
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 11f9956a..891df7ec 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -50,8 +50,13 @@ else {
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 781cf2f9..ebcbbe5c 100644
--- a/_generators/Mac.xs.inc.tt
+++ b/_generators/Mac.xs.inc.tt
@@ -128,17 +128,17 @@ mac(Crypt::Mac::[%orig_name%] self)
[%-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 @@ SV *
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 6b2292ae..7966f569 100644
--- a/inc/CryptX_Checksum_Adler32.xs.inc
+++ b/inc/CryptX_Checksum_Adler32.xs.inc
@@ -59,7 +59,8 @@ digest(Crypt::Checksum::Adler32 self)
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 @@ digest(Crypt::Checksum::Adler32 self)
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_data(...)
{
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 @@ adler32_data(...)
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 700db43d..486bf641 100644
--- a/inc/CryptX_Checksum_CRC32.xs.inc
+++ b/inc/CryptX_Checksum_CRC32.xs.inc
@@ -59,7 +59,8 @@ digest(Crypt::Checksum::CRC32 self)
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 @@ digest(Crypt::Checksum::CRC32 self)
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_data(...)
{
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 @@ crc32_data(...)
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 bbf337aa..96a3dbb1 100644
--- a/inc/CryptX_Digest.xs.inc
+++ b/inc/CryptX_Digest.xs.inc
@@ -86,17 +86,17 @@ digest(Crypt::Digest self)
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 @@ digest_data(char * digest_name, ...)
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 8c00ed43..a8f51139 100644
--- a/inc/CryptX_Mac_BLAKE2b.xs.inc
+++ b/inc/CryptX_Mac_BLAKE2b.xs.inc
@@ -77,17 +77,17 @@ mac(Crypt::Mac::BLAKE2b self)
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 @@ blake2b(unsigned long size, SV * key, ...)
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 f9fd0a12..d1b4292b 100644
--- a/inc/CryptX_Mac_BLAKE2s.xs.inc
+++ b/inc/CryptX_Mac_BLAKE2s.xs.inc
@@ -77,17 +77,17 @@ mac(Crypt::Mac::BLAKE2s self)
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 @@ blake2s(unsigned long size, SV * key, ...)
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 b21099e9..f3ce96f6 100644
--- a/inc/CryptX_Mac_F9.xs.inc
+++ b/inc/CryptX_Mac_F9.xs.inc
@@ -81,17 +81,17 @@ mac(Crypt::Mac::F9 self)
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 @@ f9(char * cipher_name, SV * key, ...)
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 da87bc13..44aa085b 100644
--- a/inc/CryptX_Mac_HMAC.xs.inc
+++ b/inc/CryptX_Mac_HMAC.xs.inc
@@ -81,17 +81,17 @@ mac(Crypt::Mac::HMAC self)
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 @@ hmac(char * hash_name, SV * key, ...)
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 05108255..ed2ee8e3 100644
--- a/inc/CryptX_Mac_OMAC.xs.inc
+++ b/inc/CryptX_Mac_OMAC.xs.inc
@@ -81,17 +81,17 @@ mac(Crypt::Mac::OMAC self)
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 @@ omac(char * cipher_name, SV * key, ...)
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 f8eb832d..45cfe666 100644
--- a/inc/CryptX_Mac_PMAC.xs.inc
+++ b/inc/CryptX_Mac_PMAC.xs.inc
@@ -81,17 +81,17 @@ mac(Crypt::Mac::PMAC self)
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 @@ pmac(char * cipher_name, SV * key, ...)
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 ea2e22a7..b3e9f158 100644
--- a/inc/CryptX_Mac_Pelican.xs.inc
+++ b/inc/CryptX_Mac_Pelican.xs.inc
@@ -77,17 +77,17 @@ mac(Crypt::Mac::Pelican self)
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 @@ pelican(SV * key, ...)
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 c42d3a91..f816e48f 100644
--- a/inc/CryptX_Mac_Poly1305.xs.inc
+++ b/inc/CryptX_Mac_Poly1305.xs.inc
@@ -77,17 +77,17 @@ mac(Crypt::Mac::Poly1305 self)
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 @@ poly1305(SV * key, ...)
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 809f583a..a5a02054 100644
--- a/inc/CryptX_Mac_XCBC.xs.inc
+++ b/inc/CryptX_Mac_XCBC.xs.inc
@@ -81,17 +81,17 @@ mac(Crypt::Mac::XCBC self)
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 @@ xcbc(char * cipher_name, SV * key, ...)
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 ddc19fae..62ee07c3 100644
--- a/inc/CryptX_PRNG.xs.inc
+++ b/inc/CryptX_PRNG.xs.inc
@@ -105,7 +105,8 @@ bytes(Crypt::PRNG self, unsigned long output_len)
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 @@ bytes(Crypt::PRNG self, unsigned long output_len)
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 @@ bytes(Crypt::PRNG self, unsigned long output_len)
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 @@ bytes(Crypt::PRNG self, unsigned long output_len)
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 3daceed3..d1ea17fb 100644
--- a/t/002_all_pm.t
+++ b/t/002_all_pm.t
@@ -3,7 +3,7 @@ use warnings;
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 47c3ccce..85771b57 100644
--- a/t/003_all_pm_pod.t
+++ b/t/003_all_pm_pod.t
@@ -3,7 +3,7 @@ use warnings;
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 5e6de670..b692782b 100644
--- a/t/004_all_pm_pod_spelling.t
+++ b/t/004_all_pm_pod_spelling.t
@@ -3,7 +3,7 @@ use warnings;
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 ce06bc4b..f922b231 100644
--- a/t/005_all_pm_pod_coverage.t
+++ b/t/005_all_pm_pod_coverage.t
@@ -3,7 +3,7 @@ use warnings;
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;