Skip to content

Commit

Permalink
Stricter typing
Browse files Browse the repository at this point in the history
  • Loading branch information
paragonie-scott committed Oct 26, 2015
1 parent db97a20 commit fe87a33
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 106 deletions.
26 changes: 16 additions & 10 deletions src/Contract/FileInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
use \ParagonIE\Halite\Asymmetric\PublicKey;
use \ParagonIE\Halite\Asymmetric\SecretKey;
use \ParagonIE\Halite\Symmetric\SecretKey as SymmetricKey;
use \ParagonIE\Halite\Asymmetric\EncryptionSecretKey;
use \ParagonIE\Halite\Asymmetric\EncryptionPublicKey;
use \ParagonIE\Halite\Asymmetric\SignatureSecretKey;
use \ParagonIE\Halite\Asymmetric\SignaturePublicKey;
use \ParagonIE\Halite\Symmetric\AuthenticationKey;
use \ParagonIE\Halite\Symmetric\EncryptionKey;

/**
* An interface for encrypting/decrypting files
Expand All @@ -20,7 +26,7 @@ interface FileInterface
public static function encryptFile(
$inputFile,
$outputFile,
SymmetricKey $key
EncryptionKey $key
);

/**
Expand All @@ -33,7 +39,7 @@ public static function encryptFile(
public static function decryptFile(
$inputFile,
$outputFile,
SymmetricKey $key
EncryptionKey $key
);

/**
Expand All @@ -46,7 +52,7 @@ public static function decryptFile(
public static function sealFile(
$inputFile,
$outputFile,
PublicKey $publickey
EncryptionPublicKey $publickey
);

/**
Expand All @@ -59,7 +65,7 @@ public static function sealFile(
public static function unsealFile(
$inputFile,
$outputFile,
SecretKey $secretkey
EncryptionSecretKey $secretkey
);

/**
Expand All @@ -72,7 +78,7 @@ public static function unsealFile(
public static function encryptResource(
$input,
$output,
SymmetricKey $key
EncryptionKey $key
);

/**
Expand All @@ -85,7 +91,7 @@ public static function encryptResource(
public static function decryptResource(
$input,
$output,
SymmetricKey $key
EncryptionKey $key
);

/**
Expand All @@ -98,7 +104,7 @@ public static function decryptResource(
public static function sealResource(
$input,
$output,
PublicKey $publickey
EncryptionPublicKey $publickey
);

/**
Expand All @@ -111,7 +117,7 @@ public static function sealResource(
public static function unsealResource(
$input,
$output,
SecretKey $secretkey
EncryptionSecretKey $secretkey
);


Expand All @@ -126,7 +132,7 @@ public static function unsealResource(
*/
public static function checksumFile(
$filepath,
SymmetricKey $key = null,
AuthenticationKey $key = null,
$raw = false
);

Expand All @@ -142,7 +148,7 @@ public static function checksumFile(
*/
public static function checksumResource(
$fileHandle,
SymmetricKey $key = null,
AuthenticationKey $key = null,
$raw = false
);
}
3 changes: 2 additions & 1 deletion src/EncryptionKeyPair.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __debugInfo()
'publicKey' => '**protected**'
];
}

/**
* Derive an encryption key from a password and a salt
*
Expand Down Expand Up @@ -67,7 +68,7 @@ public static function generate($type = Key::CRYPTO_BOX, &$secret_key = null)
}
if (Key::hasFlag($type, Key::ENCRYPTION)) {
$key = EncryptionSecretKey::generate(Key::CRYPTO_BOX, $secret_key);
$keypair = new KeyPair(...$key);
$keypair = new EncryptionKeyPair(...$key);
return $keypair;
}
throw new CryptoException\InvalidKey(
Expand Down
Loading

0 comments on commit fe87a33

Please sign in to comment.