@@ -39,10 +39,13 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function sign(PrivateKey $private_key, $message) |
41 | 41 | { |
42 | - if(!($private_key instanceof RSAPrivateKey)) throw new InvalidKeyTypeAlgorithmException; |
|
42 | + if(!($private_key instanceof RSAPrivateKey)) { |
|
43 | + throw new InvalidKeyTypeAlgorithmException; |
|
44 | + } |
|
43 | 45 | |
44 | - if($this->getMinKeyLen() > $private_key->getBitLength()) |
|
45 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
46 | + if($this->getMinKeyLen() > $private_key->getBitLength()) { |
|
47 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $private_key->getBitLength())); |
|
48 | + } |
|
46 | 49 | |
47 | 50 | if($private_key->hasPassword()){ |
48 | 51 | $this->rsa_impl->setPassword($private_key->getPassword()); |
@@ -50,8 +53,9 @@ discard block |
||
50 | 53 | |
51 | 54 | $res = $this->rsa_impl->loadKey($private_key->getEncoded()); |
52 | 55 | |
53 | - if(!$res) |
|
54 | - throw new InvalidKeyTypeAlgorithmException; |
|
56 | + if(!$res) { |
|
57 | + throw new InvalidKeyTypeAlgorithmException; |
|
58 | + } |
|
55 | 59 | |
56 | 60 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
57 | 61 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |
@@ -69,14 +73,19 @@ discard block |
||
69 | 73 | */ |
70 | 74 | public function verify(Key $key, $message, $signature) |
71 | 75 | { |
72 | - if(!($key instanceof RSAPublicKey)) throw new InvalidKeyTypeAlgorithmException; |
|
76 | + if(!($key instanceof RSAPublicKey)) { |
|
77 | + throw new InvalidKeyTypeAlgorithmException; |
|
78 | + } |
|
73 | 79 | |
74 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
75 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
80 | + if($this->getMinKeyLen() > $key->getBitLength()) { |
|
81 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
82 | + } |
|
76 | 83 | |
77 | 84 | $res = $this->rsa_impl->loadKey($key->getEncoded()); |
78 | 85 | |
79 | - if(!$res) throw new InvalidKeyTypeAlgorithmException; |
|
86 | + if(!$res) { |
|
87 | + throw new InvalidKeyTypeAlgorithmException; |
|
88 | + } |
|
80 | 89 | |
81 | 90 | $this->rsa_impl->setHash($this->getHashingAlgorithm()); |
82 | 91 | $this->rsa_impl->setMGFHash($this->getHashingAlgorithm()); |
@@ -71,7 +71,9 @@ |
||
71 | 71 | |
72 | 72 | $res = $this->rsa_imp->loadKey($this->pem_format, RSA::PRIVATE_FORMAT_PKCS1); |
73 | 73 | |
74 | - if(!$res) throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
74 | + if(!$res) { |
|
75 | + throw new RSABadPEMFormat(sprintf('pem %s',$pem_format )); |
|
76 | + } |
|
75 | 77 | |
76 | 78 | $this->n = $this->rsa_imp->modulus; |
77 | 79 | } |