Completed
Push — master ( 361424...8a38a3 )
by Dmitry
04:34
created

OpenSSL::verify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 3
dl 0
loc 3
rs 10
1
<?php
2
3
namespace EasyPay;
4
5
class OpenSSL
6
{
7
    public function __construct() {}
8
9
    /**
10
     *      verify signature of xml
11
     *
12
     *      @param string $xml
13
     *      @param string $bin_sign
14
     *      @param resource $pub_key
15
     *
16
     *      @return integer result of checking
17
     */
18
    public function verify($xml, $bin_sign, $pub_key)
19
    {
20
        return @openssl_verify($xml, $bin_sign, $pub_key);
21
    }
22
23
    /**
24
     *      get public key
25
     *
26
     *      @param mixed $certificate
27
     *      @return resource
28
     */
29
    public function get_pub_key($certificate)
30
    {
31
        $pub_key = @openssl_pkey_get_public($certificate);
32
        $this->is_key($pub_key);
33
34
        return $pub_key;
35
    }
36
37
    /**
38
     *      check key
39
     *
40
     *      @param resource $key
41
     *      @throws Exception\Runtime
42
     */
43
    public function is_key($key)
44
    {
45
        if ($key === FALSE)
46
        {
47
            throw new Exception\Runtime('Can not extract key from certificate!', -97);
48
        }
49
    }
50
51
}
52