Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 996c016

Browse files
author
tkm
committed
Improve PhpDocComments
1 parent 9613b27 commit 996c016

File tree

3 files changed

+58
-27
lines changed

3 files changed

+58
-27
lines changed

src/Developer/Encryption/FieldLevelEncryptionConfig.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Mastercard\Developer\Encryption;
44

5+
use OpenSSLAsymmetricKey;
6+
use OpenSSLCertificate;
7+
58
/**
69
* A class for storing the encryption/decryption configuration.
710
* @package Mastercard\Developer\Encryption
@@ -10,7 +13,7 @@ class FieldLevelEncryptionConfig {
1013

1114
/**
1215
* A certificate object whose public key will be used for encryption.
13-
* @var resource
16+
* @var OpenSSLCertificate|resource|string
1417
*/
1518
private $encryptionCertificate;
1619

@@ -32,7 +35,7 @@ class FieldLevelEncryptionConfig {
3235

3336
/**
3437
* A private key object to be used for decryption.
35-
* @var resource
38+
* @var OpenSSLAsymmetricKey|resource
3639
*/
3740
private $decryptionKey;
3841

@@ -161,25 +164,26 @@ public function useHttpPayloads() {
161164

162165
/**
163166
* FieldLevelEncryptionConfig constructor.
164-
* @param resource $encryptionCertificate
165-
* @param string $encryptionCertificateFingerprint
166-
* @param string $encryptionKeyFingerprint
167-
* @param resource $decryptionKey
168-
* @param array $encryptionPaths
169-
* @param array $decryptionPaths
170-
* @param string $oaepPaddingDigestAlgorithm
171-
* @param string|null $oaepPaddingDigestAlgorithmFieldName
172-
* @param string|null $oaepPaddingDigestAlgorithmHeaderName
173-
* @param string|null $ivFieldName
174-
* @param string|null $ivHeaderName
175-
* @param string|null $encryptedKeyFieldName
176-
* @param string|null $encryptedKeyHeaderName
177-
* @param string|null $encryptedValueFieldName
178-
* @param string|null $encryptionCertificateFingerprintFieldName
179-
* @param string|null $encryptionCertificateFingerprintHeaderName
180-
* @param string|null $encryptionKeyFingerprintFieldName
181-
* @param string|null $encryptionKeyFingerprintHeaderName
182-
* @param int $fieldValueEncoding
167+
*
168+
* @param OpenSSLCertificate|resource|string $encryptionCertificate
169+
* @param string $encryptionCertificateFingerprint
170+
* @param string $encryptionKeyFingerprint
171+
* @param OpenSSLAsymmetricKey|resource $decryptionKey
172+
* @param array $encryptionPaths
173+
* @param array $decryptionPaths
174+
* @param string $oaepPaddingDigestAlgorithm
175+
* @param string|null $oaepPaddingDigestAlgorithmFieldName
176+
* @param string|null $oaepPaddingDigestAlgorithmHeaderName
177+
* @param string|null $ivFieldName
178+
* @param string|null $ivHeaderName
179+
* @param string|null $encryptedKeyFieldName
180+
* @param string|null $encryptedKeyHeaderName
181+
* @param string|null $encryptedValueFieldName
182+
* @param string|null $encryptionCertificateFingerprintFieldName
183+
* @param string|null $encryptionCertificateFingerprintHeaderName
184+
* @param string|null $encryptionKeyFingerprintFieldName
185+
* @param string|null $encryptionKeyFingerprintHeaderName
186+
* @param int $fieldValueEncoding
183187
*/
184188
public function __construct($encryptionCertificate, $encryptionCertificateFingerprint, $encryptionKeyFingerprint, $decryptionKey, $encryptionPaths, $decryptionPaths, $oaepPaddingDigestAlgorithm, $oaepPaddingDigestAlgorithmFieldName, $oaepPaddingDigestAlgorithmHeaderName, $ivFieldName, $ivHeaderName, $encryptedKeyFieldName, $encryptedKeyHeaderName, $encryptedValueFieldName, $encryptionCertificateFingerprintFieldName, $encryptionCertificateFingerprintHeaderName, $encryptionKeyFingerprintFieldName, $encryptionKeyFingerprintHeaderName, $fieldValueEncoding) {
185189
$this->encryptionCertificate = $encryptionCertificate;
@@ -204,7 +208,7 @@ public function __construct($encryptionCertificate, $encryptionCertificateFinger
204208
}
205209

206210
/**
207-
* @return resource
211+
* @return OpenSSLCertificate|resource|string
208212
*/
209213
public function getEncryptionCertificate() {
210214
return $this->encryptionCertificate;
@@ -225,7 +229,7 @@ public function getEncryptionKeyFingerprint() {
225229
}
226230

227231
/**
228-
* @return resource
232+
* @return OpenSSLAsymmetricKey|resource
229233
*/
230234
public function getDecryptionKey() {
231235
return $this->decryptionKey;

src/Developer/Encryption/FieldLevelEncryptionConfigBuilder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Mastercard\Developer\Json\JsonPath;
66
use Mastercard\Developer\Utils\EncodingUtils;
7+
use OpenSSLAsymmetricKey;
8+
use OpenSSLCertificate;
79
use phpseclib\Crypt\Hash;
810

911
/**
@@ -46,7 +48,7 @@ public static function aFieldLevelEncryptionConfig() {
4648
}
4749

4850
/**
49-
* @param resource $encryptionCertificate
51+
* @param OpenSSLCertificate|resource|string $encryptionCertificate
5052
* @see FieldLevelEncryptionConfig::encryptionCertificate.
5153
* @return $this
5254
*/
@@ -76,7 +78,7 @@ public function withEncryptionKeyFingerprint($encryptionKeyFingerprint) {
7678
}
7779

7880
/**
79-
* @param resource $decryptionKey
81+
* @param OpenSSLAsymmetricKey|resource $decryptionKey
8082
* @see FieldLevelEncryptionConfig::decryptionKey.
8183
* @return $this
8284
*/

src/Developer/Encryption/FieldLevelEncryptionParams.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FieldLevelEncryptionParams {
2626
* @param FieldLevelEncryptionConfig $config
2727
* @param string|null $ivValue
2828
* @param string|null $encryptedKeyValue
29-
* @param null $oaepPaddingDigestAlgorithmValue
29+
* @param string|null $oaepPaddingDigestAlgorithmValue
3030
*/
3131
public function __construct($config, $ivValue, $encryptedKeyValue, $oaepPaddingDigestAlgorithmValue = null) {
3232
$this->ivValue = $ivValue;
@@ -65,21 +65,28 @@ public static function generate($config) {
6565
}
6666

6767
/**
68-
* @return string
68+
* @return string|null
6969
*/
7070
public function getIvValue() {
7171
return $this->ivValue;
7272
}
7373

74+
/**
75+
* @return string|null
76+
*/
7477
public function getEncryptedKeyValue() {
7578
return $this->encryptedKeyValue;
7679
}
7780

81+
/**
82+
* @return string|null
83+
*/
7884
public function getOaepPaddingDigestAlgorithmValue() {
7985
return $this->oaepPaddingDigestAlgorithmValue;
8086
}
8187

8288
/**
89+
* @return string|false
8390
* @throws EncryptionException
8491
*/
8592
public function getIvBytes() {
@@ -96,6 +103,7 @@ public function getIvBytes() {
96103
}
97104

98105
/**
106+
* @return string
99107
* @throws EncryptionException
100108
*/
101109
public function getSecretKeyBytes() {
@@ -115,6 +123,9 @@ public function getSecretKeyBytes() {
115123
}
116124

117125
/**
126+
* @param FieldLevelEncryptionConfig $config
127+
* @param string $keyBytes
128+
* @return string
118129
* @throws EncryptionException
119130
*/
120131
private static function wrapSecretKey($config, $keyBytes) {
@@ -131,6 +142,10 @@ private static function wrapSecretKey($config, $keyBytes) {
131142
}
132143

133144
/**
145+
* @param FieldLevelEncryptionConfig $config
146+
* @param string $wrappedKeyBytes
147+
* @param string $oaepPaddingDigestAlgorithm
148+
* @return string
134149
* @throws EncryptionException
135150
*/
136151
private static function unwrapSecretKey($config, $wrappedKeyBytes, $oaepPaddingDigestAlgorithm) {
@@ -144,6 +159,12 @@ private static function unwrapSecretKey($config, $wrappedKeyBytes, $oaepPaddingD
144159
}
145160
}
146161

162+
/**
163+
* @param string $oaepPaddingDigestAlgorithm
164+
* @param string $key
165+
* @param int|false $type
166+
* @return RSA
167+
*/
147168
private static function getRsa($oaepPaddingDigestAlgorithm, $key, $type) {
148169
$rsa = new RSA();
149170
$rsa->setEncryptionMode(RSA::ENCRYPTION_OAEP);
@@ -154,6 +175,10 @@ private static function getRsa($oaepPaddingDigestAlgorithm, $key, $type) {
154175
return $rsa;
155176
}
156177

178+
/**
179+
* @param array $raw
180+
* @return string
181+
*/
157182
private static function toDsigXmlPrivateKey($raw) {
158183
return "<RSAKeyValue>\r\n" .
159184
' <Modulus>' . base64_encode($raw['n']) . "</Modulus>\r\n" .

0 commit comments

Comments
 (0)