summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorKarel Miko <karel.miko@gmail.com>2016-07-02 00:30:01 +0200
committerKarel Miko <karel.miko@gmail.com>2016-07-02 00:30:01 +0200
commit39f9a6fcca5b5393d7d3653c2526a119db8bd9a8 (patch)
tree23a90ece62bc7069b5c253878b0f24d6f4f644ae /inc
parentd5d40a18657fc6026419a5e2a9d96ec917e5ba4a (diff)
key2hash: add leading zero to avoid odd number of hexadecimal numbers
Diffstat (limited to 'inc')
-rw-r--r--inc/CryptX_PK_DH.xs.inc12
-rw-r--r--inc/CryptX_PK_DSA.xs.inc10
-rw-r--r--inc/CryptX_PK_ECC.xs.inc6
-rw-r--r--inc/CryptX_PK_RSA.xs.inc16
4 files changed, 22 insertions, 22 deletions
diff --git a/inc/CryptX_PK_DH.xs.inc b/inc/CryptX_PK_DH.xs.inc
index 58001028..6e8517a7 100644
--- a/inc/CryptX_PK_DH.xs.inc
+++ b/inc/CryptX_PK_DH.xs.inc
@@ -126,7 +126,7 @@ key2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'x' too big number");
}
if (siz>0) {
- mp_tohex(self->key.x, buf);
+ mp_tohex_with_leading_zero(self->key.x, buf, 20000);
not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -138,7 +138,7 @@ key2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'y' too big number");
}
if (siz>0) {
- mp_tohex(self->key.y, buf);
+ mp_tohex_with_leading_zero(self->key.y, buf, 20000);
not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -150,7 +150,7 @@ key2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
- mp_tohex(self->key.prime, buf);
+ mp_tohex_with_leading_zero(self->key.prime, buf, 20000);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
@@ -163,7 +163,7 @@ key2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
- mp_tohex(self->key.base, buf);
+ mp_tohex_with_leading_zero(self->key.base, buf, 20000);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
@@ -194,7 +194,7 @@ params2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
- mp_tohex(self->key.prime, buf);
+ mp_tohex_with_leading_zero(self->key.prime, buf, 20000);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
@@ -207,7 +207,7 @@ params2hash(Crypt::PK::DH self)
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
- mp_tohex(self->key.base, buf);
+ mp_tohex_with_leading_zero(self->key.base, buf, 20000);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else {
diff --git a/inc/CryptX_PK_DSA.xs.inc b/inc/CryptX_PK_DSA.xs.inc
index 69e95271..d729d18d 100644
--- a/inc/CryptX_PK_DSA.xs.inc
+++ b/inc/CryptX_PK_DSA.xs.inc
@@ -96,7 +96,7 @@ key2hash(Crypt::PK::DSA self)
croak("FATAL: key2hash failed - 'g' too big number");
}
if (siz>0) {
- mp_tohex(self->key.g, buf);
+ mp_tohex_with_leading_zero(self->key.g, buf, 20000);
not_used = hv_store(rv_hash, "g", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -108,7 +108,7 @@ key2hash(Crypt::PK::DSA self)
croak("FATAL: key2hash failed - 'q' too big number");
}
if (siz>0) {
- mp_tohex(self->key.q, buf);
+ mp_tohex_with_leading_zero(self->key.q, buf, 20000);
not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -120,7 +120,7 @@ key2hash(Crypt::PK::DSA self)
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
- mp_tohex(self->key.p, buf);
+ mp_tohex_with_leading_zero(self->key.p, buf, 20000);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -132,7 +132,7 @@ key2hash(Crypt::PK::DSA self)
croak("FATAL: key2hash failed - 'x' too big number");
}
if (siz>0) {
- mp_tohex(self->key.x, buf);
+ mp_tohex_with_leading_zero(self->key.x, buf, 20000);
not_used = hv_store(rv_hash, "x", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -144,7 +144,7 @@ key2hash(Crypt::PK::DSA self)
croak("FATAL: key2hash failed - 'y' too big number");
}
if (siz>0) {
- mp_tohex(self->key.y, buf);
+ mp_tohex_with_leading_zero(self->key.y, buf, 20000);
not_used = hv_store(rv_hash, "y", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
diff --git a/inc/CryptX_PK_ECC.xs.inc b/inc/CryptX_PK_ECC.xs.inc
index d057b348..4d5a7b84 100644
--- a/inc/CryptX_PK_ECC.xs.inc
+++ b/inc/CryptX_PK_ECC.xs.inc
@@ -113,7 +113,7 @@ key2hash(Crypt::PK::ECC self)
croak("FATAL: key2hash failed - 'k' too big number");
}
if (siz>0) {
- mp_tohex(self->key.k, buf);
+ mp_tohex_with_leading_zero(self->key.k, buf, 20000);
not_used = hv_store(rv_hash, "k", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -125,7 +125,7 @@ key2hash(Crypt::PK::ECC self)
croak("FATAL: key2hash failed - 'pub_x' too big number");
}
if (siz>0) {
- mp_tohex(self->key.pubkey.x, buf);
+ mp_tohex_with_leading_zero(self->key.pubkey.x, buf, 20000);
not_used = hv_store(rv_hash, "pub_x", 5, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -137,7 +137,7 @@ key2hash(Crypt::PK::ECC self)
croak("FATAL: key2hash failed - 'pub_y' too big number");
}
if (siz>0) {
- mp_tohex(self->key.pubkey.y, buf);
+ mp_tohex_with_leading_zero(self->key.pubkey.y, buf, 20000);
not_used = hv_store(rv_hash, "pub_y", 5, newSVpv(buf, strlen(buf)), 0);
}
else{
diff --git a/inc/CryptX_PK_RSA.xs.inc b/inc/CryptX_PK_RSA.xs.inc
index dac60d89..e6e81382 100644
--- a/inc/CryptX_PK_RSA.xs.inc
+++ b/inc/CryptX_PK_RSA.xs.inc
@@ -104,7 +104,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'e' too big number");
}
if (siz>0) {
- mp_tohex(self->key.e, buf);
+ mp_tohex_with_leading_zero(self->key.e, buf, 20000);
not_used = hv_store(rv_hash, "e", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -116,7 +116,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'd' too big number");
}
if (siz>0) {
- mp_tohex(self->key.d, buf);
+ mp_tohex_with_leading_zero(self->key.d, buf, 20000);
not_used = hv_store(rv_hash, "d", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -128,7 +128,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'N' too big number");
}
if (siz>0) {
- mp_tohex(self->key.N, buf);
+ mp_tohex_with_leading_zero(self->key.N, buf, 20000);
not_used = hv_store(rv_hash, "N", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -140,7 +140,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'q' too big number");
}
if (siz>0) {
- mp_tohex(self->key.q, buf);
+ mp_tohex_with_leading_zero(self->key.q, buf, 20000);
not_used = hv_store(rv_hash, "q", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -152,7 +152,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'p' too big number");
}
if (siz>0) {
- mp_tohex(self->key.p, buf);
+ mp_tohex_with_leading_zero(self->key.p, buf, 20000);
not_used = hv_store(rv_hash, "p", 1, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -164,7 +164,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'qP' too big number");
}
if (siz>0) {
- mp_tohex(self->key.qP, buf);
+ mp_tohex_with_leading_zero(self->key.qP, buf, 20000);
not_used = hv_store(rv_hash, "qP", 2, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -176,7 +176,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'dP' too big number");
}
if (siz>0) {
- mp_tohex(self->key.dP, buf);
+ mp_tohex_with_leading_zero(self->key.dP, buf, 20000);
not_used = hv_store(rv_hash, "dP", 2, newSVpv(buf, strlen(buf)), 0);
}
else{
@@ -188,7 +188,7 @@ key2hash(Crypt::PK::RSA self)
croak("FATAL: key2hash failed - 'dQ' too big number");
}
if (siz>0) {
- mp_tohex(self->key.dQ, buf);
+ mp_tohex_with_leading_zero(self->key.dQ, buf, 20000);
not_used = hv_store(rv_hash, "dQ", 2, newSVpv(buf, strlen(buf)), 0);
}
else{