Completed
Push — master ( 16bc05...356550 )
by sebastian
03:03
created

src/security/SymmetricSharedKey.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
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
 **/
14
15
namespace security;
16
17
use jwk\JSONWebKeyTypes;
18
use utils\ByteUtil;
19
20
/**
21
 * Class SymmetricSharedKey
22
 * @package security
23
 */
24
final class SymmetricSharedKey
25
    implements PrivateKey, SharedKey {
0 ignored issues
show
The implements keyword must be on the same line as the class name
Loading history...
26
27
    /**
28
     * @param string $secret
29
     */
30
    public function __construct($secret){
31
        $this->secret = $secret;
32
    }
33
34
    private $secret = null;
35
36
    /**
37
     * @return string
38
     */
39
    public function getAlgorithm()
40
    {
41
        return JSONWebKeyTypes::OctetSequence;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getEncoded()
48
    {
49
       return $this->getSecret();
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getFormat()
56
    {
57
        return JSONWebKeyTypes::OctetSequence;
58
    }
59
60
    /**
61
     * @return int
62
     */
63
    public function getBitLength()
64
    {
65
        return ByteUtil::bitLength(strlen($this->secret));
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getSecret()
72
    {
73
       return $this->secret;
74
    }
75
}