1+ <?php namespace security \rsa ;
2+ /**
3+ * Copyright 2025 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+ use phpseclib3 \Crypt \Common \AsymmetricKey ;
15+ use phpseclib3 \Crypt \RSA ;
16+ use phpseclib \Crypt \RSA as RSA_OLD ;
17+
18+ /**
19+ * @class CustomPrivateKey
20+ * this is a decorator in order to add getter fpr protected methods
21+ */
22+ class CustomAsymmetricKey extends RSA
23+ {
24+
25+ protected $ key ;
26+ public function __construct (AsymmetricKey $ key ){
27+ parent ::__construct ();
28+ $ this ->key = $ key ;
29+ }
30+ public function getModulus (){
31+ return $ this ->key ->modulus ;
32+ }
33+
34+ public function getPrivateExponent (){
35+ return $ this ->key ->exponent ;
36+ }
37+
38+ public function getPublicExponent (){
39+ return $ this ->key ->publicExponent ;
40+ }
41+
42+ public function toString ($ type = RSA_OLD ::PRIVATE_FORMAT_PKCS8 , array $ options = [])
43+ {
44+ return $ this ->key ->toString ($ type , $ options );
45+ }
46+ }
0 commit comments