aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/crypto.php')
-rw-r--r--include/crypto.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/include/crypto.php b/include/crypto.php
index 494a2a5b9..3cddc7581 100644
--- a/include/crypto.php
+++ b/include/crypto.php
@@ -20,7 +20,23 @@ function rsa_verify($data,$sig,$key,$alg = 'sha256') {
if(intval(OPENSSL_ALGO_SHA256) && $alg === 'sha256')
$alg = OPENSSL_ALGO_SHA256;
- $verify = openssl_verify($data,$sig,$key,$alg);
+ $verify = @openssl_verify($data,$sig,$key,$alg);
+
+ if(! $verify) {
+ while($msg = openssl_error_string())
+ logger('openssl_verify: ' . $msg,LOGGER_NORMAL,LOG_ERR);
+ logger('openssl_verify: key: ' . $key, LOGGER_DEBUG, LOG_ERR);
+ // provide a backtrace so that we can debug key issues
+ if(version_compare(PHP_VERSION, '5.4.0') >= 0) {
+ $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
+ if($stack) {
+ foreach($stack as $s) {
+ logger('stack: ' . basename($s['file']) . ':' . $s['line'] . ':' . $s['function'] . '()',LOGGER_DEBUG,LOG_ERR);
+ }
+ }
+ }
+ }
+
return $verify;
}
@@ -241,6 +257,7 @@ function pkcs1_encode($Modulus,$PublicExponent) {
}
+// http://stackoverflow.com/questions/27568570/how-to-convert-raw-modulus-exponent-to-rsa-public-key-pem-format
function metopem($m,$e) {
$der = pkcs8_encode($m,$e);
$key = DerToPem($der,false);