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

OpenSSL   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 43
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A is_key() 0 5 2
A verify() 0 3 1
A __construct() 0 1 1
A get_pub_key() 0 6 1
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