PHP Class Minishlink\WebPush\Encryption

Mostrar archivo Open project: minishlink/web-push Class Usage Examples

Public Methods

Method Description
encrypt ( string $payload, string $userPublicKey, string $userAuthToken, boolean $nativeEncryption ) : array
padPayload ( string $payload, boolean $maxLengthToPad ) : string

Private Methods

Method Description
createContext ( $clientPublicKey, $serverPublicKey ) : string Creates a context for deriving encyption parameters.
createInfo ( $type, $context ) : string Returns an info record. See sections 3.2 and 3.3 of {@link https://tools.ietf.org/html/draft-ietf-httpbis-encryption-encoding-00} From {@link https://github.com/GoogleChrome/push-encryption-node/blob/master/src/encrypt.js}.
hkdf ( $salt, $ikm, $info, $length ) : string HMAC-based Extract-and-Expand Key Derivation Function (HKDF).

Method Details

encrypt() public static method

public static encrypt ( string $payload, string $userPublicKey, string $userAuthToken, boolean $nativeEncryption ) : array
$payload string With padding
$userPublicKey string Base 64 encoded (MIME or URL-safe)
$userAuthToken string Base 64 encoded (MIME or URL-safe)
$nativeEncryption boolean Use OpenSSL (>PHP7.1)
return array

padPayload() public static method

public static padPayload ( string $payload, boolean $maxLengthToPad ) : string
$payload string
$maxLengthToPad boolean
return string padded payload (plaintext)