Rev 1042 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1042 | Rev 1439 | ||
---|---|---|---|
Line 46... | Line 46... | ||
46 | * Default constructor |
46 | * Default constructor |
47 | */ |
47 | */ |
48 | public function __construct(...$indices) |
48 | public function __construct(...$indices) |
49 | { |
49 | { |
50 | $m = array_shift($indices); |
50 | $m = array_shift($indices); |
- | 51 | if ($m > 571) { |
|
- | 52 | /* sect571r1 and sect571k1 are the largest binary curves that https://www.secg.org/sec2-v2.pdf defines |
|
- | 53 | altho theoretically there may be legit reasons to use binary finite fields with larger degrees |
|
- | 54 | imposing a limit on the maximum size is both reasonable and precedented. in particular, |
|
- | 55 | http://tools.ietf.org/html/rfc4253#section-6.1 (The Secure Shell (SSH) Transport Layer Protocol) says |
|
- | 56 | "implementations SHOULD check that the packet length is reasonable in order for the implementation to |
|
- | 57 | avoid denial of service and/or buffer overflow attacks" */ |
|
- | 58 | throw new \OutOfBoundsException('Degrees larger than 571 are not supported'); |
|
- | 59 | } |
|
51 | $val = str_repeat('0', $m) . '1'; |
60 | $val = str_repeat('0', $m) . '1'; |
52 | foreach ($indices as $index) { |
61 | foreach ($indices as $index) { |
53 | $val[$index] = '1'; |
62 | $val[$index] = '1'; |
54 | } |
63 | } |
55 | $modulo = static::base2ToBase256(strrev($val)); |
64 | $modulo = static::base2ToBase256(strrev($val)); |