DownloadCrypto (abstract)
Namespace: \ParagonIE\Halite\Asymmetric
Methods
getSharedSecret()
> public getSharedSecret(EncryptionSecretKey $privateKey , EncryptionPublicKey $publicKey , $get_as_object = false ) : EncryptionKey
This method calculates a shared EncryptionKey
using Elliptic Curve Diffie Hellman key agreement over Curve25519.
encrypt()
> public encrypt(string $source , EncryptionSecretKey $ourPrivateKey , EncryptionPublicKey $theirPublicKey , boolean $raw = false ) : string
This method will:
-
Calculate a shared symmetric encryption key between your secret key and your
recipient's public key.
-
Generate a random HKDF salt.
-
Split the shared secret using salted HKDF.
-
Generate a random nonce.
-
Encrypt your plaintext (`$source`) with the derived encryption key (step 3).
-
MAC the ciphertext (step 5), along with the current library version, the HKDF
salt, and the nonce, with the derived authentication key (step 3).
-
Return the output of step 6 either as raw binary or as a hex-encoded string.
decrypt()
> public decrypt(string $source , EncryptionSecretKey $ourPrivateKey , EncryptionPublicKey $theirPublicKey , boolean $raw = false ) : string
This method will:
-
If we aren't expecting raw data, we treat `$source` as a hex string and
decode it to raw binary.
-
Calculate a shared symmetric encryption key between your secret key and the
sender's public key.
-
Parse the library version tag, HKDF salt, and nonce from the message.
-
Split the shared secret using salted HKDF.
-
Verify the MAC using the derived authentication key (step 4).
-
If step 5 is successful, decrypt the ciphertext with the derived encryption
key (step 4).
-
Return what should be the original plaintext.
seal()
> public seal(string $source , EncryptionPublicKey $publicKey , boolean $raw = false ) : string
Anonymous public-key encryption. Encrypt a message with your recipient's public
key and they can use their secret key to decrypt it.
The actual underlying protocol is \Sodium\crypto_box_seal() .
unseal()
> public unseal(string $source , EncryptionSecretKey $secretKey , boolean $raw = false ) : string
Anonymous public-key decryption. Decrypt a sealed message with your secret key.
The actual underlying protocol is \Sodium\crypto_box_seal_open() .
sign()
> public sign(string $message , SignatureSecretKey $secretKey , boolean $raw = false ) : string
Calculates a digital signature of $message , using \Sodium\crypto_sign() .
verify()
> public verify(string $message , SignaturePublicKey $secretKey , string $signature , boolean $raw = false ) : boolean
Does the signature match the contents of the message, for the given public key?
|