NistCurve   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A curve256() 0 11 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SKien\PNServer\Utils;
5
6
/*
7
 * extracted required classes and functions from package
8
 *		spomky-labs/jose
9
 *		https://github.com/Spomky-Labs/Jose 
10
 *
11
 * @package PNServer
12
 * @version 1.0.0
13
 * @copyright MIT License - see the copyright below and LICENSE file for details
14
 */
15
16
/*
17
 * *********************************************************************
18
 * Copyright (C) 2012 Matyas Danter.
19
 *
20
 * Permission is hereby granted, free of charge, to any person obtaining
21
 * a copy of this software and associated documentation files (the "Software"),
22
 * to deal in the Software without restriction, including without limitation
23
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
24
 * and/or sell copies of the Software, and to permit persons to whom the
25
 * Software is furnished to do so, subject to the following conditions:
26
 *
27
 * The above copyright notice and this permission notice shall be included
28
 * in all copies or substantial portions of the Software.
29
 *
30
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
33
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
34
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
35
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
36
 * OTHER DEALINGS IN THE SOFTWARE.
37
 * ***********************************************************************
38
 */
39
40
/**
41
 * @internal
42
 */
43
class NistCurve
44
{
45
    /**
46
     * Returns an NIST P-256 curve.
47
     */
48
    public static function curve256() : Curve
49
    {
50
        $p = \gmp_init('ffffffff00000001000000000000000000000000ffffffffffffffffffffffff', 16);
51
        $a = \gmp_init('ffffffff00000001000000000000000000000000fffffffffffffffffffffffc', 16);
52
        $b = \gmp_init('5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b', 16);
53
        $x = \gmp_init('6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296', 16);
54
        $y = \gmp_init('4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5', 16);
55
        $n = \gmp_init('ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551', 16);
56
        $generator = Point::create($x, $y, $n);
0 ignored issues
show
Bug introduced by
It seems like $x can also be of type resource; however, parameter $x of SKien\PNServer\Utils\Point::create() does only seem to accept GMP, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
        $generator = Point::create(/** @scrutinizer ignore-type */ $x, $y, $n);
Loading history...
Bug introduced by
It seems like $y can also be of type resource; however, parameter $y of SKien\PNServer\Utils\Point::create() does only seem to accept GMP, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
        $generator = Point::create($x, /** @scrutinizer ignore-type */ $y, $n);
Loading history...
Bug introduced by
It seems like $n can also be of type resource; however, parameter $order of SKien\PNServer\Utils\Point::create() does only seem to accept GMP|null, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
        $generator = Point::create($x, $y, /** @scrutinizer ignore-type */ $n);
Loading history...
57
58
        return new Curve(256, $p, $a, $b, $generator);
0 ignored issues
show
Bug introduced by
It seems like $a can also be of type resource; however, parameter $a of SKien\PNServer\Utils\Curve::__construct() does only seem to accept GMP, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        return new Curve(256, $p, /** @scrutinizer ignore-type */ $a, $b, $generator);
Loading history...
Bug introduced by
It seems like $b can also be of type resource; however, parameter $b of SKien\PNServer\Utils\Curve::__construct() does only seem to accept GMP, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        return new Curve(256, $p, $a, /** @scrutinizer ignore-type */ $b, $generator);
Loading history...
Bug introduced by
It seems like $p can also be of type resource; however, parameter $prime of SKien\PNServer\Utils\Curve::__construct() does only seem to accept GMP, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
        return new Curve(256, /** @scrutinizer ignore-type */ $p, $a, $b, $generator);
Loading history...
59
    }
60
}
61