https://issues.apache.org/jira/browse/SANTUARIO-384

git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-cpp/trunk@1655515 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp b/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp
index 1ad2637..6030dbf 100644
--- a/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp
+++ b/xsec/enc/OpenSSL/OpenSSLCryptoKeyDSA.cpp
@@ -277,7 +277,7 @@
 
 	// Now turn the signature into a base64 string
 
-	unsigned char* rawSigBuf = new unsigned char[(BN_num_bits(dsa_sig->r) + BN_num_bits(dsa_sig->s)) / 8];
+	unsigned char* rawSigBuf = new unsigned char[(BN_num_bits(dsa_sig->r) + BN_num_bits(dsa_sig->s) + 7) / 8];
     ArrayJanitor<unsigned char> j_sigbuf(rawSigBuf);
 	
     unsigned int rawLen = BN_bn2bin(dsa_sig->r, rawSigBuf);
diff --git a/xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.cpp b/xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.cpp
index ce93255..6d34e59 100644
--- a/xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.cpp
+++ b/xsec/enc/OpenSSL/OpenSSLCryptoKeyEC.cpp
@@ -238,7 +238,7 @@
 	}
 
 	// Now turn the signature into a base64 string
-	unsigned char* rawSigBuf = new unsigned char[(BN_num_bits(dsa_sig->r) + BN_num_bits(dsa_sig->s)) / 8];
+	unsigned char* rawSigBuf = new unsigned char[(BN_num_bits(dsa_sig->r) + BN_num_bits(dsa_sig->s) + 7) / 8];
     ArrayJanitor<unsigned char> j_sigbuf(rawSigBuf);
 
 	unsigned int rawLen = BN_bn2bin(dsa_sig->r, rawSigBuf);