Skip to content

Commit

Permalink
Move convenience method definitions outside of AdapterInterface.
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-security committed Jun 23, 2017
1 parent bdad237 commit 5c9532d
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 709 deletions.
329 changes: 1 addition & 328 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,7 @@
declare(strict_types=1);
namespace ParagonIE\Sapient\Adapter;

use ParagonIE\Sapient\Exception\{
InvalidMessageException
};
use ParagonIE\Sapient\CryptographyKeys\{
SealingPublicKey,
SharedAuthenticationKey,
SharedEncryptionKey,
SigningSecretKey
};
use Psr\Http\Message\{
RequestInterface,
ResponseInterface,
StreamInterface
};
use Psr\Http\Message\StreamInterface;


/**
Expand All @@ -24,320 +11,6 @@
*/
interface AdapterInterface
{
/**
* Create an HTTP request object with a JSON body that is authenticated
* with a pre-shared key. The authentication tag is stored in a
* Body-HMAC-SHA512256 header.
*
* @param string $method
* @param string $uri
* @param array $arrayToJsonify
* @param SharedAuthenticationKey $key
* @param array $headers
* @return RequestInterface
* @throws InvalidMessageException
*/
public function createSymmetricAuthenticatedJsonRequest(
string $method,
string $uri,
array $arrayToJsonify,
SharedAuthenticationKey $key,
array $headers = []
): RequestInterface;

/**
* Create an HTTP response object with a JSON body that is authenticated
* with a pre-shared key. The authentication tag is stored in a
* Body-HMAC-SHA512256 header.
*
* @param int $status
* @param array $arrayToJsonify
* @param SharedAuthenticationKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
* @throws InvalidMessageException
*/
public function createSymmetricAuthenticatedJsonResponse(
int $status,
array $arrayToJsonify,
SharedAuthenticationKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Create an HTTP request object with a JSON body that is encrypted
* with a pre-shared key.
*
* @param string $method
* @param string $uri
* @param array $arrayToJsonify
* @param SharedEncryptionKey $key
* @param array $headers
* @return RequestInterface
* @throws InvalidMessageException
*/
public function createSymmetricEncryptedJsonRequest(
string $method,
string $uri,
array $arrayToJsonify,
SharedEncryptionKey $key,
array $headers = []
): RequestInterface;

/**
* Create an HTTP response object with a JSON body that is encrypted
* with a pre-shared key.
*
* @param int $status
* @param array $arrayToJsonify
* @param SharedEncryptionKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
* @throws InvalidMessageException
*/
public function createSymmetricEncryptedJsonResponse(
int $status,
array $arrayToJsonify,
SharedEncryptionKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Create an HTTP request object with a JSON body that is encrypted
* with the server's public key.
*
* @param string $method
* @param string $uri
* @param array $arrayToJsonify
* @param SealingPublicKey $key
* @param array $headers
* @return RequestInterface
* @throws InvalidMessageException
*/
public function createSealedJsonRequest(
string $method,
string $uri,
array $arrayToJsonify,
SealingPublicKey $key,
array $headers = []
): RequestInterface;

/**
* Create an HTTP response object with a JSON body that is encrypted
* with the server's public key.
*
* @param int $status
* @param array $arrayToJsonify
* @param SealingPublicKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
* @throws InvalidMessageException
*/
public function createSealedJsonResponse(
int $status,
array $arrayToJsonify,
SealingPublicKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Creates a JSON-signed API request to be sent to an API.
* Enforces hard-coded Ed25519 keys.
*
* @param string $method
* @param string $uri
* @param array $arrayToJsonify
* @param SigningSecretKey $key
* @param array $headers
* @return RequestInterface
* @throws InvalidMessageException
*/
public function createSignedJsonRequest(
string $method,
string $uri,
array $arrayToJsonify,
SigningSecretKey $key,
array $headers = []
): RequestInterface;

/**
* Creates a JSON-signed API response to be returned from an API.
* Enforces hard-coded Ed25519 keys.
*
* @param int $status
* @param array $arrayToJsonify
* @param SigningSecretKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
* @throws InvalidMessageException
*/
public function createSignedJsonResponse(
int $status,
array $arrayToJsonify,
SigningSecretKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Authenticate your HTTP request with a pre-shared key.
*
* @param string $method
* @param string $uri
* @param string $body
* @param SharedAuthenticationKey $key
* @param array $headers
* @return RequestInterface
*/
public function createSymmetricAuthenticatedRequest(
string $method,
string $uri,
string $body,
SharedAuthenticationKey $key,
array $headers = []
): RequestInterface;

/**
* Authenticate your HTTP response with a pre-shared key.
*
* @param int $status
* @param string $body
* @param SharedAuthenticationKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
*/
public function createSymmetricAuthenticatedResponse(
int $status,
string $body,
SharedAuthenticationKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Encrypt your HTTP request with a pre-shared key.
*
* @param string $method
* @param string $uri
* @param string $body
* @param SharedEncryptionKey $key
* @param array $headers
* @return RequestInterface
*/
public function createSymmetricEncryptedRequest(
string $method,
string $uri,
string $body,
SharedEncryptionKey $key,
array $headers = []
): RequestInterface;

/**
* Encrypt your HTTP response with a pre-shared key.
*
* @param int $status
* @param string $body
* @param SharedEncryptionKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
*/
public function createSymmetricEncryptedResponse(
int $status,
string $body,
SharedEncryptionKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Encrypt your HTTP request with the server's public key, so that only
* the server can decrypt the message.
*
* @param string $method
* @param string $uri
* @param string $body
* @param SealingPublicKey $key
* @param array $headers
* @return RequestInterface
*/
public function createSealedRequest(
string $method,
string $uri,
string $body,
SealingPublicKey $key,
array $headers = []
): RequestInterface;

/**
* Encrypt your HTTP response with the client's public key, so that only
* the client can decrypt the message.
*
* @param int $status
* @param string $body
* @param SealingPublicKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
*/
public function createSealedResponse(
int $status,
string $body,
SealingPublicKey $key,
array $headers = [],
string $version = '1.1'
): ResponseInterface;

/**
* Ed25519-sign a request body.
*
* This adds an HTTP header (Body-Signature-Ed25519) which is the base64url
* encoded Ed25519 signature of the HTTP request body.
*
* @param string $method
* @param string $uri
* @param string $body
* @param SigningSecretKey $key
* @param array $headers
* @return RequestInterface
*/
public function createSignedRequest(
string $method,
string $uri,
string $body,
SigningSecretKey $key,
array $headers = []
): RequestInterface;

/**
* Ed25519-sign a response body.
*
* This adds an HTTP header (Body-Signature-Ed25519) which is the base64url
* encoded Ed25519 signature of the HTTP response body.
*
* @param int $status
* @param string $body
* @param SigningSecretKey $key
* @param array $headers
* @param string $version
* @return ResponseInterface
*/
public function createSignedResponse(
int $status,
string $body,
SigningSecretKey $key,
array $headers = [],
string $version = '1.1'
);

/**
* Adapter-specific way of converting a string into a StreamInterface
*
Expand Down
Loading

0 comments on commit 5c9532d

Please sign in to comment.