|
@@ -62,14 +62,14 @@ discard block |
|
|
block discarded – undo |
|
62
|
62
|
'a1_ele_len' => '44', |
|
63
|
63
|
'bit_str_beg' => '03', |
|
64
|
64
|
'bit_str_len' => '42', |
|
65
|
|
- 'bit_str_val' => '00' . $keypair[1], |
|
|
65
|
+ 'bit_str_val' => '00'.$keypair[1], |
|
66
|
66
|
); |
|
67
|
67
|
|
|
68
|
68
|
$dec = trim(implode($ecpemstruct)); |
|
69
|
69
|
|
|
70
|
70
|
$this->pemDataLenCheck($dec); |
|
71
|
71
|
|
|
72
|
|
- return '-----BEGIN EC PRIVATE KEY-----' . "\r\n" . chunk_split(base64_encode($this->binConv($dec)), 64) . '-----END EC PRIVATE KEY-----'; |
|
|
72
|
+ return '-----BEGIN EC PRIVATE KEY-----'."\r\n".chunk_split(base64_encode($this->binConv($dec)), 64).'-----END EC PRIVATE KEY-----'; |
|
73
|
73
|
} |
|
74
|
74
|
|
|
75
|
75
|
/** |
|
@@ -94,7 +94,7 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
$this->pemOidCheck($ecpemstruct['obj_id_val']); |
|
95
|
95
|
|
|
96
|
96
|
$private_key = $ecpemstruct['oct_sec_val']; |
|
97
|
|
- $public_key = '04' . $ecpemstruct['bit_str_val']; |
|
|
97
|
+ $public_key = '04'.$ecpemstruct['bit_str_val']; |
|
98
|
98
|
|
|
99
|
99
|
$this->pemKeyLenCheck(array($private_key, $public_key)); |
|
100
|
100
|
|
|
@@ -113,7 +113,7 @@ discard block |
|
|
block discarded – undo |
|
113
|
113
|
private function pemInitialDataCheck($keypair) |
|
114
|
114
|
{ |
|
115
|
115
|
if (true === empty($keypair) || false === is_array($keypair) || strlen($keypair[0]) < 62 || strlen($keypair[1]) < 126) { |
|
116
|
|
- throw new \Exception('Invalid or corrupt secp256k1 keypair provided. Cannot encode the keys to PEM format. Value checked was "' . var_export($keypair, true) . '".'); |
|
|
116
|
+ throw new \Exception('Invalid or corrupt secp256k1 keypair provided. Cannot encode the keys to PEM format. Value checked was "'.var_export($keypair, true).'".'); |
|
117
|
117
|
} |
|
118
|
118
|
} |
|
119
|
119
|
|
|
@@ -126,7 +126,7 @@ discard block |
|
|
block discarded – undo |
|
126
|
126
|
private function pemDataLenCheck($value) |
|
127
|
127
|
{ |
|
128
|
128
|
if (strlen($value) < 220) { |
|
129
|
|
- throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Length < 220. Value received was "' . var_export($value, true) . '".'); |
|
|
129
|
+ throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Length < 220. Value received was "'.var_export($value, true).'".'); |
|
130
|
130
|
} |
|
131
|
131
|
} |
|
132
|
132
|
|
|
@@ -139,7 +139,7 @@ discard block |
|
|
block discarded – undo |
|
139
|
139
|
private function pemKeyLenCheck($values) |
|
140
|
140
|
{ |
|
141
|
141
|
if (!is_array($values) || strlen($values[0]) < 62 || strlen($values[1]) < 126) { |
|
142
|
|
- throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Key lengths too short. Values checked were "' . var_export($values[0], true) . '" and "' . var_export($values[1], true) . '".'); |
|
|
142
|
+ throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. Key lengths too short. Values checked were "'.var_export($values[0], true).'" and "'.var_export($values[1], true).'".'); |
|
143
|
143
|
} |
|
144
|
144
|
} |
|
145
|
145
|
|
|
@@ -152,7 +152,7 @@ discard block |
|
|
block discarded – undo |
|
152
|
152
|
private function pemOidCheck($value) |
|
153
|
153
|
{ |
|
154
|
154
|
if ($value != '2b8104000a') { |
|
155
|
|
- throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. OID is not for EC key. Value checked was "' . var_export($value, true) . '".'); |
|
|
155
|
+ throw new \Exception('Invalid or corrupt secp256k1 key provided. Cannot decode the supplied PEM data. OID is not for EC key. Value checked was "'.var_export($value, true).'".'); |
|
156
|
156
|
} |
|
157
|
157
|
} |
|
158
|
158
|
|
|
@@ -222,7 +222,7 @@ discard block |
|
|
block discarded – undo |
|
222
|
222
|
$oid_string = ''; |
|
223
|
223
|
|
|
224
|
224
|
foreach ($oid as $key => $value) { |
|
225
|
|
- $oid_string .= $value . "."; |
|
|
225
|
+ $oid_string .= $value."."; |
|
226
|
226
|
} |
|
227
|
227
|
|
|
228
|
228
|
$oid_string = substr($oid_string, 0, -1); |