@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\macs; |
16 | 16 |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | * @return string |
36 | 36 | * @throws InvalidKeyLengthAlgorithmException |
37 | 37 | */ |
38 | - public function digest(SharedKey $key, $message){ |
|
38 | + public function digest(SharedKey $key, $message) { |
|
39 | 39 | |
40 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
41 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
40 | + if ($this->getMinKeyLen() > $key->getBitLength()) |
|
41 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.', $this->getMinKeyLen(), $key->getBitLength())); |
|
42 | 42 | |
43 | 43 | return hash_hmac($this->getHashingAlgorithm(), $message, $key->getSecret(), true); |
44 | 44 | } |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @throws InvalidKeyLengthAlgorithmException |
52 | 52 | * @throws InvalidKeyTypeAlgorithmException |
53 | 53 | */ |
54 | - public function verify(Key $key, $message, $digest){ |
|
55 | - if(!($key instanceof SharedKey)) throw new InvalidKeyTypeAlgorithmException; |
|
54 | + public function verify(Key $key, $message, $digest) { |
|
55 | + if (!($key instanceof SharedKey)) throw new InvalidKeyTypeAlgorithmException; |
|
56 | 56 | |
57 | 57 | return $digest === $this->digest($key, $message); |
58 | 58 | } |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function digest(SharedKey $key, $message){ |
39 | 39 | |
40 | - if($this->getMinKeyLen() > $key->getBitLength()) |
|
41 | - throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
40 | + if($this->getMinKeyLen() > $key->getBitLength()) { |
|
41 | + throw new InvalidKeyLengthAlgorithmException(sprintf('min len %s - cur len %s.',$this->getMinKeyLen(), $key->getBitLength())); |
|
42 | + } |
|
42 | 43 | |
43 | 44 | return hash_hmac($this->getHashingAlgorithm(), $message, $key->getSecret(), true); |
44 | 45 | } |
@@ -52,7 +53,9 @@ discard block |
||
52 | 53 | * @throws InvalidKeyTypeAlgorithmException |
53 | 54 | */ |
54 | 55 | public function verify(Key $key, $message, $digest){ |
55 | - if(!($key instanceof SharedKey)) throw new InvalidKeyTypeAlgorithmException; |
|
56 | + if(!($key instanceof SharedKey)) { |
|
57 | + throw new InvalidKeyTypeAlgorithmException; |
|
58 | + } |
|
56 | 59 | |
57 | 60 | return $digest === $this->digest($key, $message); |
58 | 61 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\macs\sha2; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\macs\sha2; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\macs\sha2; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\exceptions; |
16 | 16 |
@@ -68,7 +68,9 @@ |
||
68 | 68 | * @return null|ContentEncryptionAlgorithm |
69 | 69 | */ |
70 | 70 | public function get($alg) { |
71 | - if (!$this->isSupported($alg)) return null; |
|
71 | + if (!$this->isSupported($alg)) { |
|
72 | + return null; |
|
73 | + } |
|
72 | 74 | return $this->algorithms[$alg]; |
73 | 75 | } |
74 | 76 | } |
75 | 77 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms; |
16 | 16 | use jwk\JSONWebKeyTypes; |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\digital_signatures; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Copyright 2015 OpenStack Foundation |
|
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | - * you may not use this file except in compliance with the License. |
|
6 | - * You may obtain a copy of the License at |
|
7 | - * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | - * Unless required by applicable law or agreed to in writing, software |
|
9 | - * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | - * See the License for the specific language governing permissions and |
|
12 | - * limitations under the License. |
|
13 | - **/ |
|
3 | + * Copyright 2015 OpenStack Foundation |
|
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | + * you may not use this file except in compliance with the License. |
|
6 | + * You may obtain a copy of the License at |
|
7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | + * Unless required by applicable law or agreed to in writing, software |
|
9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
|
10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
11 | + * See the License for the specific language governing permissions and |
|
12 | + * limitations under the License. |
|
13 | + **/ |
|
14 | 14 | |
15 | 15 | namespace jwa\cryptographic_algorithms\digital_signatures\rsa\PKCS1; |
16 | 16 | use jwa\cryptographic_algorithms\digital_signatures\rsa\RSA_Algorithm; |